internal static DataCenterResourceProperties DeserializeDataCenterResourceProperties(JsonElement element)
        {
            Optional <ManagedCassandraProvisioningState> provisioningState = default;
            Optional <string> dataCenterLocation                 = default;
            Optional <string> delegatedSubnetId                  = default;
            Optional <int>    nodeCount                          = default;
            Optional <IReadOnlyList <SeedNode> > seedNodes       = default;
            Optional <string> base64EncodedCassandraYamlFragment = default;
            Optional <string> managedDiskCustomerKeyUri          = default;
            Optional <string> backupStorageCustomerKeyUri        = default;
            Optional <string> sku              = default;
            Optional <string> diskSku          = default;
            Optional <int>    diskCapacity     = default;
            Optional <bool>   availabilityZone = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("provisioningState"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    provisioningState = new ManagedCassandraProvisioningState(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("dataCenterLocation"))
                {
                    dataCenterLocation = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("delegatedSubnetId"))
                {
                    delegatedSubnetId = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("nodeCount"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    nodeCount = property.Value.GetInt32();
                    continue;
                }
                if (property.NameEquals("seedNodes"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    List <SeedNode> array = new List <SeedNode>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(SeedNode.DeserializeSeedNode(item));
                    }
                    seedNodes = array;
                    continue;
                }
                if (property.NameEquals("base64EncodedCassandraYamlFragment"))
                {
                    base64EncodedCassandraYamlFragment = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("managedDiskCustomerKeyUri"))
                {
                    managedDiskCustomerKeyUri = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("backupStorageCustomerKeyUri"))
                {
                    backupStorageCustomerKeyUri = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("sku"))
                {
                    sku = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("diskSku"))
                {
                    diskSku = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("diskCapacity"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    diskCapacity = property.Value.GetInt32();
                    continue;
                }
                if (property.NameEquals("availabilityZone"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    availabilityZone = property.Value.GetBoolean();
                    continue;
                }
            }
            return(new DataCenterResourceProperties(Optional.ToNullable(provisioningState), dataCenterLocation.Value, delegatedSubnetId.Value, Optional.ToNullable(nodeCount), Optional.ToList(seedNodes), base64EncodedCassandraYamlFragment.Value, managedDiskCustomerKeyUri.Value, backupStorageCustomerKeyUri.Value, sku.Value, diskSku.Value, Optional.ToNullable(diskCapacity), Optional.ToNullable(availabilityZone)));
        }
Exemplo n.º 2
0
        internal static ClusterResourceProperties DeserializeClusterResourceProperties(JsonElement element)
        {
            Optional <ManagedCassandraProvisioningState> provisioningState = default;
            Optional <string> restoreFromBackupId                = default;
            Optional <string> delegatedManagementSubnetId        = default;
            Optional <string> cassandraVersion                   = default;
            Optional <string> clusterNameOverride                = default;
            Optional <AuthenticationMethod> authenticationMethod = default;
            Optional <string>                       initialCassandraAdminPassword = default;
            Optional <SeedNode>                     prometheusEndpoint            = default;
            Optional <bool>                         repairEnabled              = default;
            Optional <IList <Certificate> >         clientCertificates         = default;
            Optional <IList <Certificate> >         externalGossipCertificates = default;
            Optional <IReadOnlyList <Certificate> > gossipCertificates         = default;
            Optional <IList <SeedNode> >            externalSeedNodes          = default;
            Optional <IReadOnlyList <SeedNode> >    seedNodes = default;
            Optional <int>  hoursBetweenBackups          = default;
            Optional <bool> deallocated                  = default;
            Optional <bool> cassandraAuditLoggingEnabled = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("provisioningState"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    provisioningState = new ManagedCassandraProvisioningState(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("restoreFromBackupId"))
                {
                    restoreFromBackupId = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("delegatedManagementSubnetId"))
                {
                    delegatedManagementSubnetId = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("cassandraVersion"))
                {
                    cassandraVersion = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("clusterNameOverride"))
                {
                    clusterNameOverride = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("authenticationMethod"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    authenticationMethod = new AuthenticationMethod(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("initialCassandraAdminPassword"))
                {
                    initialCassandraAdminPassword = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("prometheusEndpoint"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    prometheusEndpoint = SeedNode.DeserializeSeedNode(property.Value);
                    continue;
                }
                if (property.NameEquals("repairEnabled"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    repairEnabled = property.Value.GetBoolean();
                    continue;
                }
                if (property.NameEquals("clientCertificates"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    List <Certificate> array = new List <Certificate>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(Certificate.DeserializeCertificate(item));
                    }
                    clientCertificates = array;
                    continue;
                }
                if (property.NameEquals("externalGossipCertificates"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    List <Certificate> array = new List <Certificate>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(Certificate.DeserializeCertificate(item));
                    }
                    externalGossipCertificates = array;
                    continue;
                }
                if (property.NameEquals("gossipCertificates"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    List <Certificate> array = new List <Certificate>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(Certificate.DeserializeCertificate(item));
                    }
                    gossipCertificates = array;
                    continue;
                }
                if (property.NameEquals("externalSeedNodes"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    List <SeedNode> array = new List <SeedNode>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(SeedNode.DeserializeSeedNode(item));
                    }
                    externalSeedNodes = array;
                    continue;
                }
                if (property.NameEquals("seedNodes"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    List <SeedNode> array = new List <SeedNode>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(SeedNode.DeserializeSeedNode(item));
                    }
                    seedNodes = array;
                    continue;
                }
                if (property.NameEquals("hoursBetweenBackups"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    hoursBetweenBackups = property.Value.GetInt32();
                    continue;
                }
                if (property.NameEquals("deallocated"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    deallocated = property.Value.GetBoolean();
                    continue;
                }
                if (property.NameEquals("cassandraAuditLoggingEnabled"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    cassandraAuditLoggingEnabled = property.Value.GetBoolean();
                    continue;
                }
            }
            return(new ClusterResourceProperties(Optional.ToNullable(provisioningState), restoreFromBackupId.Value, delegatedManagementSubnetId.Value, cassandraVersion.Value, clusterNameOverride.Value, Optional.ToNullable(authenticationMethod), initialCassandraAdminPassword.Value, prometheusEndpoint.Value, Optional.ToNullable(repairEnabled), Optional.ToList(clientCertificates), Optional.ToList(externalGossipCertificates), Optional.ToList(gossipCertificates), Optional.ToList(externalSeedNodes), Optional.ToList(seedNodes), Optional.ToNullable(hoursBetweenBackups), Optional.ToNullable(deallocated), Optional.ToNullable(cassandraAuditLoggingEnabled)));
        }