/* 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>
    /// Schema object that was created.
    /// </summary>
    [System.CodeDom.Compiler.GeneratedCode("Azure.Iot.Operations.ProtocolCompilerLib", "1.0.0.0")]
    public partial class Schema : IJsonOnDeserialized, IJsonOnSerializing
    {
        /// <summary>
        /// Human-readable description of the schema.
        /// </summary>
        [JsonPropertyName("description")]
        [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)]
        public string? Description { get; set; } = default;

        /// <summary>
        /// Human-readable display name.
        /// </summary>
        [JsonPropertyName("displayName")]
        [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)]
        public string? DisplayName { get; set; } = default;

        /// <summary>
        /// Format of the schema.
        /// </summary>
        [JsonPropertyName("format")]
        [JsonIgnore(Condition = JsonIgnoreCondition.Never)]
        [JsonRequired]
        public string Format { get; set; } = default!;

        /// <summary>
        /// Hash of the schema content.
        /// </summary>
        [JsonPropertyName("hash")]
        [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)]
        public string? Hash { get; set; } = default;

        /// <summary>
        /// Schema name.
        /// </summary>
        [JsonPropertyName("name")]
        [JsonIgnore(Condition = JsonIgnoreCondition.Never)]
        [JsonRequired]
        public string Name { get; set; } = default!;

        /// <summary>
        /// Schema registry namespace. Uniquely identifies a schema registry within a tenant.
        /// </summary>
        [JsonPropertyName("namespace")]
        [JsonIgnore(Condition = JsonIgnoreCondition.Never)]
        [JsonRequired]
        public string Namespace { get; set; } = default!;

        /// <summary>
        /// Content stored in the schema.
        /// </summary>
        [JsonPropertyName("schemaContent")]
        [JsonIgnore(Condition = JsonIgnoreCondition.Never)]
        [JsonRequired]
        public string SchemaContent { get; set; } = default!;

        /// <summary>
        /// Type of the schema.
        /// </summary>
        [JsonPropertyName("schemaType")]
        [JsonIgnore(Condition = JsonIgnoreCondition.Never)]
        [JsonRequired]
        public SchemaType SchemaType { get; set; } = default!;

        /// <summary>
        /// Schema tags.
        /// </summary>
        [JsonPropertyName("tags")]
        [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)]
        public Dictionary<string, string>? Tags { get; set; } = default;

        /// <summary>
        /// Version of the schema. Allowed between 0-9.
        /// </summary>
        [JsonPropertyName("version")]
        [JsonIgnore(Condition = JsonIgnoreCondition.Never)]
        [JsonRequired]
        public string Version { get; set; } = default!;

        void IJsonOnDeserialized.OnDeserialized()
        {
            if (Format is null)
            {
                throw new ArgumentNullException("format field cannot be null");
            }
            if (Name is null)
            {
                throw new ArgumentNullException("name field cannot be null");
            }
            if (Namespace is null)
            {
                throw new ArgumentNullException("namespace field cannot be null");
            }
            if (SchemaContent is null)
            {
                throw new ArgumentNullException("schemaContent field cannot be null");
            }
            if (Version is null)
            {
                throw new ArgumentNullException("version field cannot be null");
            }
        }

        void IJsonOnSerializing.OnSerializing()
        {
            if (Format is null)
            {
                throw new ArgumentNullException("format field cannot be null");
            }
            if (Name is null)
            {
                throw new ArgumentNullException("name field cannot be null");
            }
            if (Namespace is null)
            {
                throw new ArgumentNullException("namespace field cannot be null");
            }
            if (SchemaContent is null)
            {
                throw new ArgumentNullException("schemaContent field cannot be null");
            }
            if (Version is null)
            {
                throw new ArgumentNullException("version field cannot be null");
            }
        }
    }
}
