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

// <auto-generated/>

#nullable disable

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

namespace Azure.ResourceManager.Compute.Models
{
    internal partial class SupportedCapabilities : IUtf8JsonSerializable
    {
        void IUtf8JsonSerializable.Write(Utf8JsonWriter writer)
        {
            writer.WriteStartObject();
            if (Optional.IsDefined(AcceleratedNetwork))
            {
                writer.WritePropertyName("acceleratedNetwork");
                writer.WriteBooleanValue(AcceleratedNetwork.Value);
            }
            writer.WriteEndObject();
        }

        internal static SupportedCapabilities DeserializeSupportedCapabilities(JsonElement element)
        {
            Optional<bool> acceleratedNetwork = default;
            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("acceleratedNetwork"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    acceleratedNetwork = property.Value.GetBoolean();
                    continue;
                }
            }
            return new SupportedCapabilities(Optional.ToNullable(acceleratedNetwork));
        }
    }
}
