/* Code generated by Azure.Iot.Operations.ProtocolCompilerLib v1.0.0.0; DO NOT EDIT. */

#nullable enable

using System;
using System.Collections.Generic;
using System.Text.Json.Serialization;
using Azure.Iot.Operations.Services.EdgeRegistry.Generated.Common;

namespace Azure.Iot.Operations.Services.EdgeRegistry.Generated
{
    /// <summary>
    /// Mutable attributes for creating or updating a Resource (its `meta` sub-entity).
    /// </summary>
    [System.CodeDom.Compiler.GeneratedCode("Azure.Iot.Operations.ProtocolCompilerLib", "1.0.0.0")]
    public partial class ResourceMetaAttributes : IJsonOnDeserialized, IJsonOnSerializing
    {
        /// <summary>
        /// Indicates that this Resource is a reference to another Resource within the same Registry. The XID path of the referenced Resource.
        /// </summary>
        [JsonPropertyName("xref")]
        [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)]
        public string? Xref { get; set; } = default;

        /// <summary>
        /// A mechanism in which additional metadata about the entity can be stored without changing the model definition of the entity. Labels can be used for querying.
        /// </summary>
        [JsonPropertyName("labels")]
        [JsonIgnore(Condition = JsonIgnoreCondition.Never)]
        [JsonRequired]
        public List<Label> Labels { get; set; } = default!;

        /// <summary>
        /// States that Versions of this Resource adhere to a certain compatibility rule.
        /// </summary>
        [JsonPropertyName("compatibility")]
        [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)]
        public string? Compatibility { get; set; } = default;

        /// <summary>
        /// Information about deprecation status of the entity, if applicable.
        /// </summary>
        [JsonPropertyName("deprecated")]
        [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)]
        public DeprecatedInfo? Deprecated { get; set; } = default;

        /// <summary>
        /// Extension-specific attributes (e.g., `format` and `content_type` for schemas).
        /// </summary>
        [JsonPropertyName("extensions")]
        [JsonIgnore(Condition = JsonIgnoreCondition.Never)]
        [JsonRequired]
        public Dictionary<string, byte[]> Extensions { get; set; } = default!;

        void IJsonOnDeserialized.OnDeserialized()
        {
            if (Labels is null)
            {
                throw new ArgumentNullException("labels field cannot be null");
            }
            if (Extensions is null)
            {
                throw new ArgumentNullException("extensions field cannot be null");
            }
        }

        void IJsonOnSerializing.OnSerializing()
        {
            if (Labels is null)
            {
                throw new ArgumentNullException("labels field cannot be null");
            }
            if (Extensions is null)
            {
                throw new ArgumentNullException("extensions field cannot be null");
            }
        }
    }
}
