internal ManagedHsmProperties(Guid?tenantId, IList <string> initialAdminObjectIds, Uri hsmUri, bool?enableSoftDelete, int?softDeleteRetentionInDays, bool?enablePurgeProtection, CreateMode?createMode, string statusMessage, HsmProvisioningState?provisioningState, ManagedHsmNetworkRuleSet networkRuleSet, IReadOnlyList <ManagedHsmPrivateEndpointConnectionItem> privateEndpointConnections, PublicNetworkAccess?publicNetworkAccess, DateTimeOffset?scheduledPurgeOn) { TenantId = tenantId; InitialAdminObjectIds = initialAdminObjectIds; HsmUri = hsmUri; EnableSoftDelete = enableSoftDelete; SoftDeleteRetentionInDays = softDeleteRetentionInDays; EnablePurgeProtection = enablePurgeProtection; CreateMode = createMode; StatusMessage = statusMessage; ProvisioningState = provisioningState; NetworkRuleSet = networkRuleSet; PrivateEndpointConnections = privateEndpointConnections; PublicNetworkAccess = publicNetworkAccess; ScheduledPurgeOn = scheduledPurgeOn; }
internal static ManagedHsmProperties DeserializeManagedHsmProperties(JsonElement element) { Optional <Guid> tenantId = default; Optional <IList <string> > initialAdminObjectIds = default; Optional <Uri> hsmUri = default; Optional <bool> enableSoftDelete = default; Optional <int> softDeleteRetentionInDays = default; Optional <bool> enablePurgeProtection = default; Optional <CreateMode> createMode = default; Optional <string> statusMessage = default; Optional <HsmProvisioningState> provisioningState = default; Optional <ManagedHsmNetworkRuleSet> networkAcls = default; Optional <IReadOnlyList <ManagedHsmPrivateEndpointConnectionItem> > privateEndpointConnections = default; Optional <PublicNetworkAccess> publicNetworkAccess = default; Optional <DateTimeOffset> scheduledPurgeDate = default; foreach (var property in element.EnumerateObject()) { if (property.NameEquals("tenantId")) { if (property.Value.ValueKind == JsonValueKind.Null) { property.ThrowNonNullablePropertyIsNull(); continue; } tenantId = property.Value.GetGuid(); continue; } if (property.NameEquals("initialAdminObjectIds")) { if (property.Value.ValueKind == JsonValueKind.Null) { property.ThrowNonNullablePropertyIsNull(); continue; } List <string> array = new List <string>(); foreach (var item in property.Value.EnumerateArray()) { array.Add(item.GetString()); } initialAdminObjectIds = array; continue; } if (property.NameEquals("hsmUri")) { if (property.Value.ValueKind == JsonValueKind.Null) { hsmUri = null; continue; } hsmUri = new Uri(property.Value.GetString()); 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("enablePurgeProtection")) { if (property.Value.ValueKind == JsonValueKind.Null) { property.ThrowNonNullablePropertyIsNull(); continue; } enablePurgeProtection = 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("statusMessage")) { statusMessage = property.Value.GetString(); continue; } if (property.NameEquals("provisioningState")) { if (property.Value.ValueKind == JsonValueKind.Null) { property.ThrowNonNullablePropertyIsNull(); continue; } provisioningState = new HsmProvisioningState(property.Value.GetString()); continue; } if (property.NameEquals("networkAcls")) { if (property.Value.ValueKind == JsonValueKind.Null) { property.ThrowNonNullablePropertyIsNull(); continue; } networkAcls = ManagedHsmNetworkRuleSet.DeserializeManagedHsmNetworkRuleSet(property.Value); continue; } if (property.NameEquals("privateEndpointConnections")) { if (property.Value.ValueKind == JsonValueKind.Null) { property.ThrowNonNullablePropertyIsNull(); continue; } List <ManagedHsmPrivateEndpointConnectionItem> array = new List <ManagedHsmPrivateEndpointConnectionItem>(); foreach (var item in property.Value.EnumerateArray()) { array.Add(ManagedHsmPrivateEndpointConnectionItem.DeserializeManagedHsmPrivateEndpointConnectionItem(item)); } privateEndpointConnections = array; continue; } if (property.NameEquals("publicNetworkAccess")) { if (property.Value.ValueKind == JsonValueKind.Null) { property.ThrowNonNullablePropertyIsNull(); continue; } publicNetworkAccess = new PublicNetworkAccess(property.Value.GetString()); continue; } if (property.NameEquals("scheduledPurgeDate")) { if (property.Value.ValueKind == JsonValueKind.Null) { property.ThrowNonNullablePropertyIsNull(); continue; } scheduledPurgeDate = property.Value.GetDateTimeOffset("O"); continue; } } return(new ManagedHsmProperties(Optional.ToNullable(tenantId), Optional.ToList(initialAdminObjectIds), hsmUri.Value, Optional.ToNullable(enableSoftDelete), Optional.ToNullable(softDeleteRetentionInDays), Optional.ToNullable(enablePurgeProtection), Optional.ToNullable(createMode), statusMessage.Value, Optional.ToNullable(provisioningState), networkAcls.Value, Optional.ToList(privateEndpointConnections), Optional.ToNullable(publicNetworkAccess), Optional.ToNullable(scheduledPurgeDate))); }