// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

// <auto-generated/>

#nullable disable

using System.Text.Json;
using Azure.Core;
using Azure.ResourceManager.Resources.Models;

namespace Azure.ResourceManager.Cdn.Models
{
    public partial class OriginGroupOverrideActionParameters : IUtf8JsonSerializable
    {
        void IUtf8JsonSerializable.Write(Utf8JsonWriter writer)
        {
            writer.WriteStartObject();
            writer.WritePropertyName("@odata.type");
            writer.WriteStringValue(OdataType.ToString());
            writer.WritePropertyName("originGroup");
            JsonSerializer.Serialize(writer, OriginGroup); writer.WriteEndObject();
        }

        internal static OriginGroupOverrideActionParameters DeserializeOriginGroupOverrideActionParameters(JsonElement element)
        {
            OriginGroupOverrideActionParametersOdataType odataType = default;
            WritableSubResource originGroup = default;
            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("@odata.type"))
                {
                    odataType = new OriginGroupOverrideActionParametersOdataType(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("originGroup"))
                {
                    originGroup = JsonSerializer.Deserialize<WritableSubResource>(property.Value.ToString());
                    continue;
                }
            }
            return new OriginGroupOverrideActionParameters(odataType, originGroup);
        }
    }
}
