/* 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
{
    [System.CodeDom.Compiler.GeneratedCode("Azure.Iot.Operations.ProtocolCompilerLib", "1.0.0.0")]
    public partial class ResourceMeta : IJsonOnDeserialized, IJsonOnSerializing
    {
        /// <summary>
        /// Resource identifier.
        /// </summary>
        [JsonPropertyName("id")]
        [JsonIgnore(Condition = JsonIgnoreCondition.Never)]
        [JsonRequired]
        public string Id { get; set; } = default!;

        /// <summary>
        /// Full XID path.
        /// </summary>
        [JsonPropertyName("xid")]
        [JsonIgnore(Condition = JsonIgnoreCondition.Never)]
        [JsonRequired]
        public string Xid { get; set; } = default!;

        /// <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 numeric value used to determine whether an entity has been modified.
        /// </summary>
        [JsonPropertyName("epoch")]
        [JsonIgnore(Condition = JsonIgnoreCondition.Never)]
        [JsonRequired]
        public ulong Epoch { 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>
        /// The date/time of when the entity was created.
        /// </summary>
        [JsonPropertyName("createdAt")]
        [JsonIgnore(Condition = JsonIgnoreCondition.Never)]
        [JsonRequired]
        public DateTime CreatedAt { get; set; } = default!;

        /// <summary>
        /// The date/time of when the entity was last updated.
        /// </summary>
        [JsonPropertyName("modifiedAt")]
        [JsonIgnore(Condition = JsonIgnoreCondition.Never)]
        [JsonRequired]
        public DateTime ModifiedAt { get; set; } = default!;

        /// <summary>
        /// Indicates whether the Resource is updateable by clients.
        /// </summary>
        [JsonPropertyName("readOnly")]
        [JsonIgnore(Condition = JsonIgnoreCondition.Never)]
        [JsonRequired]
        public bool ReadOnly { 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>
        /// The versionId of the default Version of the Resource.
        /// </summary>
        [JsonPropertyName("defaultVersionId")]
        [JsonIgnore(Condition = JsonIgnoreCondition.Never)]
        [JsonRequired]
        public string DefaultVersionId { get; set; } = default!;

        /// <summary>
        /// A value of true means that `defaultVersionId` has been explicitly set and MUST NOT automatically change if other Versions are added or removed. A value of false means the default Version MUST be the newest Version, as defined by the Resource's versionmode algorithm.
        /// </summary>
        [JsonPropertyName("defaultVersionSticky")]
        [JsonIgnore(Condition = JsonIgnoreCondition.Never)]
        [JsonRequired]
        public bool DefaultVersionSticky { 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 (Id is null)
            {
                throw new ArgumentNullException("id field cannot be null");
            }
            if (Xid is null)
            {
                throw new ArgumentNullException("xid field cannot be null");
            }
            if (Labels is null)
            {
                throw new ArgumentNullException("labels field cannot be null");
            }
            if (DefaultVersionId is null)
            {
                throw new ArgumentNullException("defaultVersionId field cannot be null");
            }
            if (Extensions is null)
            {
                throw new ArgumentNullException("extensions field cannot be null");
            }
        }

        void IJsonOnSerializing.OnSerializing()
        {
            if (Id is null)
            {
                throw new ArgumentNullException("id field cannot be null");
            }
            if (Xid is null)
            {
                throw new ArgumentNullException("xid field cannot be null");
            }
            if (Labels is null)
            {
                throw new ArgumentNullException("labels field cannot be null");
            }
            if (DefaultVersionId is null)
            {
                throw new ArgumentNullException("defaultVersionId field cannot be null");
            }
            if (Extensions is null)
            {
                throw new ArgumentNullException("extensions field cannot be null");
            }
        }
    }
}
