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

namespace Azure.Iot.Operations.Services.EdgeRegistry.Generated
{
    /// <summary>
    /// Request payload for creating a generic xRegistry Version entity. The parent Resource is implicitly created if it doesn't already exist. Create is strictly idempotent: if every field matches the latest Version of the parent Resource (including labels), the latest Version is returned; otherwise a new Version is created.
    /// </summary>
    [System.CodeDom.Compiler.GeneratedCode("Azure.Iot.Operations.ProtocolCompilerLib", "1.0.0.0")]
    public partial class CreateVersionRequestPayload : IJsonOnDeserialized, IJsonOnSerializing
    {
        /// <summary>
        /// Group identifier. Uses the default if not specified.
        /// </summary>
        [JsonPropertyName("groupId")]
        [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)]
        public string? GroupId { get; set; } = default;

        /// <summary>
        /// Version identifier of the Version to create. If omitted, the server determines the versionId.
        /// </summary>
        [JsonPropertyName("versionId")]
        [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)]
        public string? VersionId { get; set; } = default;

        /// <summary>
        /// The attributes of the Version to create.
        /// </summary>
        [JsonPropertyName("version")]
        [JsonIgnore(Condition = JsonIgnoreCondition.Never)]
        [JsonRequired]
        public VersionAttributes Version { get; set; } = default!;

        /// <summary>
        /// Queryable Key Value pairs to be added to the parent Resource. The parent Resource is implicitly created if it doesn't already exist.
        /// </summary>
        [JsonPropertyName("resourceLabels")]
        [JsonIgnore(Condition = JsonIgnoreCondition.Never)]
        [JsonRequired]
        public List<Label> ResourceLabels { get; set; } = default!;

        void IJsonOnDeserialized.OnDeserialized()
        {
            if (Version is null)
            {
                throw new ArgumentNullException("version field cannot be null");
            }
            if (ResourceLabels is null)
            {
                throw new ArgumentNullException("resourceLabels field cannot be null");
            }
        }

        void IJsonOnSerializing.OnSerializing()
        {
            if (Version is null)
            {
                throw new ArgumentNullException("version field cannot be null");
            }
            if (ResourceLabels is null)
            {
                throw new ArgumentNullException("resourceLabels field cannot be null");
            }
        }
    }
}
