using System.Text.Json;
using Azure.Core;

namespace Azure.ResourceManager.MachineLearningServices.Models
{
    public partial class EnvironmentImageRequest : IUtf8JsonSerializable
    {
        void IUtf8JsonSerializable.Write(Utf8JsonWriter writer)
        {
            writer.WriteStartObject();
            if (Optional.IsDefined(DriverProgram))
            {
                writer.WritePropertyName("driverProgram");
                writer.WriteStringValue(DriverProgram);
            }
            if (Optional.IsCollectionDefined(Assets))
            {
                writer.WritePropertyName("assets");
                writer.WriteStartArray();
                foreach (var item in Assets)
                {
                    writer.WriteObjectValue(item);
                }
                writer.WriteEndArray();
            }
            if (Optional.IsCollectionDefined(ModelIds))
            {
                writer.WritePropertyName("modelIds");
                writer.WriteStartArray();
                foreach (var item in ModelIds)
                {
                    writer.WriteStringValue(item);
                }
                writer.WriteEndArray();
            }
            if (Optional.IsCollectionDefined(Models))
            {
                writer.WritePropertyName("models");
                writer.WriteStartArray();
                foreach (var item in Models)
                {
                    writer.WriteObjectValue(item);
                }
                writer.WriteEndArray();
            }
            if (Optional.IsDefined(Environment))
            {
                writer.WritePropertyName("environment");
                writer.WriteObjectValue(Environment);
            }
            if (Optional.IsDefined(EnvironmentReference))
            {
                writer.WritePropertyName("environmentReference");
                writer.WriteObjectValue(EnvironmentReference);
            }
            writer.WriteEndObject();
        }
    }
}
