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

        /// <summary>
        /// Full XID path, e.g. /schemagroups/mygroup
        /// </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>
        /// 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>
        /// Information about deprecation status of the entity, if applicable.
        /// </summary>
        [JsonPropertyName("deprecated")]
        [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)]
        public DeprecatedInfo? Deprecated { get; set; } = default;

        /// <summary>
        /// Map of the count of each Resource type contained within this Group, keyed by Resource type.
        /// </summary>
        [JsonPropertyName("resourcesCounts")]
        [JsonIgnore(Condition = JsonIgnoreCondition.Never)]
        [JsonRequired]
        public Dictionary<string, ulong> ResourcesCounts { get; set; } = default!;

        /// <summary>
        /// Extension-specific attributes (e.g., `envelope`, `protocol` for message Groups).
        /// </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 (ResourcesCounts is null)
            {
                throw new ArgumentNullException("resourcesCounts 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 (ResourcesCounts is null)
            {
                throw new ArgumentNullException("resourcesCounts field cannot be null");
            }
            if (Extensions is null)
            {
                throw new ArgumentNullException("extensions field cannot be null");
            }
        }
    }
}
