예제 #1
0
        internal static DataLakeAnalytics DeserializeDataLakeAnalytics(JsonElement element)
        {
            Optional <DataLakeAnalyticsProperties> properties = default;
            ComputeType                  computeType          = default;
            Optional <string>            computeLocation      = default;
            Optional <ProvisioningState> provisioningState    = default;
            Optional <string>            description          = default;
            Optional <DateTimeOffset>    createdOn            = default;
            Optional <DateTimeOffset>    modifiedOn           = default;
            Optional <string>            resourceId           = default;
            Optional <IReadOnlyList <MachineLearningServiceError> > provisioningErrors = default;
            Optional <bool> isAttachedCompute = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("properties"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    properties = DataLakeAnalyticsProperties.DeserializeDataLakeAnalyticsProperties(property.Value);
                    continue;
                }
                if (property.NameEquals("computeType"))
                {
                    computeType = new ComputeType(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("computeLocation"))
                {
                    computeLocation = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("provisioningState"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    provisioningState = new ProvisioningState(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("description"))
                {
                    description = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("createdOn"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    createdOn = property.Value.GetDateTimeOffset("O");
                    continue;
                }
                if (property.NameEquals("modifiedOn"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    modifiedOn = property.Value.GetDateTimeOffset("O");
                    continue;
                }
                if (property.NameEquals("resourceId"))
                {
                    resourceId = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("provisioningErrors"))
                {
                    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));
                    }
                    provisioningErrors = array;
                    continue;
                }
                if (property.NameEquals("isAttachedCompute"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    isAttachedCompute = property.Value.GetBoolean();
                    continue;
                }
            }
            return(new DataLakeAnalytics(computeType, computeLocation.Value, Optional.ToNullable(provisioningState), description.Value, Optional.ToNullable(createdOn), Optional.ToNullable(modifiedOn), resourceId.Value, Optional.ToList(provisioningErrors), Optional.ToNullable(isAttachedCompute), properties.Value));
        }
예제 #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));
        }
        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)));
        }
예제 #4
0
        internal static Compute DeserializeCompute(JsonElement element)
        {
            if (element.TryGetProperty("computeType", out JsonElement discriminator))
            {
                switch (discriminator.GetString())
                {
                case "AKS": return(AKS.DeserializeAKS(element));

                case "AmlCompute": return(AmlCompute.DeserializeAmlCompute(element));

                case "ComputeInstance": return(ComputeInstance.DeserializeComputeInstance(element));

                case "DataFactory": return(DataFactory.DeserializeDataFactory(element));

                case "DataLakeAnalytics": return(DataLakeAnalytics.DeserializeDataLakeAnalytics(element));

                case "Databricks": return(Databricks.DeserializeDatabricks(element));

                case "HDInsight": return(HDInsight.DeserializeHDInsight(element));

                case "VirtualMachine": return(VirtualMachine.DeserializeVirtualMachine(element));
                }
            }
            ComputeType                  computeType       = default;
            Optional <string>            computeLocation   = default;
            Optional <ProvisioningState> provisioningState = default;
            Optional <string>            description       = default;
            Optional <DateTimeOffset>    createdOn         = default;
            Optional <DateTimeOffset>    modifiedOn        = default;
            Optional <string>            resourceId        = default;
            Optional <IReadOnlyList <MachineLearningServiceError> > provisioningErrors = default;
            Optional <bool> isAttachedCompute = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("computeType"))
                {
                    computeType = new ComputeType(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("computeLocation"))
                {
                    computeLocation = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("provisioningState"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    provisioningState = new ProvisioningState(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("description"))
                {
                    description = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("createdOn"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    createdOn = property.Value.GetDateTimeOffset("O");
                    continue;
                }
                if (property.NameEquals("modifiedOn"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    modifiedOn = property.Value.GetDateTimeOffset("O");
                    continue;
                }
                if (property.NameEquals("resourceId"))
                {
                    resourceId = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("provisioningErrors"))
                {
                    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));
                    }
                    provisioningErrors = array;
                    continue;
                }
                if (property.NameEquals("isAttachedCompute"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    isAttachedCompute = property.Value.GetBoolean();
                    continue;
                }
            }
            return(new Compute(computeType, computeLocation.Value, Optional.ToNullable(provisioningState), description.Value, Optional.ToNullable(createdOn), Optional.ToNullable(modifiedOn), resourceId.Value, Optional.ToList(provisioningErrors), Optional.ToNullable(isAttachedCompute)));
        }