Beispiel #1
0
        internal static ComputeSecrets DeserializeComputeSecrets(JsonElement element)
        {
            if (element.TryGetProperty("computeType", out JsonElement discriminator))
            {
                switch (discriminator.GetString())
                {
                case "AKS": return(AksComputeSecrets.DeserializeAksComputeSecrets(element));

                case "Databricks": return(DatabricksComputeSecrets.DeserializeDatabricksComputeSecrets(element));

                case "VirtualMachine": return(VirtualMachineSecrets.DeserializeVirtualMachineSecrets(element));
                }
            }
            ComputeType computeType = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("computeType"))
                {
                    computeType = new ComputeType(property.Value.GetString());
                    continue;
                }
            }
            return(new ComputeSecrets(computeType));
        }
Beispiel #2
0
        internal static AksComputeSecrets DeserializeAksComputeSecrets(JsonElement element)
        {
            Optional <string> userKubeConfig      = default;
            Optional <string> adminKubeConfig     = default;
            Optional <string> imagePullSecretName = default;
            ComputeType       computeType         = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("userKubeConfig"))
                {
                    userKubeConfig = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("adminKubeConfig"))
                {
                    adminKubeConfig = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("imagePullSecretName"))
                {
                    imagePullSecretName = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("computeType"))
                {
                    computeType = new ComputeType(property.Value.GetString());
                    continue;
                }
            }
            return(new AksComputeSecrets(computeType, userKubeConfig.Value, adminKubeConfig.Value, imagePullSecretName.Value));
        }
Beispiel #3
0
 void IUtf8JsonSerializable.Write(Utf8JsonWriter writer)
 {
     writer.WriteStartObject();
     if (Optional.IsDefined(Properties))
     {
         writer.WritePropertyName("properties");
         writer.WriteObjectValue(Properties);
     }
     writer.WritePropertyName("computeType");
     writer.WriteStringValue(ComputeType.ToString());
     if (Optional.IsDefined(Description))
     {
         writer.WritePropertyName("description");
         writer.WriteStringValue(Description);
     }
     if (Optional.IsDefined(ResourceId))
     {
         writer.WritePropertyName("resourceId");
         writer.WriteStringValue(ResourceId);
     }
     if (Optional.IsDefined(DisableLocalAuth))
     {
         writer.WritePropertyName("disableLocalAuth");
         writer.WriteBooleanValue(DisableLocalAuth.Value);
     }
     writer.WriteEndObject();
 }
Beispiel #4
0
        internal static VirtualMachineSecrets DeserializeVirtualMachineSecrets(JsonElement element)
        {
            Optional <VirtualMachineSshCredentials> administratorAccount = default;
            ComputeType computeType = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("administratorAccount"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    administratorAccount = VirtualMachineSshCredentials.DeserializeVirtualMachineSshCredentials(property.Value);
                    continue;
                }
                if (property.NameEquals("computeType"))
                {
                    computeType = new ComputeType(property.Value.GetString());
                    continue;
                }
            }
            return(new VirtualMachineSecrets(computeType, administratorAccount.Value));
        }
Beispiel #5
0
 internal Compute(ComputeType computeType, string computeLocation, ProvisioningState?provisioningState, string description, DateTimeOffset?createdOn, DateTimeOffset?modifiedOn, ResourceIdentifier resourceId, IReadOnlyList <ErrorResponse> provisioningErrors, bool?isAttachedCompute, bool?disableLocalAuth)
 {
     ComputeType        = computeType;
     ComputeLocation    = computeLocation;
     ProvisioningState  = provisioningState;
     Description        = description;
     CreatedOn          = createdOn;
     ModifiedOn         = modifiedOn;
     ResourceId         = resourceId;
     ProvisioningErrors = provisioningErrors;
     IsAttachedCompute  = isAttachedCompute;
     DisableLocalAuth   = disableLocalAuth;
 }
Beispiel #6
0
        internal static DatabricksComputeSecrets DeserializeDatabricksComputeSecrets(JsonElement element)
        {
            Optional <string> databricksAccessToken = default;
            ComputeType       computeType           = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("databricksAccessToken"))
                {
                    databricksAccessToken = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("computeType"))
                {
                    computeType = new ComputeType(property.Value.GetString());
                    continue;
                }
            }
            return(new DatabricksComputeSecrets(computeType, databricksAccessToken.Value));
        }
