internal AmlComputeProperties(OsType?osType, string vmSize, VmPriority?vmPriority, VirtualMachineImage virtualMachineImage, bool?isolatedNetwork, ScaleSettings scaleSettings, UserAccountCredentials userAccountCredentials, ResourceId subnet, RemoteLoginPortPublicAccess?remoteLoginPortPublicAccess, AllocationState?allocationState, DateTimeOffset?allocationStateTransitionTime, IReadOnlyList <MachineLearningServiceError> errors, int?currentNodeCount, int?targetNodeCount, NodeStateCounts nodeStateCounts, bool?enableNodePublicIp)
 {
     OsType                        = osType;
     VmSize                        = vmSize;
     VmPriority                    = vmPriority;
     VirtualMachineImage           = virtualMachineImage;
     IsolatedNetwork               = isolatedNetwork;
     ScaleSettings                 = scaleSettings;
     UserAccountCredentials        = userAccountCredentials;
     Subnet                        = subnet;
     RemoteLoginPortPublicAccess   = remoteLoginPortPublicAccess;
     AllocationState               = allocationState;
     AllocationStateTransitionTime = allocationStateTransitionTime;
     Errors                        = errors;
     CurrentNodeCount              = currentNodeCount;
     TargetNodeCount               = targetNodeCount;
     NodeStateCounts               = nodeStateCounts;
     EnableNodePublicIp            = enableNodePublicIp;
 }
        internal static AmlComputeProperties DeserializeAmlComputeProperties(JsonElement element)
        {
            Optional <OsType>              osType                                = default;
            Optional <string>              vmSize                                = default;
            Optional <VmPriority>          vmPriority                            = default;
            Optional <VirtualMachineImage> virtualMachineImage                   = default;
            Optional <bool>                        isolatedNetwork               = default;
            Optional <ScaleSettings>               scaleSettings                 = default;
            Optional <UserAccountCredentials>      userAccountCredentials        = default;
            Optional <ResourceId>                  subnet                        = default;
            Optional <RemoteLoginPortPublicAccess> remoteLoginPortPublicAccess   = default;
            Optional <AllocationState>             allocationState               = default;
            Optional <DateTimeOffset>              allocationStateTransitionTime = default;
            Optional <IReadOnlyList <MachineLearningServiceError> > errors       = default;
            Optional <int>             currentNodeCount                          = default;
            Optional <int>             targetNodeCount                           = default;
            Optional <NodeStateCounts> nodeStateCounts                           = default;
            Optional <bool>            enableNodePublicIp                        = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("osType"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    osType = new OsType(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("vmSize"))
                {
                    vmSize = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("vmPriority"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    vmPriority = new VmPriority(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("virtualMachineImage"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    virtualMachineImage = VirtualMachineImage.DeserializeVirtualMachineImage(property.Value);
                    continue;
                }
                if (property.NameEquals("isolatedNetwork"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    isolatedNetwork = property.Value.GetBoolean();
                    continue;
                }
                if (property.NameEquals("scaleSettings"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    scaleSettings = ScaleSettings.DeserializeScaleSettings(property.Value);
                    continue;
                }
                if (property.NameEquals("userAccountCredentials"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    userAccountCredentials = UserAccountCredentials.DeserializeUserAccountCredentials(property.Value);
                    continue;
                }
                if (property.NameEquals("subnet"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    subnet = ResourceId.DeserializeResourceId(property.Value);
                    continue;
                }
                if (property.NameEquals("remoteLoginPortPublicAccess"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    remoteLoginPortPublicAccess = new RemoteLoginPortPublicAccess(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("allocationState"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    allocationState = new AllocationState(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("allocationStateTransitionTime"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    allocationStateTransitionTime = property.Value.GetDateTimeOffset("O");
                    continue;
                }
                if (property.NameEquals("errors"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    List <MachineLearningServiceError> array = new List <MachineLearningServiceError>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(MachineLearningServiceError.DeserializeMachineLearningServiceError(item));
                    }
                    errors = array;
                    continue;
                }
                if (property.NameEquals("currentNodeCount"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    currentNodeCount = property.Value.GetInt32();
                    continue;
                }
                if (property.NameEquals("targetNodeCount"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    targetNodeCount = property.Value.GetInt32();
                    continue;
                }
                if (property.NameEquals("nodeStateCounts"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    nodeStateCounts = NodeStateCounts.DeserializeNodeStateCounts(property.Value);
                    continue;
                }
                if (property.NameEquals("enableNodePublicIp"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    enableNodePublicIp = property.Value.GetBoolean();
                    continue;
                }
            }
            return(new AmlComputeProperties(Optional.ToNullable(osType), vmSize.Value, Optional.ToNullable(vmPriority), virtualMachineImage.Value, Optional.ToNullable(isolatedNetwork), scaleSettings.Value, userAccountCredentials.Value, subnet.Value, Optional.ToNullable(remoteLoginPortPublicAccess), Optional.ToNullable(allocationState), Optional.ToNullable(allocationStateTransitionTime), Optional.ToList(errors), Optional.ToNullable(currentNodeCount), Optional.ToNullable(targetNodeCount), nodeStateCounts.Value, Optional.ToNullable(enableNodePublicIp)));
        }