/* 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.AdrBaseService
{
    /// <summary>
    /// Reference to the device that provides data for this asset. Must provide device name & endpoint on the device to use.
    /// </summary>
    [System.CodeDom.Compiler.GeneratedCode("Azure.Iot.Operations.ProtocolCompilerLib", "1.0.0.0")]
    public partial class AssetDeviceRef : IJsonOnDeserialized, IJsonOnSerializing
    {
        /// <summary>
        /// Name of the device resource.
        /// </summary>
        [JsonPropertyName("deviceName")]
        [JsonIgnore(Condition = JsonIgnoreCondition.Never)]
        [JsonRequired]
        public string DeviceName { get; set; } = default!;

        /// <summary>
        /// The name of endpoint to use.
        /// </summary>
        [JsonPropertyName("endpointName")]
        [JsonIgnore(Condition = JsonIgnoreCondition.Never)]
        [JsonRequired]
        public string EndpointName { get; set; } = default!;

        void IJsonOnDeserialized.OnDeserialized()
        {
            if (DeviceName is null)
            {
                throw new ArgumentNullException("deviceName field cannot be null");
            }
            if (EndpointName is null)
            {
                throw new ArgumentNullException("endpointName field cannot be null");
            }
        }

        void IJsonOnSerializing.OnSerializing()
        {
            if (DeviceName is null)
            {
                throw new ArgumentNullException("deviceName field cannot be null");
            }
            if (EndpointName is null)
            {
                throw new ArgumentNullException("endpointName field cannot be null");
            }
        }
    }
}
