Exemplo n.º 1
0
 internal ComputeInstanceProperties(string vmSize, ResourceId subnet, ApplicationSharingPolicy?applicationSharingPolicy, ComputeInstanceSshSettings sshSettings, ComputeInstanceConnectivityEndpoints connectivityEndpoints, IReadOnlyList <ComputeInstanceApplication> applications, ComputeInstanceCreatedBy createdBy, IReadOnlyList <MachineLearningServiceError> errors, ComputeInstanceState?state, ComputeInstanceAuthorizationType?computeInstanceAuthorizationType, PersonalComputeInstanceSettings personalComputeInstanceSettings, ComputeInstanceLastOperation lastOperation)
 {
     VmSize = vmSize;
     Subnet = subnet;
     ApplicationSharingPolicy = applicationSharingPolicy;
     SshSettings           = sshSettings;
     ConnectivityEndpoints = connectivityEndpoints;
     Applications          = applications;
     CreatedBy             = createdBy;
     Errors = errors;
     State  = state;
     ComputeInstanceAuthorizationType = computeInstanceAuthorizationType;
     PersonalComputeInstanceSettings  = personalComputeInstanceSettings;
     LastOperation = lastOperation;
 }
Exemplo n.º 2
0
        internal static ComputeInstanceProperties DeserializeComputeInstanceProperties(JsonElement element)
        {
            Optional <string>     vmSize = default;
            Optional <ResourceId> subnet = default;
            Optional <ApplicationSharingPolicy>                     applicationSharingPolicy = default;
            Optional <ComputeInstanceSshSettings>                   sshSettings           = default;
            Optional <ComputeInstanceConnectivityEndpoints>         connectivityEndpoints = default;
            Optional <IReadOnlyList <ComputeInstanceApplication> >  applications          = default;
            Optional <ComputeInstanceCreatedBy>                     createdBy             = default;
            Optional <IReadOnlyList <MachineLearningServiceError> > errors = default;
            Optional <ComputeInstanceState>             state = default;
            Optional <ComputeInstanceAuthorizationType> computeInstanceAuthorizationType = default;
            Optional <PersonalComputeInstanceSettings>  personalComputeInstanceSettings  = default;
            Optional <ComputeInstanceLastOperation>     lastOperation = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("vmSize"))
                {
                    vmSize = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("subnet"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    subnet = ResourceId.DeserializeResourceId(property.Value);
                    continue;
                }
                if (property.NameEquals("applicationSharingPolicy"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    applicationSharingPolicy = new ApplicationSharingPolicy(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("sshSettings"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    sshSettings = ComputeInstanceSshSettings.DeserializeComputeInstanceSshSettings(property.Value);
                    continue;
                }
                if (property.NameEquals("connectivityEndpoints"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    connectivityEndpoints = ComputeInstanceConnectivityEndpoints.DeserializeComputeInstanceConnectivityEndpoints(property.Value);
                    continue;
                }
                if (property.NameEquals("applications"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    List <ComputeInstanceApplication> array = new List <ComputeInstanceApplication>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(ComputeInstanceApplication.DeserializeComputeInstanceApplication(item));
                    }
                    applications = array;
                    continue;
                }
                if (property.NameEquals("createdBy"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    createdBy = ComputeInstanceCreatedBy.DeserializeComputeInstanceCreatedBy(property.Value);
                    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("state"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    state = new ComputeInstanceState(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("computeInstanceAuthorizationType"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    computeInstanceAuthorizationType = new ComputeInstanceAuthorizationType(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("personalComputeInstanceSettings"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    personalComputeInstanceSettings = PersonalComputeInstanceSettings.DeserializePersonalComputeInstanceSettings(property.Value);
                    continue;
                }
                if (property.NameEquals("lastOperation"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    lastOperation = ComputeInstanceLastOperation.DeserializeComputeInstanceLastOperation(property.Value);
                    continue;
                }
            }
            return(new ComputeInstanceProperties(vmSize.Value, subnet.Value, Optional.ToNullable(applicationSharingPolicy), sshSettings.Value, connectivityEndpoints.Value, Optional.ToList(applications), createdBy.Value, Optional.ToList(errors), Optional.ToNullable(state), Optional.ToNullable(computeInstanceAuthorizationType), personalComputeInstanceSettings.Value, lastOperation.Value));
        }