public VaultProperties(Guid tenantId, KeyVaultSku sku) { if (sku == null) { throw new ArgumentNullException(nameof(sku)); } TenantId = tenantId; Sku = sku; AccessPolicies = new ChangeTrackingList <AccessPolicyEntry>(); PrivateEndpointConnections = new ChangeTrackingList <PrivateEndpointConnectionItem>(); }
public VaultProperties(Guid tenantId, KeyVaultSku sku) { if (sku == null) { throw new ArgumentNullException(nameof(sku)); } TenantId = tenantId; Sku = sku; // This is a workaround to ensure the vault can be created successfully // See the details of the issue here: https://github.com/Azure/azure-rest-api-specs/issues/19022 AccessPolicies = new List <VaultAccessPolicy>(); PrivateEndpointConnections = new ChangeTrackingList <PrivateEndpointConnectionItemData>(); }
internal VaultProperties(Guid tenantId, KeyVaultSku sku, IList <AccessPolicyEntry> accessPolicies, Uri vaultUri, string hsmPoolResourceId, bool?enabledForDeployment, bool?enabledForDiskEncryption, bool?enabledForTemplateDeployment, bool?enableSoftDelete, int?softDeleteRetentionInDays, bool?enableRbacAuthorization, VaultCreateMode?createMode, bool?enablePurgeProtection, NetworkRuleSet networkAcls, VaultProvisioningState?provisioningState, IReadOnlyList <PrivateEndpointConnectionItem> privateEndpointConnections, string publicNetworkAccess) { TenantId = tenantId; Sku = sku; AccessPolicies = accessPolicies; VaultUri = vaultUri; HsmPoolResourceId = hsmPoolResourceId; EnabledForDeployment = enabledForDeployment; EnabledForDiskEncryption = enabledForDiskEncryption; EnabledForTemplateDeployment = enabledForTemplateDeployment; EnableSoftDelete = enableSoftDelete; SoftDeleteRetentionInDays = softDeleteRetentionInDays; EnableRbacAuthorization = enableRbacAuthorization; CreateMode = createMode; EnablePurgeProtection = enablePurgeProtection; NetworkAcls = networkAcls; ProvisioningState = provisioningState; PrivateEndpointConnections = privateEndpointConnections; PublicNetworkAccess = publicNetworkAccess; }
internal static VaultProperties DeserializeVaultProperties(JsonElement element) { Guid tenantId = default; KeyVaultSku sku = default; Optional <IList <AccessPolicyEntry> > accessPolicies = default; Optional <Uri> vaultUri = default; Optional <string> hsmPoolResourceId = default; Optional <bool> enabledForDeployment = default; Optional <bool> enabledForDiskEncryption = default; Optional <bool> enabledForTemplateDeployment = default; Optional <bool> enableSoftDelete = default; Optional <int> softDeleteRetentionInDays = default; Optional <bool> enableRbacAuthorization = default; Optional <CreateMode> createMode = default; Optional <bool> enablePurgeProtection = default; Optional <NetworkRuleSet> networkAcls = default; Optional <VaultProvisioningState> provisioningState = default; Optional <IReadOnlyList <PrivateEndpointConnectionItem> > privateEndpointConnections = default; Optional <string> publicNetworkAccess = default; foreach (var property in element.EnumerateObject()) { if (property.NameEquals("tenantId")) { tenantId = property.Value.GetGuid(); continue; } if (property.NameEquals("sku")) { sku = KeyVaultSku.DeserializeKeyVaultSku(property.Value); continue; } if (property.NameEquals("accessPolicies")) { if (property.Value.ValueKind == JsonValueKind.Null) { property.ThrowNonNullablePropertyIsNull(); continue; } List <AccessPolicyEntry> array = new List <AccessPolicyEntry>(); foreach (var item in property.Value.EnumerateArray()) { array.Add(AccessPolicyEntry.DeserializeAccessPolicyEntry(item)); } accessPolicies = array; continue; } if (property.NameEquals("vaultUri")) { if (property.Value.ValueKind == JsonValueKind.Null) { property.ThrowNonNullablePropertyIsNull(); continue; } vaultUri = new Uri(property.Value.GetString()); continue; } if (property.NameEquals("hsmPoolResourceId")) { hsmPoolResourceId = property.Value.GetString(); continue; } if (property.NameEquals("enabledForDeployment")) { if (property.Value.ValueKind == JsonValueKind.Null) { property.ThrowNonNullablePropertyIsNull(); continue; } enabledForDeployment = property.Value.GetBoolean(); continue; } if (property.NameEquals("enabledForDiskEncryption")) { if (property.Value.ValueKind == JsonValueKind.Null) { property.ThrowNonNullablePropertyIsNull(); continue; } enabledForDiskEncryption = property.Value.GetBoolean(); continue; } if (property.NameEquals("enabledForTemplateDeployment")) { if (property.Value.ValueKind == JsonValueKind.Null) { property.ThrowNonNullablePropertyIsNull(); continue; } enabledForTemplateDeployment = property.Value.GetBoolean(); continue; } if (property.NameEquals("enableSoftDelete")) { if (property.Value.ValueKind == JsonValueKind.Null) { property.ThrowNonNullablePropertyIsNull(); continue; } enableSoftDelete = property.Value.GetBoolean(); continue; } if (property.NameEquals("softDeleteRetentionInDays")) { if (property.Value.ValueKind == JsonValueKind.Null) { property.ThrowNonNullablePropertyIsNull(); continue; } softDeleteRetentionInDays = property.Value.GetInt32(); continue; } if (property.NameEquals("enableRbacAuthorization")) { if (property.Value.ValueKind == JsonValueKind.Null) { property.ThrowNonNullablePropertyIsNull(); continue; } enableRbacAuthorization = property.Value.GetBoolean(); continue; } if (property.NameEquals("createMode")) { if (property.Value.ValueKind == JsonValueKind.Null) { property.ThrowNonNullablePropertyIsNull(); continue; } createMode = property.Value.GetString().ToCreateMode(); continue; } if (property.NameEquals("enablePurgeProtection")) { if (property.Value.ValueKind == JsonValueKind.Null) { property.ThrowNonNullablePropertyIsNull(); continue; } enablePurgeProtection = property.Value.GetBoolean(); continue; } if (property.NameEquals("networkAcls")) { if (property.Value.ValueKind == JsonValueKind.Null) { property.ThrowNonNullablePropertyIsNull(); continue; } networkAcls = NetworkRuleSet.DeserializeNetworkRuleSet(property.Value); continue; } if (property.NameEquals("provisioningState")) { if (property.Value.ValueKind == JsonValueKind.Null) { property.ThrowNonNullablePropertyIsNull(); continue; } provisioningState = new VaultProvisioningState(property.Value.GetString()); continue; } if (property.NameEquals("privateEndpointConnections")) { if (property.Value.ValueKind == JsonValueKind.Null) { property.ThrowNonNullablePropertyIsNull(); continue; } List <PrivateEndpointConnectionItem> array = new List <PrivateEndpointConnectionItem>(); foreach (var item in property.Value.EnumerateArray()) { array.Add(PrivateEndpointConnectionItem.DeserializePrivateEndpointConnectionItem(item)); } privateEndpointConnections = array; continue; } if (property.NameEquals("publicNetworkAccess")) { publicNetworkAccess = property.Value.GetString(); continue; } } return(new VaultProperties(tenantId, sku, Optional.ToList(accessPolicies), vaultUri.Value, hsmPoolResourceId.Value, Optional.ToNullable(enabledForDeployment), Optional.ToNullable(enabledForDiskEncryption), Optional.ToNullable(enabledForTemplateDeployment), Optional.ToNullable(enableSoftDelete), Optional.ToNullable(softDeleteRetentionInDays), Optional.ToNullable(enableRbacAuthorization), Optional.ToNullable(createMode), Optional.ToNullable(enablePurgeProtection), networkAcls.Value, Optional.ToNullable(provisioningState), Optional.ToList(privateEndpointConnections), publicNetworkAccess.Value)); }