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

namespace Azure.ResourceManager.Synapse.Models
{
    public partial class LinkedIntegrationRuntime
    {
        internal static LinkedIntegrationRuntime DeserializeLinkedIntegrationRuntime(JsonElement element)
        {
            Optional<string> name = default;
            Optional<string> subscriptionId = default;
            Optional<string> dataFactoryName = default;
            Optional<string> dataFactoryLocation = default;
            Optional<DateTimeOffset> createTime = default;
            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("name"))
                {
                    name = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("subscriptionId"))
                {
                    subscriptionId = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("dataFactoryName"))
                {
                    dataFactoryName = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("dataFactoryLocation"))
                {
                    dataFactoryLocation = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("createTime"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    createTime = property.Value.GetDateTimeOffset("O");
                    continue;
                }
            }
            return new LinkedIntegrationRuntime(name.Value, subscriptionId.Value, dataFactoryName.Value, dataFactoryLocation.Value, Optional.ToNullable(createTime));
        }
    }
}
