/* 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.Host.Generated.Common;

namespace Azure.Iot.Operations.Services.EdgeRegistry.Host.Generated
{
    /// <summary>
    /// Resource entity
    /// </summary>
    [System.CodeDom.Compiler.GeneratedCode("Azure.Iot.Operations.ProtocolCompilerLib", "1.0.0.0")]
    public partial class Resource : 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>
        /// An object that contains most of the Resource-level attributes.
        /// </summary>
        [JsonPropertyName("meta")]
        [JsonIgnore(Condition = JsonIgnoreCondition.Never)]
        [JsonRequired]
        public ResourceMeta Meta { get; set; } = default!;

        /// <summary>
        /// A specific Version of a Resource.
        /// </summary>
        [JsonPropertyName("defaultVersion")]
        [JsonIgnore(Condition = JsonIgnoreCondition.Never)]
        [JsonRequired]
        public Version DefaultVersion { get; set; } = default!;

        /// <summary>
        /// The number of Versions contained on the Resource.
        /// </summary>
        [JsonPropertyName("versionsCount")]
        [JsonIgnore(Condition = JsonIgnoreCondition.Never)]
        [JsonRequired]
        public ulong VersionsCount { 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 (Meta is null)
            {
                throw new ArgumentNullException("meta field cannot be null");
            }
            if (DefaultVersion is null)
            {
                throw new ArgumentNullException("defaultVersion 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 (Meta is null)
            {
                throw new ArgumentNullException("meta field cannot be null");
            }
            if (DefaultVersion is null)
            {
                throw new ArgumentNullException("defaultVersion field cannot be null");
            }
            if (Extensions is null)
            {
                throw new ArgumentNullException("extensions field cannot be null");
            }
        }
    }
}
