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

        /// <summary>
        /// Version identifier.
        /// </summary>
        [JsonPropertyName("versionId")]
        [JsonIgnore(Condition = JsonIgnoreCondition.Never)]
        [JsonRequired]
        public string VersionId { get; set; } = default!;

        /// <summary>
        /// Full XID path.
        /// </summary>
        [JsonPropertyName("xid")]
        [JsonIgnore(Condition = JsonIgnoreCondition.Never)]
        [JsonRequired]
        public string Xid { 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>
        /// Human-readable name.
        /// </summary>
        [JsonPropertyName("name")]
        [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)]
        public string? Name { get; set; } = default;

        /// <summary>
        /// Indicates whether this Version is the default Version of the owning Resource.
        /// </summary>
        [JsonPropertyName("isDefault")]
        [JsonIgnore(Condition = JsonIgnoreCondition.Never)]
        [JsonRequired]
        public bool IsDefault { get; set; } = default!;

        /// <summary>
        /// A human-readable summary of the purpose of the entity.
        /// </summary>
        [JsonPropertyName("description")]
        [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)]
        public string? Description { get; set; } = default;

        /// <summary>
        /// A URL to additional information about this entity.
        /// </summary>
        [JsonPropertyName("documentation")]
        [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)]
        public string? Documentation { get; set; } = default;

        /// <summary>
        /// A URL to a graphical icon for the owning entity.
        /// </summary>
        [JsonPropertyName("icon")]
        [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)]
        public string? Icon { 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>
        /// The versionId of this Version's ancestor, or this Version's versionId if it has no ancestor.
        /// </summary>
        [JsonPropertyName("ancestor")]
        [JsonIgnore(Condition = JsonIgnoreCondition.Never)]
        [JsonRequired]
        public string Ancestor { get; set; } = default!;

        /// <summary>
        /// The media type of the entity as defined by RFC9110.
        /// </summary>
        [JsonPropertyName("contentType")]
        [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)]
        public string? ContentType { get; set; } = default;

        /// <summary>
        /// Identifies what the Version represents (e.g. `JsonSchema/draft-07`, `JSON-LD/1.1`).
        /// </summary>
        [JsonPropertyName("format")]
        [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)]
        public string? Format { get; set; } = default;

        /// <summary>
        /// When format validation is enabled, indicates whether the server has validated that the Version conforms to the rules defined by its `format` attribute.
        /// </summary>
        [JsonPropertyName("formatValidated")]
        [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)]
        public ValidationStatus? FormatValidated { get; set; } = default;

        /// <summary>
        /// When compatibility validation is enabled, indicates whether the server has validated that the Version conforms to the rules defined by its Resource's `meta.compatibility` attribute.
        /// </summary>
        [JsonPropertyName("compatibilityValidated")]
        [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)]
        public ValidationStatus? CompatibilityValidated { get; set; } = default;

        /// <summary>
        /// The raw document content for this Version as base64-encoded bytes. The interpretation (schema, thing description, thing model, …) is determined by the parent Resource's type.
        /// </summary>
        [JsonPropertyName("document")]
        [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)]
        public byte[]? Document { get; set; } = default;

        /// <summary>
        /// The hash of the document content for this Version.
        /// </summary>
        [JsonPropertyName("documentHash")]
        [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)]
        public string? DocumentHash { get; set; } = default;

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

        void IJsonOnDeserialized.OnDeserialized()
        {
            if (ResourceId is null)
            {
                throw new ArgumentNullException("resourceId field cannot be null");
            }
            if (VersionId is null)
            {
                throw new ArgumentNullException("versionId 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 (Ancestor is null)
            {
                throw new ArgumentNullException("ancestor field cannot be null");
            }
            if (Extensions is null)
            {
                throw new ArgumentNullException("extensions field cannot be null");
            }
        }

        void IJsonOnSerializing.OnSerializing()
        {
            if (ResourceId is null)
            {
                throw new ArgumentNullException("resourceId field cannot be null");
            }
            if (VersionId is null)
            {
                throw new ArgumentNullException("versionId 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 (Ancestor is null)
            {
                throw new ArgumentNullException("ancestor field cannot be null");
            }
            if (Extensions is null)
            {
                throw new ArgumentNullException("extensions field cannot be null");
            }
        }
    }
}
