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

namespace Azure.Iot.Operations.Services.AssetAndDeviceRegistry.Generated.DeviceDiscoveryService
{
    [System.CodeDom.Compiler.GeneratedCode("Azure.Iot.Operations.ProtocolCompilerLib", "1.0.0.0")]
    public partial class CreateOrUpdateDiscoveredDeviceRequestSchema : IJsonOnDeserialized, IJsonOnSerializing
    {
        /// <summary>
        /// The discovered device resource to create or update. Fields omitted in the request will be removed. The specified inbound endpoint will be added or updated in the inbound endpoints map.
        /// </summary>
        [JsonPropertyName("discoveredDevice")]
        [JsonIgnore(Condition = JsonIgnoreCondition.Never)]
        [JsonRequired]
        public DiscoveredDevice DiscoveredDevice { get; set; } = default!;

        /// <summary>
        /// The name of the discovered device to create or update. This field is used to perform deduplication of discovered devices.
        /// </summary>
        [JsonPropertyName("discoveredDeviceName")]
        [JsonIgnore(Condition = JsonIgnoreCondition.Never)]
        [JsonRequired]
        public string DiscoveredDeviceName { get; set; } = default!;

        void IJsonOnDeserialized.OnDeserialized()
        {
            if (DiscoveredDevice is null)
            {
                throw new ArgumentNullException("discoveredDevice field cannot be null");
            }
            if (DiscoveredDeviceName is null)
            {
                throw new ArgumentNullException("discoveredDeviceName field cannot be null");
            }
        }

        void IJsonOnSerializing.OnSerializing()
        {
            if (DiscoveredDevice is null)
            {
                throw new ArgumentNullException("discoveredDevice field cannot be null");
            }
            if (DiscoveredDeviceName is null)
            {
                throw new ArgumentNullException("discoveredDeviceName field cannot be null");
            }
        }
    }
}
