/* 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
{
    [System.CodeDom.Compiler.GeneratedCode("Azure.Iot.Operations.ProtocolCompilerLib", "1.0.0.0")]
    public partial class EdgeRegistryError : IJsonOnDeserialized, IJsonOnSerializing
    {
        /// <summary>
        /// HTTP-style response code.
        /// </summary>
        [JsonPropertyName("code")]
        [JsonIgnore(Condition = JsonIgnoreCondition.Never)]
        [JsonRequired]
        public ulong Code { get; set; } = default!;

        /// <summary>
        /// Detailed error description.
        /// </summary>
        [JsonPropertyName("detail")]
        [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)]
        public string? Detail { get; set; } = default;

        /// <summary>
        /// The component that raised the error.
        /// </summary>
        [JsonPropertyName("source")]
        [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)]
        public string? Source { get; set; } = default;

        /// <summary>
        /// HTTP-style response status text.
        /// </summary>
        [JsonPropertyName("status")]
        [JsonIgnore(Condition = JsonIgnoreCondition.Never)]
        [JsonRequired]
        public string Status { get; set; } = default!;

        /// <summary>
        /// The XID of the entity being processed when the error occurred, if applicable.
        /// </summary>
        [JsonPropertyName("subject")]
        [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)]
        public string? Subject { get; set; } = default;

        /// <summary>
        /// Short human-readable error title.
        /// </summary>
        [JsonPropertyName("title")]
        [JsonIgnore(Condition = JsonIgnoreCondition.Never)]
        [JsonRequired]
        public string Title { get; set; } = default!;

        /// <summary>
        /// URI identifying the error type.
        /// </summary>
        [JsonPropertyName("type")]
        [JsonIgnore(Condition = JsonIgnoreCondition.Never)]
        [JsonRequired]
        public string Type { get; set; } = default!;

        void IJsonOnDeserialized.OnDeserialized()
        {
            if (Status is null)
            {
                throw new ArgumentNullException("status field cannot be null");
            }
            if (Title is null)
            {
                throw new ArgumentNullException("title field cannot be null");
            }
            if (Type is null)
            {
                throw new ArgumentNullException("type field cannot be null");
            }
        }

        void IJsonOnSerializing.OnSerializing()
        {
            if (Status is null)
            {
                throw new ArgumentNullException("status field cannot be null");
            }
            if (Title is null)
            {
                throw new ArgumentNullException("title field cannot be null");
            }
            if (Type is null)
            {
                throw new ArgumentNullException("type field cannot be null");
            }
        }
    }
}