Beispiel #7
0
        internal static DatabricksCompute DeserializeDatabricksCompute(JsonElement element)
        {
            Optional <DatabricksProperties> 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 <ResourceIdentifier>             resourceId         = default;
            Optional <IReadOnlyList <ErrorResponse> > provisioningErrors = default;
            Optional <bool>                           isAttachedCompute  = default;
            Optional <bool>                           disableLocalAuth   = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("properties"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    properties = DatabricksProperties.DeserializeDatabricksProperties(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"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    resourceId = new ResourceIdentifier(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("provisioningErrors"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        provisioningErrors = null;
                        continue;
                    }
                    List <ErrorResponse> array = new List <ErrorResponse>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(ErrorResponse.DeserializeErrorResponse(item));
                    }
                    provisioningErrors = array;
                    continue;
                }
                if (property.NameEquals("isAttachedCompute"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    isAttachedCompute = property.Value.GetBoolean();
                    continue;
                }
                if (property.NameEquals("disableLocalAuth"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    disableLocalAuth = property.Value.GetBoolean();
                    continue;
                }
            }
            return(new DatabricksCompute(computeType, computeLocation.Value, Optional.ToNullable(provisioningState), description.Value, Optional.ToNullable(createdOn), Optional.ToNullable(modifiedOn), resourceId.Value, Optional.ToList(provisioningErrors), Optional.ToNullable(isAttachedCompute), Optional.ToNullable(disableLocalAuth), properties.Value));
        }
Beispiel #8
0
 internal AmlCompute(ComputeType computeType, string computeLocation, ProvisioningState?provisioningState, string description, DateTimeOffset?createdOn, DateTimeOffset?modifiedOn, ResourceIdentifier resourceId, IReadOnlyList <ErrorResponse> provisioningErrors, bool?isAttachedCompute, bool?disableLocalAuth, AmlComputeProperties properties) : base(computeType, computeLocation, provisioningState, description, createdOn, modifiedOn, resourceId, provisioningErrors, isAttachedCompute, disableLocalAuth)
 {
     Properties  = properties;
     ComputeType = computeType;
 }
Beispiel #9
0
        internal static Compute DeserializeCompute(JsonElement element)
        {
            if (element.TryGetProperty("computeType", out JsonElement discriminator))
            {
                switch (discriminator.GetString())
                {
                case "AKS": return(AksCompute.DeserializeAksCompute(element));

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

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

                case "DataFactory": return(DataFactoryCompute.DeserializeDataFactoryCompute(element));

                case "DataLakeAnalytics": return(DataLakeAnalyticsCompute.DeserializeDataLakeAnalyticsCompute(element));

                case "Databricks": return(DatabricksCompute.DeserializeDatabricksCompute(element));

                case "HDInsight": return(HDInsightCompute.DeserializeHDInsightCompute(element));

                case "Kubernetes": return(KubernetesCompute.DeserializeKubernetesCompute(element));

                case "SynapseSpark": return(SynapseSparkCompute.DeserializeSynapseSparkCompute(element));

                case "VirtualMachine": return(VirtualMachineCompute.DeserializeVirtualMachineCompute(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 <ResourceIdentifier>             resourceId         = default;
            Optional <IReadOnlyList <ErrorResponse> > provisioningErrors = default;
            Optional <bool>                           isAttachedCompute  = default;
            Optional <bool>                           disableLocalAuth   = 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"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    resourceId = new ResourceIdentifier(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("provisioningErrors"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        provisioningErrors = null;
                        continue;
                    }
                    List <ErrorResponse> array = new List <ErrorResponse>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(ErrorResponse.DeserializeErrorResponse(item));
                    }
                    provisioningErrors = array;
                    continue;
                }
                if (property.NameEquals("isAttachedCompute"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    isAttachedCompute = property.Value.GetBoolean();
                    continue;
                }
                if (property.NameEquals("disableLocalAuth"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    disableLocalAuth = 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), Optional.ToNullable(disableLocalAuth)));
        }