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

namespace Azure.Iot.Operations.Services.SchemaRegistry.Generated
{
    /// <summary>
    /// Error object for schema operations
    /// </summary>
    [System.CodeDom.Compiler.GeneratedCode("Azure.Iot.Operations.ProtocolCompilerLib", "1.0.0.0")]
    public partial class SchemaRegistryError : IJsonOnDeserialized, IJsonOnSerializing
    {
        /// <summary>
        /// Error code for classification of errors (ex: '400', '404', '500', etc.).
        /// </summary>
        [JsonPropertyName("code")]
        [JsonIgnore(Condition = JsonIgnoreCondition.Never)]
        [JsonRequired]
        public int Code { get; set; } = default!;

        /// <summary>
        /// Additional details about the error, if available.
        /// </summary>
        [JsonPropertyName("details")]
        [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)]
        public SchemaRegistryErrorDetails? Details { get; set; } = default;

        /// <summary>
        /// Inner error object for nested errors, if applicable.
        /// </summary>
        [JsonPropertyName("innerError")]
        [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)]
        public SchemaRegistryErrorDetails? InnerError { get; set; } = default;

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

        /// <summary>
        /// Target of the error, if applicable (e.g., 'schemaType').
        /// </summary>
        [JsonPropertyName("target")]
        [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)]
        public string? Target { get; set; } = default;

        void IJsonOnDeserialized.OnDeserialized()
        {
            if (Message is null)
            {
                throw new ArgumentNullException("message field cannot be null");
            }
        }

        void IJsonOnSerializing.OnSerializing()
        {
            if (Message is null)
            {
                throw new ArgumentNullException("message field cannot be null");
            }
        }
    }
}
