Пример #1
0
 internal ComputeInstanceProperties(string vmSize, ResourceId subnet, ApplicationSharingPolicy?applicationSharingPolicy, ComputeInstanceSshSettings sshSettings, ComputeInstanceConnectivityEndpoints connectivityEndpoints, IReadOnlyList <ComputeInstanceApplication> applications, ComputeInstanceCreatedBy createdBy, IReadOnlyList <ErrorResponse> errors, ComputeInstanceState?state, ComputeInstanceAuthorizationType?computeInstanceAuthorizationType, PersonalComputeInstanceSettings personalComputeInstanceSettings, SetupScripts setupScriptsSettings, ComputeInstanceLastOperation lastOperation, ComputeSchedules schedules, bool?enableNodePublicIP, IReadOnlyList <ComputeInstanceContainer> containers, IReadOnlyList <ComputeInstanceDataDisk> dataDisks, IReadOnlyList <ComputeInstanceDataMount> dataMounts, ComputeInstanceVersion versions)
 {
     VmSize = vmSize;
     Subnet = subnet;
     ApplicationSharingPolicy = applicationSharingPolicy;
     SshSettings           = sshSettings;
     ConnectivityEndpoints = connectivityEndpoints;
     Applications          = applications;
     CreatedBy             = createdBy;
     Errors = errors;
     State  = state;
     ComputeInstanceAuthorizationType = computeInstanceAuthorizationType;
     PersonalComputeInstanceSettings  = personalComputeInstanceSettings;
     SetupScriptsSettings             = setupScriptsSettings;
     LastOperation      = lastOperation;
     Schedules          = schedules;
     EnableNodePublicIP = enableNodePublicIP;
     Containers         = containers;
     DataDisks          = dataDisks;
     DataMounts         = dataMounts;
     Versions           = versions;
 }
Пример #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 <ErrorResponse> >              errors = default;
            Optional <ComputeInstanceState>             state             = default;
            Optional <ComputeInstanceAuthorizationType> computeInstanceAuthorizationType = default;
            Optional <PersonalComputeInstanceSettings>  personalComputeInstanceSettings  = default;
            Optional <SetupScripts> setupScripts = default;
            Optional <ComputeInstanceLastOperation> lastOperation = default;
            Optional <ComputeSchedules>             schedules     = default;
            Optional <bool> enableNodePublicIp = default;
            Optional <IReadOnlyList <ComputeInstanceContainer> > containers = default;
            Optional <IReadOnlyList <ComputeInstanceDataDisk> >  dataDisks  = default;
            Optional <IReadOnlyList <ComputeInstanceDataMount> > dataMounts = default;
            Optional <ComputeInstanceVersion> versions = 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 <ErrorResponse> array = new List <ErrorResponse>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(ErrorResponse.DeserializeErrorResponse(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("setupScripts"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    setupScripts = SetupScripts.DeserializeSetupScripts(property.Value);
                    continue;
                }
                if (property.NameEquals("lastOperation"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    lastOperation = ComputeInstanceLastOperation.DeserializeComputeInstanceLastOperation(property.Value);
                    continue;
                }
                if (property.NameEquals("schedules"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    schedules = ComputeSchedules.DeserializeComputeSchedules(property.Value);
                    continue;
                }
                if (property.NameEquals("enableNodePublicIp"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    enableNodePublicIp = property.Value.GetBoolean();
                    continue;
                }
                if (property.NameEquals("containers"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    List <ComputeInstanceContainer> array = new List <ComputeInstanceContainer>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(ComputeInstanceContainer.DeserializeComputeInstanceContainer(item));
                    }
                    containers = array;
                    continue;
                }
                if (property.NameEquals("dataDisks"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    List <ComputeInstanceDataDisk> array = new List <ComputeInstanceDataDisk>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(ComputeInstanceDataDisk.DeserializeComputeInstanceDataDisk(item));
                    }
                    dataDisks = array;
                    continue;
                }
                if (property.NameEquals("dataMounts"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    List <ComputeInstanceDataMount> array = new List <ComputeInstanceDataMount>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(ComputeInstanceDataMount.DeserializeComputeInstanceDataMount(item));
                    }
                    dataMounts = array;
                    continue;
                }
                if (property.NameEquals("versions"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    versions = ComputeInstanceVersion.DeserializeComputeInstanceVersion(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, setupScripts.Value, lastOperation.Value, schedules.Value, Optional.ToNullable(enableNodePublicIp), Optional.ToList(containers), Optional.ToList(dataDisks), Optional.ToList(dataMounts), versions.Value));
        }