diff --git a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/CHANGELOG.md b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/CHANGELOG.md index 08340931cae8..2d732e854303 100644 --- a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/CHANGELOG.md +++ b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/CHANGELOG.md @@ -1,5 +1,130 @@ # Release History +## 3.0.0b1 (2026-02-13) + +### Features Added + + - Client `PostgreSQLManagementClient` added method `send_request` + - Model `AdvancedThreatProtectionSettingsModel` added property `properties` + - Model `BackupsLongTermRetentionOperation` added property `properties` + - Model `MigrationResourceForPatch` added property `properties` + - Enum `RecommendationTypeEnum` added member `VACUUM_TABLE` + - Enum `RecommendationTypeParameterEnum` added member `VACUUM_TABLE` + - Model `ServerForPatch` added property `properties` + - Model `VirtualEndpoint` added property `properties` + - Added model `AdministratorMicrosoftEntraPropertiesForAdd` + - Added model `AdvancedThreatProtectionSettingsProperties` + - Added model `BackupsLongTermRetentionResponseProperties` + - Added model `LogSpecification` + - Added model `LtrBackupOperationResponseProperties` + - Added model `MetricSpecification` + - Added model `MigrateNetworkStatus` + - Added model `MigrationPropertiesForPatch` + - Added enum `NetworkMigrationState` + - Added model `OperationProperties` + - Added enum `PostgreSqlFlexibleServerHighAvailabilityMode` + - Added model `ServerPropertiesForPatch` + - Added model `ServiceSpecification` + - Added model `VirtualEndpointResourceProperties` + - Model `ServersOperations` added method `begin_migrate_network_mode` + +### Breaking Changes + + - Model `AdministratorMicrosoftEntraAdd` deleted or renamed its instance variable `principal_type` + - Model `AdministratorMicrosoftEntraAdd` deleted or renamed its instance variable `principal_name` + - Model `AdministratorMicrosoftEntraAdd` deleted or renamed its instance variable `tenant_id` + - Model `AdvancedThreatProtectionSettingsModel` deleted or renamed its instance variable `state` + - Model `AdvancedThreatProtectionSettingsModel` deleted or renamed its instance variable `creation_time` + - Model `BackupsLongTermRetentionOperation` deleted or renamed its instance variable `datasource_size_in_bytes` + - Model `BackupsLongTermRetentionOperation` deleted or renamed its instance variable `data_transferred_in_bytes` + - Model `BackupsLongTermRetentionOperation` deleted or renamed its instance variable `backup_name` + - Model `BackupsLongTermRetentionOperation` deleted or renamed its instance variable `backup_metadata` + - Model `BackupsLongTermRetentionOperation` deleted or renamed its instance variable `status` + - Model `BackupsLongTermRetentionOperation` deleted or renamed its instance variable `start_time` + - Model `BackupsLongTermRetentionOperation` deleted or renamed its instance variable `end_time` + - Model `BackupsLongTermRetentionOperation` deleted or renamed its instance variable `percent_complete` + - Model `BackupsLongTermRetentionOperation` deleted or renamed its instance variable `error_code` + - Model `BackupsLongTermRetentionOperation` deleted or renamed its instance variable `error_message` + - Model `BackupsLongTermRetentionResponse` deleted or renamed its instance variable `datasource_size_in_bytes` + - Model `BackupsLongTermRetentionResponse` deleted or renamed its instance variable `data_transferred_in_bytes` + - Model `BackupsLongTermRetentionResponse` deleted or renamed its instance variable `backup_name` + - Model `BackupsLongTermRetentionResponse` deleted or renamed its instance variable `backup_metadata` + - Model `BackupsLongTermRetentionResponse` deleted or renamed its instance variable `status` + - Model `BackupsLongTermRetentionResponse` deleted or renamed its instance variable `start_time` + - Model `BackupsLongTermRetentionResponse` deleted or renamed its instance variable `end_time` + - Model `BackupsLongTermRetentionResponse` deleted or renamed its instance variable `percent_complete` + - Model `BackupsLongTermRetentionResponse` deleted or renamed its instance variable `error_code` + - Model `BackupsLongTermRetentionResponse` deleted or renamed its instance variable `error_message` + - Model `ConfigurationForUpdate` deleted or renamed its instance variable `value` + - Model `ConfigurationForUpdate` deleted or renamed its instance variable `description` + - Model `ConfigurationForUpdate` deleted or renamed its instance variable `default_value` + - Model `ConfigurationForUpdate` deleted or renamed its instance variable `data_type` + - Model `ConfigurationForUpdate` deleted or renamed its instance variable `allowed_values` + - Model `ConfigurationForUpdate` deleted or renamed its instance variable `source` + - Model `ConfigurationForUpdate` deleted or renamed its instance variable `is_dynamic_config` + - Model `ConfigurationForUpdate` deleted or renamed its instance variable `is_read_only` + - Model `ConfigurationForUpdate` deleted or renamed its instance variable `is_config_pending_restart` + - Model `ConfigurationForUpdate` deleted or renamed its instance variable `unit` + - Model `ConfigurationForUpdate` deleted or renamed its instance variable `documentation_link` + - Model `LtrPreBackupResponse` deleted or renamed its instance variable `number_of_containers` + - Model `MigrationResourceForPatch` deleted or renamed its instance variable `source_db_server_resource_id` + - Model `MigrationResourceForPatch` deleted or renamed its instance variable `source_db_server_fully_qualified_domain_name` + - Model `MigrationResourceForPatch` deleted or renamed its instance variable `target_db_server_fully_qualified_domain_name` + - Model `MigrationResourceForPatch` deleted or renamed its instance variable `secret_parameters` + - Model `MigrationResourceForPatch` deleted or renamed its instance variable `dbs_to_migrate` + - Model `MigrationResourceForPatch` deleted or renamed its instance variable `setup_logical_replication_on_source_db_if_needed` + - Model `MigrationResourceForPatch` deleted or renamed its instance variable `overwrite_dbs_in_target` + - Model `MigrationResourceForPatch` deleted or renamed its instance variable `migration_window_start_time_in_utc` + - Model `MigrationResourceForPatch` deleted or renamed its instance variable `migrate_roles` + - Model `MigrationResourceForPatch` deleted or renamed its instance variable `start_data_migration` + - Model `MigrationResourceForPatch` deleted or renamed its instance variable `trigger_cutover` + - Model `MigrationResourceForPatch` deleted or renamed its instance variable `dbs_to_trigger_cutover_on` + - Model `MigrationResourceForPatch` deleted or renamed its instance variable `cancel` + - Model `MigrationResourceForPatch` deleted or renamed its instance variable `dbs_to_cancel_migration_on` + - Model `MigrationResourceForPatch` deleted or renamed its instance variable `migration_mode` + - Model `ServerForPatch` deleted or renamed its instance variable `administrator_login` + - Model `ServerForPatch` deleted or renamed its instance variable `administrator_login_password` + - Model `ServerForPatch` deleted or renamed its instance variable `version` + - Model `ServerForPatch` deleted or renamed its instance variable `storage` + - Model `ServerForPatch` deleted or renamed its instance variable `backup` + - Model `ServerForPatch` deleted or renamed its instance variable `high_availability` + - Model `ServerForPatch` deleted or renamed its instance variable `maintenance_window` + - Model `ServerForPatch` deleted or renamed its instance variable `auth_config` + - Model `ServerForPatch` deleted or renamed its instance variable `data_encryption` + - Model `ServerForPatch` deleted or renamed its instance variable `availability_zone` + - Model `ServerForPatch` deleted or renamed its instance variable `create_mode` + - Model `ServerForPatch` deleted or renamed its instance variable `replication_role` + - Model `ServerForPatch` deleted or renamed its instance variable `replica` + - Model `ServerForPatch` deleted or renamed its instance variable `network` + - Model `ServerForPatch` deleted or renamed its instance variable `cluster` + - Model `VirtualEndpoint` deleted or renamed its instance variable `endpoint_type` + - Model `VirtualEndpoint` deleted or renamed its instance variable `members` + - Model `VirtualEndpoint` deleted or renamed its instance variable `virtual_endpoints` + - Model `VirtualEndpointResourceForPatch` deleted or renamed its instance variable `endpoint_type` + - Model `VirtualEndpointResourceForPatch` deleted or renamed its instance variable `members` + - Model `VirtualEndpointResourceForPatch` deleted or renamed its instance variable `virtual_endpoints` + - Deleted or renamed model `AdministratorMicrosoftEntraList` + - Deleted or renamed model `AdvancedThreatProtectionSettingsList` + - Deleted or renamed model `BackupAutomaticAndOnDemandList` + - Deleted or renamed model `CapabilityList` + - Deleted or renamed model `CapturedLogList` + - Deleted or renamed model `ConfigurationList` + - Deleted or renamed model `DatabaseList` + - Deleted or renamed model `FirewallRuleList` + - Deleted or renamed model `LtrServerBackupOperationList` + - Deleted or renamed model `MigrationDetailsLevel` + - Deleted or renamed model `MigrationList` + - Deleted or renamed model `ObjectRecommendationList` + - Deleted or renamed model `OperationList` + - Deleted or renamed model `PrivateEndpointConnectionList` + - Deleted or renamed model `PrivateLinkResourceList` + - Deleted or renamed model `QuotaUsageList` + - Deleted or renamed model `ServerList` + - Deleted or renamed model `TuningOptionsList` + - Deleted or renamed model `VirtualEndpointsList` + - Method `MigrationsOperations.list_by_target_server` changed its parameter `migration_list_filter` from `positional_or_keyword` to `keyword_only` + - Method `TuningOptionsOperations.list_recommendations` changed its parameter `recommendation_type` from `positional_or_keyword` to `keyword_only` + ## 2.0.0 (2025-11-17) ### Features Added diff --git a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/_metadata.json b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/_metadata.json index 3644214fbc16..1d6a83dc04a7 100644 --- a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/_metadata.json +++ b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/_metadata.json @@ -1,11 +1,10 @@ { - "commit": "b61ac84b569118b89c1ebce6bdb94600c58e1066", + "apiVersion": "2026-01-01-preview", + "apiVersions": { + "Microsoft.DBforPostgreSQL": "2026-01-01-preview" + }, + "commit": "3afef36df83f47abac337e0cbd850e3d1c00dc8e", "repository_url": "https://github.com/Azure/azure-rest-api-specs", - "autorest": "3.10.2", - "use": [ - "@autorest/python@6.42.0", - "@autorest/modelerfour@4.27.0" - ], - "autorest_command": "autorest specification/postgresql/resource-manager/readme.md --generate-sample=True --include-x-ms-examples-original-file=True --package-mode=azure-mgmt --python --python-sdks-folder=/mnt/vss/_work/1/azure-sdk-for-python/sdk --use=@autorest/python@6.42.0 --use=@autorest/modelerfour@4.27.0 --version=3.10.2 --version-tolerant=False", - "readme": "specification/postgresql/resource-manager/readme.md" + "typespec_src": "specification/postgresql/DBforPostgreSQL.Management", + "emitterVersion": "0.60.1" } \ No newline at end of file diff --git a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/apiview-properties.json b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/apiview-properties.json index 058449d953f9..a55989c115f6 100644 --- a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/apiview-properties.json +++ b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/apiview-properties.json @@ -1,310 +1,319 @@ { - "CrossLanguagePackageId": null, + "CrossLanguagePackageId": "Microsoft.DBforPostgreSQL", "CrossLanguageDefinitionId": { - "azure.mgmt.postgresqlflexibleservers.models.AdminCredentials": null, - "azure.mgmt.postgresqlflexibleservers.models.AdminCredentialsForPatch": null, - "azure.mgmt.postgresqlflexibleservers.models.Resource": null, - "azure.mgmt.postgresqlflexibleservers.models.ProxyResource": null, - "azure.mgmt.postgresqlflexibleservers.models.AdministratorMicrosoftEntra": null, - "azure.mgmt.postgresqlflexibleservers.models.AdministratorMicrosoftEntraAdd": null, - "azure.mgmt.postgresqlflexibleservers.models.AdministratorMicrosoftEntraList": null, - "azure.mgmt.postgresqlflexibleservers.models.AdvancedThreatProtectionSettingsList": null, - "azure.mgmt.postgresqlflexibleservers.models.AdvancedThreatProtectionSettingsModel": null, - "azure.mgmt.postgresqlflexibleservers.models.AuthConfig": null, - "azure.mgmt.postgresqlflexibleservers.models.AuthConfigForPatch": null, - "azure.mgmt.postgresqlflexibleservers.models.Backup": null, - "azure.mgmt.postgresqlflexibleservers.models.BackupAutomaticAndOnDemand": null, - "azure.mgmt.postgresqlflexibleservers.models.BackupAutomaticAndOnDemandList": null, - "azure.mgmt.postgresqlflexibleservers.models.BackupForPatch": null, - "azure.mgmt.postgresqlflexibleservers.models.BackupRequestBase": null, - "azure.mgmt.postgresqlflexibleservers.models.BackupSettings": null, - "azure.mgmt.postgresqlflexibleservers.models.BackupsLongTermRetentionOperation": null, - "azure.mgmt.postgresqlflexibleservers.models.BackupsLongTermRetentionRequest": null, - "azure.mgmt.postgresqlflexibleservers.models.BackupsLongTermRetentionResponse": null, - "azure.mgmt.postgresqlflexibleservers.models.BackupStoreDetails": null, - "azure.mgmt.postgresqlflexibleservers.models.CapabilityBase": null, - "azure.mgmt.postgresqlflexibleservers.models.Capability": null, - "azure.mgmt.postgresqlflexibleservers.models.CapabilityList": null, - "azure.mgmt.postgresqlflexibleservers.models.CapturedLog": null, - "azure.mgmt.postgresqlflexibleservers.models.CapturedLogList": null, - "azure.mgmt.postgresqlflexibleservers.models.CheckNameAvailabilityRequest": null, - "azure.mgmt.postgresqlflexibleservers.models.CheckNameAvailabilityResponse": null, - "azure.mgmt.postgresqlflexibleservers.models.Cluster": null, - "azure.mgmt.postgresqlflexibleservers.models.Configuration": null, - "azure.mgmt.postgresqlflexibleservers.models.ConfigurationForUpdate": null, - "azure.mgmt.postgresqlflexibleservers.models.ConfigurationList": null, - "azure.mgmt.postgresqlflexibleservers.models.Database": null, - "azure.mgmt.postgresqlflexibleservers.models.DatabaseList": null, - "azure.mgmt.postgresqlflexibleservers.models.DatabaseMigrationState": null, - "azure.mgmt.postgresqlflexibleservers.models.DataEncryption": null, - "azure.mgmt.postgresqlflexibleservers.models.DbLevelValidationStatus": null, - "azure.mgmt.postgresqlflexibleservers.models.DbServerMetadata": null, - "azure.mgmt.postgresqlflexibleservers.models.DelegatedSubnetUsage": null, - "azure.mgmt.postgresqlflexibleservers.models.ErrorAdditionalInfo": null, - "azure.mgmt.postgresqlflexibleservers.models.ErrorDetail": null, - "azure.mgmt.postgresqlflexibleservers.models.ErrorResponse": null, - "azure.mgmt.postgresqlflexibleservers.models.FastProvisioningEditionCapability": null, - "azure.mgmt.postgresqlflexibleservers.models.FirewallRule": null, - "azure.mgmt.postgresqlflexibleservers.models.FirewallRuleList": null, - "azure.mgmt.postgresqlflexibleservers.models.HighAvailability": null, - "azure.mgmt.postgresqlflexibleservers.models.HighAvailabilityForPatch": null, - "azure.mgmt.postgresqlflexibleservers.models.ImpactRecord": null, - "azure.mgmt.postgresqlflexibleservers.models.LtrPreBackupRequest": null, - "azure.mgmt.postgresqlflexibleservers.models.LtrPreBackupResponse": null, - "azure.mgmt.postgresqlflexibleservers.models.LtrServerBackupOperationList": null, - "azure.mgmt.postgresqlflexibleservers.models.MaintenanceWindow": null, - "azure.mgmt.postgresqlflexibleservers.models.MaintenanceWindowForPatch": null, - "azure.mgmt.postgresqlflexibleservers.models.TrackedResource": null, - "azure.mgmt.postgresqlflexibleservers.models.Migration": null, - "azure.mgmt.postgresqlflexibleservers.models.MigrationList": null, - "azure.mgmt.postgresqlflexibleservers.models.MigrationNameAvailability": null, - "azure.mgmt.postgresqlflexibleservers.models.MigrationResourceForPatch": null, - "azure.mgmt.postgresqlflexibleservers.models.MigrationSecretParameters": null, - "azure.mgmt.postgresqlflexibleservers.models.MigrationSecretParametersForPatch": null, - "azure.mgmt.postgresqlflexibleservers.models.MigrationStatus": null, - "azure.mgmt.postgresqlflexibleservers.models.MigrationSubstateDetails": null, - "azure.mgmt.postgresqlflexibleservers.models.NameAvailabilityModel": null, - "azure.mgmt.postgresqlflexibleservers.models.NameProperty": null, - "azure.mgmt.postgresqlflexibleservers.models.Network": null, - "azure.mgmt.postgresqlflexibleservers.models.ObjectRecommendation": null, - "azure.mgmt.postgresqlflexibleservers.models.ObjectRecommendationDetails": null, - "azure.mgmt.postgresqlflexibleservers.models.ObjectRecommendationList": null, - "azure.mgmt.postgresqlflexibleservers.models.ObjectRecommendationPropertiesAnalyzedWorkload": null, - "azure.mgmt.postgresqlflexibleservers.models.ObjectRecommendationPropertiesImplementationDetails": null, - "azure.mgmt.postgresqlflexibleservers.models.Operation": null, - "azure.mgmt.postgresqlflexibleservers.models.OperationDisplay": null, - "azure.mgmt.postgresqlflexibleservers.models.OperationList": null, - "azure.mgmt.postgresqlflexibleservers.models.PrivateEndpoint": null, - "azure.mgmt.postgresqlflexibleservers.models.PrivateEndpointConnection": null, - "azure.mgmt.postgresqlflexibleservers.models.PrivateEndpointConnectionList": null, - "azure.mgmt.postgresqlflexibleservers.models.PrivateLinkResource": null, - "azure.mgmt.postgresqlflexibleservers.models.PrivateLinkResourceList": null, - "azure.mgmt.postgresqlflexibleservers.models.PrivateLinkServiceConnectionState": null, - "azure.mgmt.postgresqlflexibleservers.models.QuotaUsage": null, - "azure.mgmt.postgresqlflexibleservers.models.QuotaUsageList": null, - "azure.mgmt.postgresqlflexibleservers.models.Replica": null, - "azure.mgmt.postgresqlflexibleservers.models.RestartParameter": null, - "azure.mgmt.postgresqlflexibleservers.models.Server": null, - "azure.mgmt.postgresqlflexibleservers.models.ServerEditionCapability": null, - "azure.mgmt.postgresqlflexibleservers.models.ServerForPatch": null, - "azure.mgmt.postgresqlflexibleservers.models.ServerList": null, - "azure.mgmt.postgresqlflexibleservers.models.ServerSku": null, - "azure.mgmt.postgresqlflexibleservers.models.ServerSkuCapability": null, - "azure.mgmt.postgresqlflexibleservers.models.ServerVersionCapability": null, - "azure.mgmt.postgresqlflexibleservers.models.Sku": null, - "azure.mgmt.postgresqlflexibleservers.models.SkuForPatch": null, - "azure.mgmt.postgresqlflexibleservers.models.Storage": null, - "azure.mgmt.postgresqlflexibleservers.models.StorageEditionCapability": null, - "azure.mgmt.postgresqlflexibleservers.models.StorageMbCapability": null, - "azure.mgmt.postgresqlflexibleservers.models.StorageTierCapability": null, - "azure.mgmt.postgresqlflexibleservers.models.SupportedFeature": null, - "azure.mgmt.postgresqlflexibleservers.models.SystemData": null, - "azure.mgmt.postgresqlflexibleservers.models.TuningOptions": null, - "azure.mgmt.postgresqlflexibleservers.models.TuningOptionsList": null, - "azure.mgmt.postgresqlflexibleservers.models.UserAssignedIdentity": null, - "azure.mgmt.postgresqlflexibleservers.models.UserIdentity": null, - "azure.mgmt.postgresqlflexibleservers.models.ValidationDetails": null, - "azure.mgmt.postgresqlflexibleservers.models.ValidationMessage": null, - "azure.mgmt.postgresqlflexibleservers.models.ValidationSummaryItem": null, - "azure.mgmt.postgresqlflexibleservers.models.VirtualEndpointResourceForPatch": null, - "azure.mgmt.postgresqlflexibleservers.models.VirtualEndpoint": null, - "azure.mgmt.postgresqlflexibleservers.models.VirtualEndpointsList": null, - "azure.mgmt.postgresqlflexibleservers.models.VirtualNetworkSubnetUsageModel": null, - "azure.mgmt.postgresqlflexibleservers.models.VirtualNetworkSubnetUsageParameter": null, - "azure.mgmt.postgresqlflexibleservers.models.CreatedByType": null, - "azure.mgmt.postgresqlflexibleservers.models.PrincipalType": null, - "azure.mgmt.postgresqlflexibleservers.models.ThreatProtectionState": null, - "azure.mgmt.postgresqlflexibleservers.models.BackupType": null, - "azure.mgmt.postgresqlflexibleservers.models.CapabilityStatus": null, - "azure.mgmt.postgresqlflexibleservers.models.HighAvailabilityMode": null, - "azure.mgmt.postgresqlflexibleservers.models.FeatureStatus": null, - "azure.mgmt.postgresqlflexibleservers.models.FastProvisioningSupport": null, - "azure.mgmt.postgresqlflexibleservers.models.GeographicallyRedundantBackupSupport": null, - "azure.mgmt.postgresqlflexibleservers.models.ZoneRedundantHighAvailabilitySupport": null, - "azure.mgmt.postgresqlflexibleservers.models.ZoneRedundantHighAvailabilityAndGeographicallyRedundantBackupSupport": null, - "azure.mgmt.postgresqlflexibleservers.models.StorageAutoGrowthSupport": null, - "azure.mgmt.postgresqlflexibleservers.models.OnlineStorageResizeSupport": null, - "azure.mgmt.postgresqlflexibleservers.models.LocationRestricted": null, - "azure.mgmt.postgresqlflexibleservers.models.ConfigurationDataType": null, - "azure.mgmt.postgresqlflexibleservers.models.ExecutionStatus": null, - "azure.mgmt.postgresqlflexibleservers.models.ValidationState": null, - "azure.mgmt.postgresqlflexibleservers.models.MigrationState": null, - "azure.mgmt.postgresqlflexibleservers.models.MigrationSubstate": null, - "azure.mgmt.postgresqlflexibleservers.models.MigrationDatabaseState": null, - "azure.mgmt.postgresqlflexibleservers.models.MigrationMode": null, - "azure.mgmt.postgresqlflexibleservers.models.MigrationOption": null, - "azure.mgmt.postgresqlflexibleservers.models.SourceType": null, - "azure.mgmt.postgresqlflexibleservers.models.SslMode": null, - "azure.mgmt.postgresqlflexibleservers.models.SkuTier": null, - "azure.mgmt.postgresqlflexibleservers.models.LogicalReplicationOnSourceServer": null, - "azure.mgmt.postgresqlflexibleservers.models.OverwriteDatabasesOnTargetServer": null, - "azure.mgmt.postgresqlflexibleservers.models.MigrateRolesAndPermissions": null, - "azure.mgmt.postgresqlflexibleservers.models.StartDataMigration": null, - "azure.mgmt.postgresqlflexibleservers.models.TriggerCutover": null, - "azure.mgmt.postgresqlflexibleservers.models.Cancel": null, - "azure.mgmt.postgresqlflexibleservers.models.OperationOrigin": null, - "azure.mgmt.postgresqlflexibleservers.models.PrivateEndpointServiceConnectionStatus": null, - "azure.mgmt.postgresqlflexibleservers.models.PrivateEndpointConnectionProvisioningState": null, - "azure.mgmt.postgresqlflexibleservers.models.IdentityType": null, - "azure.mgmt.postgresqlflexibleservers.models.PostgresMajorVersion": null, - "azure.mgmt.postgresqlflexibleservers.models.ServerState": null, - "azure.mgmt.postgresqlflexibleservers.models.StorageAutoGrow": null, - "azure.mgmt.postgresqlflexibleservers.models.AzureManagedDiskPerformanceTier": null, - "azure.mgmt.postgresqlflexibleservers.models.StorageType": null, - "azure.mgmt.postgresqlflexibleservers.models.MicrosoftEntraAuth": null, - "azure.mgmt.postgresqlflexibleservers.models.PasswordBasedAuth": null, - "azure.mgmt.postgresqlflexibleservers.models.DataEncryptionType": null, - "azure.mgmt.postgresqlflexibleservers.models.EncryptionKeyStatus": null, - "azure.mgmt.postgresqlflexibleservers.models.GeographicallyRedundantBackup": null, - "azure.mgmt.postgresqlflexibleservers.models.ServerPublicNetworkAccessState": null, - "azure.mgmt.postgresqlflexibleservers.models.HighAvailabilityState": null, - "azure.mgmt.postgresqlflexibleservers.models.ReplicationRole": null, - "azure.mgmt.postgresqlflexibleservers.models.ReplicationState": null, - "azure.mgmt.postgresqlflexibleservers.models.ReadReplicaPromoteMode": null, - "azure.mgmt.postgresqlflexibleservers.models.ReadReplicaPromoteOption": null, - "azure.mgmt.postgresqlflexibleservers.models.CreateMode": null, - "azure.mgmt.postgresqlflexibleservers.models.RecommendationTypeEnum": null, - "azure.mgmt.postgresqlflexibleservers.models.VirtualEndpointType": null, - "azure.mgmt.postgresqlflexibleservers.models.ThreatProtectionName": null, - "azure.mgmt.postgresqlflexibleservers.models.MigrationListFilter": null, - "azure.mgmt.postgresqlflexibleservers.models.MigrationNameAvailabilityReason": null, - "azure.mgmt.postgresqlflexibleservers.models.CheckNameAvailabilityReason": null, - "azure.mgmt.postgresqlflexibleservers.models.CreateModeForPatch": null, - "azure.mgmt.postgresqlflexibleservers.models.FailoverMode": null, - "azure.mgmt.postgresqlflexibleservers.models.TuningOptionParameterEnum": null, - "azure.mgmt.postgresqlflexibleservers.models.RecommendationTypeParameterEnum": null, - "azure.mgmt.postgresqlflexibleservers.models.MigrationDetailsLevel": null, - "azure.mgmt.postgresqlflexibleservers.operations.AdministratorsMicrosoftEntraOperations.begin_create_or_update": null, - "azure.mgmt.postgresqlflexibleservers.aio.operations.AdministratorsMicrosoftEntraOperations.begin_create_or_update": null, - "azure.mgmt.postgresqlflexibleservers.operations.AdministratorsMicrosoftEntraOperations.begin_delete": null, - "azure.mgmt.postgresqlflexibleservers.aio.operations.AdministratorsMicrosoftEntraOperations.begin_delete": null, - "azure.mgmt.postgresqlflexibleservers.operations.AdministratorsMicrosoftEntraOperations.get": null, - "azure.mgmt.postgresqlflexibleservers.aio.operations.AdministratorsMicrosoftEntraOperations.get": null, - "azure.mgmt.postgresqlflexibleservers.operations.AdministratorsMicrosoftEntraOperations.list_by_server": null, - "azure.mgmt.postgresqlflexibleservers.aio.operations.AdministratorsMicrosoftEntraOperations.list_by_server": null, - "azure.mgmt.postgresqlflexibleservers.operations.AdvancedThreatProtectionSettingsOperations.list_by_server": null, - "azure.mgmt.postgresqlflexibleservers.aio.operations.AdvancedThreatProtectionSettingsOperations.list_by_server": null, - "azure.mgmt.postgresqlflexibleservers.operations.AdvancedThreatProtectionSettingsOperations.get": null, - "azure.mgmt.postgresqlflexibleservers.aio.operations.AdvancedThreatProtectionSettingsOperations.get": null, - "azure.mgmt.postgresqlflexibleservers.operations.ServerThreatProtectionSettingsOperations.begin_create_or_update": null, - "azure.mgmt.postgresqlflexibleservers.aio.operations.ServerThreatProtectionSettingsOperations.begin_create_or_update": null, - "azure.mgmt.postgresqlflexibleservers.operations.BackupsAutomaticAndOnDemandOperations.begin_create": null, - "azure.mgmt.postgresqlflexibleservers.aio.operations.BackupsAutomaticAndOnDemandOperations.begin_create": null, - "azure.mgmt.postgresqlflexibleservers.operations.BackupsAutomaticAndOnDemandOperations.begin_delete": null, - "azure.mgmt.postgresqlflexibleservers.aio.operations.BackupsAutomaticAndOnDemandOperations.begin_delete": null, - "azure.mgmt.postgresqlflexibleservers.operations.BackupsAutomaticAndOnDemandOperations.get": null, - "azure.mgmt.postgresqlflexibleservers.aio.operations.BackupsAutomaticAndOnDemandOperations.get": null, - "azure.mgmt.postgresqlflexibleservers.operations.BackupsAutomaticAndOnDemandOperations.list_by_server": null, - "azure.mgmt.postgresqlflexibleservers.aio.operations.BackupsAutomaticAndOnDemandOperations.list_by_server": null, - "azure.mgmt.postgresqlflexibleservers.operations.CapabilitiesByLocationOperations.list": null, - "azure.mgmt.postgresqlflexibleservers.aio.operations.CapabilitiesByLocationOperations.list": null, - "azure.mgmt.postgresqlflexibleservers.operations.CapabilitiesByServerOperations.list": null, - "azure.mgmt.postgresqlflexibleservers.aio.operations.CapabilitiesByServerOperations.list": null, - "azure.mgmt.postgresqlflexibleservers.operations.CapturedLogsOperations.list_by_server": null, - "azure.mgmt.postgresqlflexibleservers.aio.operations.CapturedLogsOperations.list_by_server": null, - "azure.mgmt.postgresqlflexibleservers.operations.ConfigurationsOperations.list_by_server": null, - "azure.mgmt.postgresqlflexibleservers.aio.operations.ConfigurationsOperations.list_by_server": null, - "azure.mgmt.postgresqlflexibleservers.operations.ConfigurationsOperations.get": null, - "azure.mgmt.postgresqlflexibleservers.aio.operations.ConfigurationsOperations.get": null, - "azure.mgmt.postgresqlflexibleservers.operations.ConfigurationsOperations.begin_update": null, - "azure.mgmt.postgresqlflexibleservers.aio.operations.ConfigurationsOperations.begin_update": null, - "azure.mgmt.postgresqlflexibleservers.operations.ConfigurationsOperations.begin_put": null, - "azure.mgmt.postgresqlflexibleservers.aio.operations.ConfigurationsOperations.begin_put": null, - "azure.mgmt.postgresqlflexibleservers.operations.DatabasesOperations.begin_create": null, - "azure.mgmt.postgresqlflexibleservers.aio.operations.DatabasesOperations.begin_create": null, - "azure.mgmt.postgresqlflexibleservers.operations.DatabasesOperations.begin_delete": null, - "azure.mgmt.postgresqlflexibleservers.aio.operations.DatabasesOperations.begin_delete": null, - "azure.mgmt.postgresqlflexibleservers.operations.DatabasesOperations.get": null, - "azure.mgmt.postgresqlflexibleservers.aio.operations.DatabasesOperations.get": null, - "azure.mgmt.postgresqlflexibleservers.operations.DatabasesOperations.list_by_server": null, - "azure.mgmt.postgresqlflexibleservers.aio.operations.DatabasesOperations.list_by_server": null, - "azure.mgmt.postgresqlflexibleservers.operations.FirewallRulesOperations.begin_create_or_update": null, - "azure.mgmt.postgresqlflexibleservers.aio.operations.FirewallRulesOperations.begin_create_or_update": null, - "azure.mgmt.postgresqlflexibleservers.operations.FirewallRulesOperations.begin_delete": null, - "azure.mgmt.postgresqlflexibleservers.aio.operations.FirewallRulesOperations.begin_delete": null, - "azure.mgmt.postgresqlflexibleservers.operations.FirewallRulesOperations.get": null, - "azure.mgmt.postgresqlflexibleservers.aio.operations.FirewallRulesOperations.get": null, - "azure.mgmt.postgresqlflexibleservers.operations.FirewallRulesOperations.list_by_server": null, - "azure.mgmt.postgresqlflexibleservers.aio.operations.FirewallRulesOperations.list_by_server": null, - "azure.mgmt.postgresqlflexibleservers.operations.BackupsLongTermRetentionOperations.check_prerequisites": null, - "azure.mgmt.postgresqlflexibleservers.aio.operations.BackupsLongTermRetentionOperations.check_prerequisites": null, - "azure.mgmt.postgresqlflexibleservers.operations.BackupsLongTermRetentionOperations.begin_start": null, - "azure.mgmt.postgresqlflexibleservers.aio.operations.BackupsLongTermRetentionOperations.begin_start": null, - "azure.mgmt.postgresqlflexibleservers.operations.BackupsLongTermRetentionOperations.get": null, - "azure.mgmt.postgresqlflexibleservers.aio.operations.BackupsLongTermRetentionOperations.get": null, - "azure.mgmt.postgresqlflexibleservers.operations.BackupsLongTermRetentionOperations.list_by_server": null, - "azure.mgmt.postgresqlflexibleservers.aio.operations.BackupsLongTermRetentionOperations.list_by_server": null, - "azure.mgmt.postgresqlflexibleservers.operations.MigrationsOperations.create": null, - "azure.mgmt.postgresqlflexibleservers.aio.operations.MigrationsOperations.create": null, - "azure.mgmt.postgresqlflexibleservers.operations.MigrationsOperations.get": null, - "azure.mgmt.postgresqlflexibleservers.aio.operations.MigrationsOperations.get": null, - "azure.mgmt.postgresqlflexibleservers.operations.MigrationsOperations.update": null, - "azure.mgmt.postgresqlflexibleservers.aio.operations.MigrationsOperations.update": null, - "azure.mgmt.postgresqlflexibleservers.operations.MigrationsOperations.cancel": null, - "azure.mgmt.postgresqlflexibleservers.aio.operations.MigrationsOperations.cancel": null, - "azure.mgmt.postgresqlflexibleservers.operations.MigrationsOperations.list_by_target_server": null, - "azure.mgmt.postgresqlflexibleservers.aio.operations.MigrationsOperations.list_by_target_server": null, - "azure.mgmt.postgresqlflexibleservers.operations.MigrationsOperations.check_name_availability": null, - "azure.mgmt.postgresqlflexibleservers.aio.operations.MigrationsOperations.check_name_availability": null, - "azure.mgmt.postgresqlflexibleservers.operations.NameAvailabilityOperations.check_globally": null, - "azure.mgmt.postgresqlflexibleservers.aio.operations.NameAvailabilityOperations.check_globally": null, - "azure.mgmt.postgresqlflexibleservers.operations.NameAvailabilityOperations.check_with_location": null, - "azure.mgmt.postgresqlflexibleservers.aio.operations.NameAvailabilityOperations.check_with_location": null, - "azure.mgmt.postgresqlflexibleservers.operations.Operations.list": null, - "azure.mgmt.postgresqlflexibleservers.aio.operations.Operations.list": null, - "azure.mgmt.postgresqlflexibleservers.operations.PrivateDnsZoneSuffixOperations.get": null, - "azure.mgmt.postgresqlflexibleservers.aio.operations.PrivateDnsZoneSuffixOperations.get": null, - "azure.mgmt.postgresqlflexibleservers.operations.PrivateEndpointConnectionsOperations.get": null, - "azure.mgmt.postgresqlflexibleservers.aio.operations.PrivateEndpointConnectionsOperations.get": null, - "azure.mgmt.postgresqlflexibleservers.operations.PrivateEndpointConnectionsOperations.begin_update": null, - "azure.mgmt.postgresqlflexibleservers.aio.operations.PrivateEndpointConnectionsOperations.begin_update": null, - "azure.mgmt.postgresqlflexibleservers.operations.PrivateEndpointConnectionsOperations.begin_delete": null, - "azure.mgmt.postgresqlflexibleservers.aio.operations.PrivateEndpointConnectionsOperations.begin_delete": null, - "azure.mgmt.postgresqlflexibleservers.operations.PrivateEndpointConnectionsOperations.list_by_server": null, - "azure.mgmt.postgresqlflexibleservers.aio.operations.PrivateEndpointConnectionsOperations.list_by_server": null, - "azure.mgmt.postgresqlflexibleservers.operations.PrivateLinkResourcesOperations.list_by_server": null, - "azure.mgmt.postgresqlflexibleservers.aio.operations.PrivateLinkResourcesOperations.list_by_server": null, - "azure.mgmt.postgresqlflexibleservers.operations.PrivateLinkResourcesOperations.get": null, - "azure.mgmt.postgresqlflexibleservers.aio.operations.PrivateLinkResourcesOperations.get": null, - "azure.mgmt.postgresqlflexibleservers.operations.QuotaUsagesOperations.list": null, - "azure.mgmt.postgresqlflexibleservers.aio.operations.QuotaUsagesOperations.list": null, - "azure.mgmt.postgresqlflexibleservers.operations.ReplicasOperations.list_by_server": null, - "azure.mgmt.postgresqlflexibleservers.aio.operations.ReplicasOperations.list_by_server": null, - "azure.mgmt.postgresqlflexibleservers.operations.ServersOperations.begin_create_or_update": null, - "azure.mgmt.postgresqlflexibleservers.aio.operations.ServersOperations.begin_create_or_update": null, - "azure.mgmt.postgresqlflexibleservers.operations.ServersOperations.begin_update": null, - "azure.mgmt.postgresqlflexibleservers.aio.operations.ServersOperations.begin_update": null, - "azure.mgmt.postgresqlflexibleservers.operations.ServersOperations.begin_delete": null, - "azure.mgmt.postgresqlflexibleservers.aio.operations.ServersOperations.begin_delete": null, - "azure.mgmt.postgresqlflexibleservers.operations.ServersOperations.get": null, - "azure.mgmt.postgresqlflexibleservers.aio.operations.ServersOperations.get": null, - "azure.mgmt.postgresqlflexibleservers.operations.ServersOperations.list_by_resource_group": null, - "azure.mgmt.postgresqlflexibleservers.aio.operations.ServersOperations.list_by_resource_group": null, - "azure.mgmt.postgresqlflexibleservers.operations.ServersOperations.list_by_subscription": null, - "azure.mgmt.postgresqlflexibleservers.aio.operations.ServersOperations.list_by_subscription": null, - "azure.mgmt.postgresqlflexibleservers.operations.ServersOperations.begin_restart": null, - "azure.mgmt.postgresqlflexibleservers.aio.operations.ServersOperations.begin_restart": null, - "azure.mgmt.postgresqlflexibleservers.operations.ServersOperations.begin_start": null, - "azure.mgmt.postgresqlflexibleservers.aio.operations.ServersOperations.begin_start": null, - "azure.mgmt.postgresqlflexibleservers.operations.ServersOperations.begin_stop": null, - "azure.mgmt.postgresqlflexibleservers.aio.operations.ServersOperations.begin_stop": null, - "azure.mgmt.postgresqlflexibleservers.operations.TuningOptionsOperations.get": null, - "azure.mgmt.postgresqlflexibleservers.aio.operations.TuningOptionsOperations.get": null, - "azure.mgmt.postgresqlflexibleservers.operations.TuningOptionsOperations.list_recommendations": null, - "azure.mgmt.postgresqlflexibleservers.aio.operations.TuningOptionsOperations.list_recommendations": null, - "azure.mgmt.postgresqlflexibleservers.operations.TuningOptionsOperations.list_by_server": null, - "azure.mgmt.postgresqlflexibleservers.aio.operations.TuningOptionsOperations.list_by_server": null, - "azure.mgmt.postgresqlflexibleservers.operations.VirtualEndpointsOperations.begin_create": null, - "azure.mgmt.postgresqlflexibleservers.aio.operations.VirtualEndpointsOperations.begin_create": null, - "azure.mgmt.postgresqlflexibleservers.operations.VirtualEndpointsOperations.begin_update": null, - "azure.mgmt.postgresqlflexibleservers.aio.operations.VirtualEndpointsOperations.begin_update": null, - "azure.mgmt.postgresqlflexibleservers.operations.VirtualEndpointsOperations.begin_delete": null, - "azure.mgmt.postgresqlflexibleservers.aio.operations.VirtualEndpointsOperations.begin_delete": null, - "azure.mgmt.postgresqlflexibleservers.operations.VirtualEndpointsOperations.get": null, - "azure.mgmt.postgresqlflexibleservers.aio.operations.VirtualEndpointsOperations.get": null, - "azure.mgmt.postgresqlflexibleservers.operations.VirtualEndpointsOperations.list_by_server": null, - "azure.mgmt.postgresqlflexibleservers.aio.operations.VirtualEndpointsOperations.list_by_server": null, - "azure.mgmt.postgresqlflexibleservers.operations.VirtualNetworkSubnetUsageOperations.list": null, - "azure.mgmt.postgresqlflexibleservers.aio.operations.VirtualNetworkSubnetUsageOperations.list": null + "azure.mgmt.postgresqlflexibleservers.models.AdminCredentials": "Microsoft.DBforPostgreSQL.AdminCredentials", + "azure.mgmt.postgresqlflexibleservers.models.AdminCredentialsForPatch": "Microsoft.DBforPostgreSQL.AdminCredentialsForPatch", + "azure.mgmt.postgresqlflexibleservers.models.Resource": "Azure.ResourceManager.CommonTypes.Resource", + "azure.mgmt.postgresqlflexibleservers.models.ProxyResource": "Azure.ResourceManager.CommonTypes.ProxyResource", + "azure.mgmt.postgresqlflexibleservers.models.AdministratorMicrosoftEntra": "Microsoft.DBforPostgreSQL.AdministratorMicrosoftEntra", + "azure.mgmt.postgresqlflexibleservers.models.AdministratorMicrosoftEntraAdd": "Microsoft.DBforPostgreSQL.AdministratorMicrosoftEntraAdd", + "azure.mgmt.postgresqlflexibleservers.models.AdministratorMicrosoftEntraProperties": "Microsoft.DBforPostgreSQL.AdministratorMicrosoftEntraProperties", + "azure.mgmt.postgresqlflexibleservers.models.AdministratorMicrosoftEntraPropertiesForAdd": "Microsoft.DBforPostgreSQL.AdministratorMicrosoftEntraPropertiesForAdd", + "azure.mgmt.postgresqlflexibleservers.models.AdvancedThreatProtectionSettingsModel": "Microsoft.DBforPostgreSQL.AdvancedThreatProtectionSettingsModel", + "azure.mgmt.postgresqlflexibleservers.models.AdvancedThreatProtectionSettingsProperties": "Microsoft.DBforPostgreSQL.AdvancedThreatProtectionSettingsProperties", + "azure.mgmt.postgresqlflexibleservers.models.AuthConfig": "Microsoft.DBforPostgreSQL.AuthConfig", + "azure.mgmt.postgresqlflexibleservers.models.AuthConfigForPatch": "Microsoft.DBforPostgreSQL.AuthConfigForPatch", + "azure.mgmt.postgresqlflexibleservers.models.Backup": "Microsoft.DBforPostgreSQL.Backup", + "azure.mgmt.postgresqlflexibleservers.models.BackupAutomaticAndOnDemand": "Microsoft.DBforPostgreSQL.BackupAutomaticAndOnDemand", + "azure.mgmt.postgresqlflexibleservers.models.BackupAutomaticAndOnDemandProperties": "Microsoft.DBforPostgreSQL.BackupAutomaticAndOnDemandProperties", + "azure.mgmt.postgresqlflexibleservers.models.BackupForPatch": "Microsoft.DBforPostgreSQL.BackupForPatch", + "azure.mgmt.postgresqlflexibleservers.models.BackupRequestBase": "Microsoft.DBforPostgreSQL.BackupRequestBase", + "azure.mgmt.postgresqlflexibleservers.models.BackupSettings": "Microsoft.DBforPostgreSQL.BackupSettings", + "azure.mgmt.postgresqlflexibleservers.models.BackupsLongTermRetentionOperation": "Microsoft.DBforPostgreSQL.BackupsLongTermRetentionOperation", + "azure.mgmt.postgresqlflexibleservers.models.BackupsLongTermRetentionRequest": "Microsoft.DBforPostgreSQL.BackupsLongTermRetentionRequest", + "azure.mgmt.postgresqlflexibleservers.models.BackupsLongTermRetentionResponse": "Microsoft.DBforPostgreSQL.BackupsLongTermRetentionResponse", + "azure.mgmt.postgresqlflexibleservers.models.BackupsLongTermRetentionResponseProperties": "Microsoft.DBforPostgreSQL.BackupsLongTermRetentionResponseProperties", + "azure.mgmt.postgresqlflexibleservers.models.BackupStoreDetails": "Microsoft.DBforPostgreSQL.BackupStoreDetails", + "azure.mgmt.postgresqlflexibleservers.models.CapabilityBase": "Microsoft.DBforPostgreSQL.CapabilityBase", + "azure.mgmt.postgresqlflexibleservers.models.Capability": "Microsoft.DBforPostgreSQL.Capability", + "azure.mgmt.postgresqlflexibleservers.models.CapturedLog": "Microsoft.DBforPostgreSQL.CapturedLog", + "azure.mgmt.postgresqlflexibleservers.models.CapturedLogProperties": "Microsoft.DBforPostgreSQL.CapturedLogProperties", + "azure.mgmt.postgresqlflexibleservers.models.CheckNameAvailabilityRequest": "Azure.ResourceManager.CommonTypes.CheckNameAvailabilityRequest", + "azure.mgmt.postgresqlflexibleservers.models.CheckNameAvailabilityResponse": "Azure.ResourceManager.CommonTypes.CheckNameAvailabilityResponse", + "azure.mgmt.postgresqlflexibleservers.models.Cluster": "Microsoft.DBforPostgreSQL.Cluster", + "azure.mgmt.postgresqlflexibleservers.models.Configuration": "Microsoft.DBforPostgreSQL.Configuration", + "azure.mgmt.postgresqlflexibleservers.models.ConfigurationForUpdate": "Microsoft.DBforPostgreSQL.ConfigurationForUpdate", + "azure.mgmt.postgresqlflexibleservers.models.ConfigurationProperties": "Microsoft.DBforPostgreSQL.ConfigurationProperties", + "azure.mgmt.postgresqlflexibleservers.models.Database": "Microsoft.DBforPostgreSQL.Database", + "azure.mgmt.postgresqlflexibleservers.models.DatabaseMigrationState": "Microsoft.DBforPostgreSQL.DatabaseMigrationState", + "azure.mgmt.postgresqlflexibleservers.models.DatabaseProperties": "Microsoft.DBforPostgreSQL.DatabaseProperties", + "azure.mgmt.postgresqlflexibleservers.models.DataEncryption": "Microsoft.DBforPostgreSQL.DataEncryption", + "azure.mgmt.postgresqlflexibleservers.models.DbLevelValidationStatus": "Microsoft.DBforPostgreSQL.DbLevelValidationStatus", + "azure.mgmt.postgresqlflexibleservers.models.DbServerMetadata": "Microsoft.DBforPostgreSQL.DbServerMetadata", + "azure.mgmt.postgresqlflexibleservers.models.DelegatedSubnetUsage": "Microsoft.DBforPostgreSQL.DelegatedSubnetUsage", + "azure.mgmt.postgresqlflexibleservers.models.ErrorAdditionalInfo": "Azure.ResourceManager.CommonTypes.ErrorAdditionalInfo", + "azure.mgmt.postgresqlflexibleservers.models.ErrorDetail": "Azure.ResourceManager.CommonTypes.ErrorDetail", + "azure.mgmt.postgresqlflexibleservers.models.ErrorResponse": "Azure.ResourceManager.CommonTypes.ErrorResponse", + "azure.mgmt.postgresqlflexibleservers.models.FastProvisioningEditionCapability": "Microsoft.DBforPostgreSQL.FastProvisioningEditionCapability", + "azure.mgmt.postgresqlflexibleservers.models.FirewallRule": "Microsoft.DBforPostgreSQL.FirewallRule", + "azure.mgmt.postgresqlflexibleservers.models.FirewallRuleProperties": "Microsoft.DBforPostgreSQL.FirewallRuleProperties", + "azure.mgmt.postgresqlflexibleservers.models.HighAvailability": "Microsoft.DBforPostgreSQL.HighAvailability", + "azure.mgmt.postgresqlflexibleservers.models.HighAvailabilityForPatch": "Microsoft.DBforPostgreSQL.HighAvailabilityForPatch", + "azure.mgmt.postgresqlflexibleservers.models.ImpactRecord": "Microsoft.DBforPostgreSQL.ImpactRecord", + "azure.mgmt.postgresqlflexibleservers.models.LogSpecification": "Microsoft.DBforPostgreSQL.LogSpecification", + "azure.mgmt.postgresqlflexibleservers.models.LtrBackupOperationResponseProperties": "Microsoft.DBforPostgreSQL.LtrBackupOperationResponseProperties", + "azure.mgmt.postgresqlflexibleservers.models.LtrPreBackupRequest": "Microsoft.DBforPostgreSQL.LtrPreBackupRequest", + "azure.mgmt.postgresqlflexibleservers.models.LtrPreBackupResponse": "Microsoft.DBforPostgreSQL.LtrPreBackupResponse", + "azure.mgmt.postgresqlflexibleservers.models.MaintenanceWindow": "Microsoft.DBforPostgreSQL.MaintenanceWindow", + "azure.mgmt.postgresqlflexibleservers.models.MaintenanceWindowForPatch": "Microsoft.DBforPostgreSQL.MaintenanceWindowForPatch", + "azure.mgmt.postgresqlflexibleservers.models.MetricSpecification": "Microsoft.DBforPostgreSQL.MetricSpecification", + "azure.mgmt.postgresqlflexibleservers.models.MigrateNetworkStatus": "Microsoft.DBforPostgreSQL.MigrateNetworkStatus", + "azure.mgmt.postgresqlflexibleservers.models.TrackedResource": "Azure.ResourceManager.CommonTypes.TrackedResource", + "azure.mgmt.postgresqlflexibleservers.models.Migration": "Microsoft.DBforPostgreSQL.Migration", + "azure.mgmt.postgresqlflexibleservers.models.MigrationNameAvailability": "Microsoft.DBforPostgreSQL.MigrationNameAvailability", + "azure.mgmt.postgresqlflexibleservers.models.MigrationProperties": "Microsoft.DBforPostgreSQL.MigrationProperties", + "azure.mgmt.postgresqlflexibleservers.models.MigrationPropertiesForPatch": "Microsoft.DBforPostgreSQL.MigrationPropertiesForPatch", + "azure.mgmt.postgresqlflexibleservers.models.MigrationResourceForPatch": "Microsoft.DBforPostgreSQL.MigrationResourceForPatch", + "azure.mgmt.postgresqlflexibleservers.models.MigrationSecretParameters": "Microsoft.DBforPostgreSQL.MigrationSecretParameters", + "azure.mgmt.postgresqlflexibleservers.models.MigrationSecretParametersForPatch": "Microsoft.DBforPostgreSQL.MigrationSecretParametersForPatch", + "azure.mgmt.postgresqlflexibleservers.models.MigrationStatus": "Microsoft.DBforPostgreSQL.MigrationStatus", + "azure.mgmt.postgresqlflexibleservers.models.MigrationSubstateDetails": "Microsoft.DBforPostgreSQL.MigrationSubstateDetails", + "azure.mgmt.postgresqlflexibleservers.models.NameAvailabilityModel": "Microsoft.DBforPostgreSQL.NameAvailabilityModel", + "azure.mgmt.postgresqlflexibleservers.models.NameProperty": "Microsoft.DBforPostgreSQL.NameProperty", + "azure.mgmt.postgresqlflexibleservers.models.Network": "Microsoft.DBforPostgreSQL.Network", + "azure.mgmt.postgresqlflexibleservers.models.ObjectRecommendation": "Microsoft.DBforPostgreSQL.ObjectRecommendation", + "azure.mgmt.postgresqlflexibleservers.models.ObjectRecommendationDetails": "Microsoft.DBforPostgreSQL.ObjectRecommendationDetails", + "azure.mgmt.postgresqlflexibleservers.models.ObjectRecommendationProperties": "Microsoft.DBforPostgreSQL.ObjectRecommendationProperties", + "azure.mgmt.postgresqlflexibleservers.models.ObjectRecommendationPropertiesAnalyzedWorkload": "Microsoft.DBforPostgreSQL.ObjectRecommendationPropertiesAnalyzedWorkload", + "azure.mgmt.postgresqlflexibleservers.models.ObjectRecommendationPropertiesImplementationDetails": "Microsoft.DBforPostgreSQL.ObjectRecommendationPropertiesImplementationDetails", + "azure.mgmt.postgresqlflexibleservers.models.Operation": "Microsoft.DBforPostgreSQL.Operation", + "azure.mgmt.postgresqlflexibleservers.models.OperationDisplay": "Microsoft.DBforPostgreSQL.OperationDisplay", + "azure.mgmt.postgresqlflexibleservers.models.OperationProperties": "Microsoft.DBforPostgreSQL.OperationProperties", + "azure.mgmt.postgresqlflexibleservers.models.PrivateEndpoint": "Azure.ResourceManager.CommonTypes.PrivateEndpoint", + "azure.mgmt.postgresqlflexibleservers.models.PrivateEndpointConnection": "Microsoft.DBforPostgreSQL.PrivateEndpointConnection", + "azure.mgmt.postgresqlflexibleservers.models.PrivateEndpointConnectionProperties": "Azure.ResourceManager.CommonTypes.PrivateEndpointConnectionProperties", + "azure.mgmt.postgresqlflexibleservers.models.PrivateLinkResource": "Microsoft.DBforPostgreSQL.PrivateLinkResource", + "azure.mgmt.postgresqlflexibleservers.models.PrivateLinkResourceProperties": "Azure.ResourceManager.CommonTypes.PrivateLinkResourceProperties", + "azure.mgmt.postgresqlflexibleservers.models.PrivateLinkServiceConnectionState": "Azure.ResourceManager.CommonTypes.PrivateLinkServiceConnectionState", + "azure.mgmt.postgresqlflexibleservers.models.QuotaUsage": "Microsoft.DBforPostgreSQL.QuotaUsage", + "azure.mgmt.postgresqlflexibleservers.models.Replica": "Microsoft.DBforPostgreSQL.Replica", + "azure.mgmt.postgresqlflexibleservers.models.RestartParameter": "Microsoft.DBforPostgreSQL.RestartParameter", + "azure.mgmt.postgresqlflexibleservers.models.Server": "Microsoft.DBforPostgreSQL.Server", + "azure.mgmt.postgresqlflexibleservers.models.ServerEditionCapability": "Microsoft.DBforPostgreSQL.ServerEditionCapability", + "azure.mgmt.postgresqlflexibleservers.models.ServerForPatch": "Microsoft.DBforPostgreSQL.ServerForPatch", + "azure.mgmt.postgresqlflexibleservers.models.ServerProperties": "Microsoft.DBforPostgreSQL.ServerProperties", + "azure.mgmt.postgresqlflexibleservers.models.ServerPropertiesForPatch": "Microsoft.DBforPostgreSQL.ServerPropertiesForPatch", + "azure.mgmt.postgresqlflexibleservers.models.ServerSku": "Microsoft.DBforPostgreSQL.ServerSku", + "azure.mgmt.postgresqlflexibleservers.models.ServerSkuCapability": "Microsoft.DBforPostgreSQL.ServerSkuCapability", + "azure.mgmt.postgresqlflexibleservers.models.ServerVersionCapability": "Microsoft.DBforPostgreSQL.ServerVersionCapability", + "azure.mgmt.postgresqlflexibleservers.models.ServiceSpecification": "Microsoft.DBforPostgreSQL.ServiceSpecification", + "azure.mgmt.postgresqlflexibleservers.models.Sku": "Microsoft.DBforPostgreSQL.Sku", + "azure.mgmt.postgresqlflexibleservers.models.SkuForPatch": "Microsoft.DBforPostgreSQL.SkuForPatch", + "azure.mgmt.postgresqlflexibleservers.models.Storage": "Microsoft.DBforPostgreSQL.Storage", + "azure.mgmt.postgresqlflexibleservers.models.StorageEditionCapability": "Microsoft.DBforPostgreSQL.StorageEditionCapability", + "azure.mgmt.postgresqlflexibleservers.models.StorageMbCapability": "Microsoft.DBforPostgreSQL.StorageMbCapability", + "azure.mgmt.postgresqlflexibleservers.models.StorageTierCapability": "Microsoft.DBforPostgreSQL.StorageTierCapability", + "azure.mgmt.postgresqlflexibleservers.models.SupportedFeature": "Microsoft.DBforPostgreSQL.SupportedFeature", + "azure.mgmt.postgresqlflexibleservers.models.SystemData": "Azure.ResourceManager.CommonTypes.SystemData", + "azure.mgmt.postgresqlflexibleservers.models.TuningOptions": "Microsoft.DBforPostgreSQL.TuningOptions", + "azure.mgmt.postgresqlflexibleservers.models.TuningOptionsProperties": "Microsoft.DBforPostgreSQL.TuningOptionsProperties", + "azure.mgmt.postgresqlflexibleservers.models.UserAssignedIdentity": "Microsoft.DBforPostgreSQL.UserAssignedIdentity", + "azure.mgmt.postgresqlflexibleservers.models.UserIdentity": "Microsoft.DBforPostgreSQL.UserIdentity", + "azure.mgmt.postgresqlflexibleservers.models.ValidationDetails": "Microsoft.DBforPostgreSQL.ValidationDetails", + "azure.mgmt.postgresqlflexibleservers.models.ValidationMessage": "Microsoft.DBforPostgreSQL.ValidationMessage", + "azure.mgmt.postgresqlflexibleservers.models.ValidationSummaryItem": "Microsoft.DBforPostgreSQL.ValidationSummaryItem", + "azure.mgmt.postgresqlflexibleservers.models.VirtualEndpoint": "Microsoft.DBforPostgreSQL.VirtualEndpoint", + "azure.mgmt.postgresqlflexibleservers.models.VirtualEndpointResourceForPatch": "Microsoft.DBforPostgreSQL.VirtualEndpointResourceForPatch", + "azure.mgmt.postgresqlflexibleservers.models.VirtualEndpointResourceProperties": "Microsoft.DBforPostgreSQL.VirtualEndpointResourceProperties", + "azure.mgmt.postgresqlflexibleservers.models.VirtualNetworkSubnetUsageModel": "Microsoft.DBforPostgreSQL.VirtualNetworkSubnetUsageModel", + "azure.mgmt.postgresqlflexibleservers.models.VirtualNetworkSubnetUsageParameter": "Microsoft.DBforPostgreSQL.VirtualNetworkSubnetUsageParameter", + "azure.mgmt.postgresqlflexibleservers.models.OperationOrigin": "Microsoft.DBforPostgreSQL.OperationOrigin", + "azure.mgmt.postgresqlflexibleservers.models.CreatedByType": "Azure.ResourceManager.CommonTypes.createdByType", + "azure.mgmt.postgresqlflexibleservers.models.MigrationState": "Microsoft.DBforPostgreSQL.MigrationState", + "azure.mgmt.postgresqlflexibleservers.models.MigrationSubstate": "Microsoft.DBforPostgreSQL.MigrationSubstate", + "azure.mgmt.postgresqlflexibleservers.models.MigrationDatabaseState": "Microsoft.DBforPostgreSQL.MigrationDatabaseState", + "azure.mgmt.postgresqlflexibleservers.models.ValidationState": "Microsoft.DBforPostgreSQL.ValidationState", + "azure.mgmt.postgresqlflexibleservers.models.MigrationMode": "Microsoft.DBforPostgreSQL.MigrationMode", + "azure.mgmt.postgresqlflexibleservers.models.MigrationOption": "Microsoft.DBforPostgreSQL.MigrationOption", + "azure.mgmt.postgresqlflexibleservers.models.SourceType": "Microsoft.DBforPostgreSQL.SourceType", + "azure.mgmt.postgresqlflexibleservers.models.SslMode": "Microsoft.DBforPostgreSQL.SslMode", + "azure.mgmt.postgresqlflexibleservers.models.SkuTier": "Microsoft.DBforPostgreSQL.SkuTier", + "azure.mgmt.postgresqlflexibleservers.models.LogicalReplicationOnSourceServer": "Microsoft.DBforPostgreSQL.LogicalReplicationOnSourceServer", + "azure.mgmt.postgresqlflexibleservers.models.OverwriteDatabasesOnTargetServer": "Microsoft.DBforPostgreSQL.OverwriteDatabasesOnTargetServer", + "azure.mgmt.postgresqlflexibleservers.models.MigrateRolesAndPermissions": "Microsoft.DBforPostgreSQL.MigrateRolesAndPermissions", + "azure.mgmt.postgresqlflexibleservers.models.StartDataMigration": "Microsoft.DBforPostgreSQL.StartDataMigration", + "azure.mgmt.postgresqlflexibleservers.models.TriggerCutover": "Microsoft.DBforPostgreSQL.TriggerCutover", + "azure.mgmt.postgresqlflexibleservers.models.Cancel": "Microsoft.DBforPostgreSQL.Cancel", + "azure.mgmt.postgresqlflexibleservers.models.MigrationListFilter": "Microsoft.DBforPostgreSQL.MigrationListFilter", + "azure.mgmt.postgresqlflexibleservers.models.MigrationNameAvailabilityReason": "Microsoft.DBforPostgreSQL.MigrationNameAvailabilityReason", + "azure.mgmt.postgresqlflexibleservers.models.PostgresMajorVersion": "Microsoft.DBforPostgreSQL.PostgresMajorVersion", + "azure.mgmt.postgresqlflexibleservers.models.ServerState": "Microsoft.DBforPostgreSQL.ServerState", + "azure.mgmt.postgresqlflexibleservers.models.StorageAutoGrow": "Microsoft.DBforPostgreSQL.StorageAutoGrow", + "azure.mgmt.postgresqlflexibleservers.models.AzureManagedDiskPerformanceTier": "Microsoft.DBforPostgreSQL.AzureManagedDiskPerformanceTier", + "azure.mgmt.postgresqlflexibleservers.models.StorageType": "Microsoft.DBforPostgreSQL.StorageType", + "azure.mgmt.postgresqlflexibleservers.models.MicrosoftEntraAuth": "Microsoft.DBforPostgreSQL.MicrosoftEntraAuth", + "azure.mgmt.postgresqlflexibleservers.models.PasswordBasedAuth": "Microsoft.DBforPostgreSQL.PasswordBasedAuth", + "azure.mgmt.postgresqlflexibleservers.models.DataEncryptionType": "Microsoft.DBforPostgreSQL.DataEncryptionType", + "azure.mgmt.postgresqlflexibleservers.models.EncryptionKeyStatus": "Microsoft.DBforPostgreSQL.EncryptionKeyStatus", + "azure.mgmt.postgresqlflexibleservers.models.GeographicallyRedundantBackup": "Microsoft.DBforPostgreSQL.GeographicallyRedundantBackup", + "azure.mgmt.postgresqlflexibleservers.models.ServerPublicNetworkAccessState": "Microsoft.DBforPostgreSQL.ServerPublicNetworkAccessState", + "azure.mgmt.postgresqlflexibleservers.models.PostgreSqlFlexibleServerHighAvailabilityMode": "Microsoft.DBforPostgreSQL.PostgreSqlFlexibleServerHighAvailabilityMode", + "azure.mgmt.postgresqlflexibleservers.models.HighAvailabilityState": "Microsoft.DBforPostgreSQL.HighAvailabilityState", + "azure.mgmt.postgresqlflexibleservers.models.ReplicationRole": "Microsoft.DBforPostgreSQL.ReplicationRole", + "azure.mgmt.postgresqlflexibleservers.models.ReplicationState": "Microsoft.DBforPostgreSQL.ReplicationState", + "azure.mgmt.postgresqlflexibleservers.models.ReadReplicaPromoteMode": "Microsoft.DBforPostgreSQL.ReadReplicaPromoteMode", + "azure.mgmt.postgresqlflexibleservers.models.ReadReplicaPromoteOption": "Microsoft.DBforPostgreSQL.ReadReplicaPromoteOption", + "azure.mgmt.postgresqlflexibleservers.models.CreateMode": "Microsoft.DBforPostgreSQL.CreateMode", + "azure.mgmt.postgresqlflexibleservers.models.PrivateEndpointServiceConnectionStatus": "Azure.ResourceManager.CommonTypes.PrivateEndpointServiceConnectionStatus", + "azure.mgmt.postgresqlflexibleservers.models.PrivateEndpointConnectionProvisioningState": "Azure.ResourceManager.CommonTypes.PrivateEndpointConnectionProvisioningState", + "azure.mgmt.postgresqlflexibleservers.models.IdentityType": "Microsoft.DBforPostgreSQL.IdentityType", + "azure.mgmt.postgresqlflexibleservers.models.CreateModeForPatch": "Microsoft.DBforPostgreSQL.CreateModeForPatch", + "azure.mgmt.postgresqlflexibleservers.models.FailoverMode": "Microsoft.DBforPostgreSQL.FailoverMode", + "azure.mgmt.postgresqlflexibleservers.models.NetworkMigrationState": "Microsoft.DBforPostgreSQL.NetworkMigrationState", + "azure.mgmt.postgresqlflexibleservers.models.ConfigurationDataType": "Microsoft.DBforPostgreSQL.ConfigurationDataType", + "azure.mgmt.postgresqlflexibleservers.models.VirtualEndpointType": "Microsoft.DBforPostgreSQL.VirtualEndpointType", + "azure.mgmt.postgresqlflexibleservers.models.PrincipalType": "Microsoft.DBforPostgreSQL.PrincipalType", + "azure.mgmt.postgresqlflexibleservers.models.CapabilityStatus": "Microsoft.DBforPostgreSQL.CapabilityStatus", + "azure.mgmt.postgresqlflexibleservers.models.HighAvailabilityMode": "Microsoft.DBforPostgreSQL.HighAvailabilityMode", + "azure.mgmt.postgresqlflexibleservers.models.FeatureStatus": "Microsoft.DBforPostgreSQL.FeatureStatus", + "azure.mgmt.postgresqlflexibleservers.models.FastProvisioningSupport": "Microsoft.DBforPostgreSQL.FastProvisioningSupport", + "azure.mgmt.postgresqlflexibleservers.models.GeographicallyRedundantBackupSupport": "Microsoft.DBforPostgreSQL.GeographicallyRedundantBackupSupport", + "azure.mgmt.postgresqlflexibleservers.models.ZoneRedundantHighAvailabilitySupport": "Microsoft.DBforPostgreSQL.ZoneRedundantHighAvailabilitySupport", + "azure.mgmt.postgresqlflexibleservers.models.ZoneRedundantHighAvailabilityAndGeographicallyRedundantBackupSupport": "Microsoft.DBforPostgreSQL.ZoneRedundantHighAvailabilityAndGeographicallyRedundantBackupSupport", + "azure.mgmt.postgresqlflexibleservers.models.StorageAutoGrowthSupport": "Microsoft.DBforPostgreSQL.StorageAutoGrowthSupport", + "azure.mgmt.postgresqlflexibleservers.models.OnlineStorageResizeSupport": "Microsoft.DBforPostgreSQL.OnlineStorageResizeSupport", + "azure.mgmt.postgresqlflexibleservers.models.LocationRestricted": "Microsoft.DBforPostgreSQL.LocationRestricted", + "azure.mgmt.postgresqlflexibleservers.models.ExecutionStatus": "Microsoft.DBforPostgreSQL.ExecutionStatus", + "azure.mgmt.postgresqlflexibleservers.models.ThreatProtectionState": "Microsoft.DBforPostgreSQL.ThreatProtectionState", + "azure.mgmt.postgresqlflexibleservers.models.ThreatProtectionName": "Microsoft.DBforPostgreSQL.ThreatProtectionName", + "azure.mgmt.postgresqlflexibleservers.models.BackupType": "Microsoft.DBforPostgreSQL.BackupType", + "azure.mgmt.postgresqlflexibleservers.models.TuningOptionParameterEnum": "Microsoft.DBforPostgreSQL.TuningOptionParameterEnum", + "azure.mgmt.postgresqlflexibleservers.models.RecommendationTypeEnum": "Microsoft.DBforPostgreSQL.RecommendationTypeEnum", + "azure.mgmt.postgresqlflexibleservers.models.RecommendationTypeParameterEnum": "Microsoft.DBforPostgreSQL.RecommendationTypeParameterEnum", + "azure.mgmt.postgresqlflexibleservers.models.CheckNameAvailabilityReason": "Azure.ResourceManager.CommonTypes.CheckNameAvailabilityReason", + "azure.mgmt.postgresqlflexibleservers.operations.Operations.list": "Azure.ResourceManager.Legacy.Operations.list", + "azure.mgmt.postgresqlflexibleservers.aio.operations.Operations.list": "Azure.ResourceManager.Legacy.Operations.list", + "azure.mgmt.postgresqlflexibleservers.operations.MigrationsOperations.get": "Microsoft.DBforPostgreSQL.Migrations.get", + "azure.mgmt.postgresqlflexibleservers.aio.operations.MigrationsOperations.get": "Microsoft.DBforPostgreSQL.Migrations.get", + "azure.mgmt.postgresqlflexibleservers.operations.MigrationsOperations.create": "Microsoft.DBforPostgreSQL.Migrations.create", + "azure.mgmt.postgresqlflexibleservers.aio.operations.MigrationsOperations.create": "Microsoft.DBforPostgreSQL.Migrations.create", + "azure.mgmt.postgresqlflexibleservers.operations.MigrationsOperations.update": "Microsoft.DBforPostgreSQL.Migrations.update", + "azure.mgmt.postgresqlflexibleservers.aio.operations.MigrationsOperations.update": "Microsoft.DBforPostgreSQL.Migrations.update", + "azure.mgmt.postgresqlflexibleservers.operations.MigrationsOperations.cancel": "Microsoft.DBforPostgreSQL.Migrations.cancel", + "azure.mgmt.postgresqlflexibleservers.aio.operations.MigrationsOperations.cancel": "Microsoft.DBforPostgreSQL.Migrations.cancel", + "azure.mgmt.postgresqlflexibleservers.operations.MigrationsOperations.list_by_target_server": "Microsoft.DBforPostgreSQL.Migrations.listByTargetServer", + "azure.mgmt.postgresqlflexibleservers.aio.operations.MigrationsOperations.list_by_target_server": "Microsoft.DBforPostgreSQL.Migrations.listByTargetServer", + "azure.mgmt.postgresqlflexibleservers.operations.MigrationsOperations.check_name_availability": "Microsoft.DBforPostgreSQL.Servers.checkNameAvailability", + "azure.mgmt.postgresqlflexibleservers.aio.operations.MigrationsOperations.check_name_availability": "Microsoft.DBforPostgreSQL.Servers.checkNameAvailability", + "azure.mgmt.postgresqlflexibleservers.operations.ServersOperations.get": "Microsoft.DBforPostgreSQL.Servers.get", + "azure.mgmt.postgresqlflexibleservers.aio.operations.ServersOperations.get": "Microsoft.DBforPostgreSQL.Servers.get", + "azure.mgmt.postgresqlflexibleservers.operations.ServersOperations.begin_create_or_update": "Microsoft.DBforPostgreSQL.Servers.createOrUpdate", + "azure.mgmt.postgresqlflexibleservers.aio.operations.ServersOperations.begin_create_or_update": "Microsoft.DBforPostgreSQL.Servers.createOrUpdate", + "azure.mgmt.postgresqlflexibleservers.operations.ServersOperations.begin_update": "Microsoft.DBforPostgreSQL.Servers.update", + "azure.mgmt.postgresqlflexibleservers.aio.operations.ServersOperations.begin_update": "Microsoft.DBforPostgreSQL.Servers.update", + "azure.mgmt.postgresqlflexibleservers.operations.ServersOperations.begin_delete": "Microsoft.DBforPostgreSQL.Servers.delete", + "azure.mgmt.postgresqlflexibleservers.aio.operations.ServersOperations.begin_delete": "Microsoft.DBforPostgreSQL.Servers.delete", + "azure.mgmt.postgresqlflexibleservers.operations.ServersOperations.list_by_resource_group": "Microsoft.DBforPostgreSQL.Servers.listByResourceGroup", + "azure.mgmt.postgresqlflexibleservers.aio.operations.ServersOperations.list_by_resource_group": "Microsoft.DBforPostgreSQL.Servers.listByResourceGroup", + "azure.mgmt.postgresqlflexibleservers.operations.ServersOperations.list_by_subscription": "Microsoft.DBforPostgreSQL.Servers.listBySubscription", + "azure.mgmt.postgresqlflexibleservers.aio.operations.ServersOperations.list_by_subscription": "Microsoft.DBforPostgreSQL.Servers.listBySubscription", + "azure.mgmt.postgresqlflexibleservers.operations.ServersOperations.begin_restart": "Microsoft.DBforPostgreSQL.Servers.restart", + "azure.mgmt.postgresqlflexibleservers.aio.operations.ServersOperations.begin_restart": "Microsoft.DBforPostgreSQL.Servers.restart", + "azure.mgmt.postgresqlflexibleservers.operations.ServersOperations.begin_start": "Microsoft.DBforPostgreSQL.Servers.serversStart", + "azure.mgmt.postgresqlflexibleservers.aio.operations.ServersOperations.begin_start": "Microsoft.DBforPostgreSQL.Servers.serversStart", + "azure.mgmt.postgresqlflexibleservers.operations.ServersOperations.begin_stop": "Microsoft.DBforPostgreSQL.Servers.stop", + "azure.mgmt.postgresqlflexibleservers.aio.operations.ServersOperations.begin_stop": "Microsoft.DBforPostgreSQL.Servers.stop", + "azure.mgmt.postgresqlflexibleservers.operations.ServersOperations.begin_migrate_network_mode": "Microsoft.DBforPostgreSQL.Servers.migrateNetworkMode", + "azure.mgmt.postgresqlflexibleservers.aio.operations.ServersOperations.begin_migrate_network_mode": "Microsoft.DBforPostgreSQL.Servers.migrateNetworkMode", + "azure.mgmt.postgresqlflexibleservers.operations.ConfigurationsOperations.get": "Microsoft.DBforPostgreSQL.Configurations.get", + "azure.mgmt.postgresqlflexibleservers.aio.operations.ConfigurationsOperations.get": "Microsoft.DBforPostgreSQL.Configurations.get", + "azure.mgmt.postgresqlflexibleservers.operations.ConfigurationsOperations.begin_put": "Microsoft.DBforPostgreSQL.Configurations.put", + "azure.mgmt.postgresqlflexibleservers.aio.operations.ConfigurationsOperations.begin_put": "Microsoft.DBforPostgreSQL.Configurations.put", + "azure.mgmt.postgresqlflexibleservers.operations.ConfigurationsOperations.begin_update": "Microsoft.DBforPostgreSQL.Configurations.update", + "azure.mgmt.postgresqlflexibleservers.aio.operations.ConfigurationsOperations.begin_update": "Microsoft.DBforPostgreSQL.Configurations.update", + "azure.mgmt.postgresqlflexibleservers.operations.ConfigurationsOperations.list_by_server": "Microsoft.DBforPostgreSQL.Configurations.listByServer", + "azure.mgmt.postgresqlflexibleservers.aio.operations.ConfigurationsOperations.list_by_server": "Microsoft.DBforPostgreSQL.Configurations.listByServer", + "azure.mgmt.postgresqlflexibleservers.operations.DatabasesOperations.get": "Microsoft.DBforPostgreSQL.Databases.get", + "azure.mgmt.postgresqlflexibleservers.aio.operations.DatabasesOperations.get": "Microsoft.DBforPostgreSQL.Databases.get", + "azure.mgmt.postgresqlflexibleservers.operations.DatabasesOperations.begin_create": "Microsoft.DBforPostgreSQL.Databases.create", + "azure.mgmt.postgresqlflexibleservers.aio.operations.DatabasesOperations.begin_create": "Microsoft.DBforPostgreSQL.Databases.create", + "azure.mgmt.postgresqlflexibleservers.operations.DatabasesOperations.begin_delete": "Microsoft.DBforPostgreSQL.Databases.delete", + "azure.mgmt.postgresqlflexibleservers.aio.operations.DatabasesOperations.begin_delete": "Microsoft.DBforPostgreSQL.Databases.delete", + "azure.mgmt.postgresqlflexibleservers.operations.DatabasesOperations.list_by_server": "Microsoft.DBforPostgreSQL.Databases.listByServer", + "azure.mgmt.postgresqlflexibleservers.aio.operations.DatabasesOperations.list_by_server": "Microsoft.DBforPostgreSQL.Databases.listByServer", + "azure.mgmt.postgresqlflexibleservers.operations.FirewallRulesOperations.get": "Microsoft.DBforPostgreSQL.FirewallRules.get", + "azure.mgmt.postgresqlflexibleservers.aio.operations.FirewallRulesOperations.get": "Microsoft.DBforPostgreSQL.FirewallRules.get", + "azure.mgmt.postgresqlflexibleservers.operations.FirewallRulesOperations.begin_create_or_update": "Microsoft.DBforPostgreSQL.FirewallRules.createOrUpdate", + "azure.mgmt.postgresqlflexibleservers.aio.operations.FirewallRulesOperations.begin_create_or_update": "Microsoft.DBforPostgreSQL.FirewallRules.createOrUpdate", + "azure.mgmt.postgresqlflexibleservers.operations.FirewallRulesOperations.begin_delete": "Microsoft.DBforPostgreSQL.FirewallRules.delete", + "azure.mgmt.postgresqlflexibleservers.aio.operations.FirewallRulesOperations.begin_delete": "Microsoft.DBforPostgreSQL.FirewallRules.delete", + "azure.mgmt.postgresqlflexibleservers.operations.FirewallRulesOperations.list_by_server": "Microsoft.DBforPostgreSQL.FirewallRules.listByServer", + "azure.mgmt.postgresqlflexibleservers.aio.operations.FirewallRulesOperations.list_by_server": "Microsoft.DBforPostgreSQL.FirewallRules.listByServer", + "azure.mgmt.postgresqlflexibleservers.operations.PrivateEndpointConnectionsOperations.get": "Microsoft.DBforPostgreSQL.PrivateEndpointConnections.get", + "azure.mgmt.postgresqlflexibleservers.aio.operations.PrivateEndpointConnectionsOperations.get": "Microsoft.DBforPostgreSQL.PrivateEndpointConnections.get", + "azure.mgmt.postgresqlflexibleservers.operations.PrivateEndpointConnectionsOperations.begin_update": "Microsoft.DBforPostgreSQL.PrivateEndpointConnections.update", + "azure.mgmt.postgresqlflexibleservers.aio.operations.PrivateEndpointConnectionsOperations.begin_update": "Microsoft.DBforPostgreSQL.PrivateEndpointConnections.update", + "azure.mgmt.postgresqlflexibleservers.operations.PrivateEndpointConnectionsOperations.begin_delete": "Microsoft.DBforPostgreSQL.PrivateEndpointConnections.delete", + "azure.mgmt.postgresqlflexibleservers.aio.operations.PrivateEndpointConnectionsOperations.begin_delete": "Microsoft.DBforPostgreSQL.PrivateEndpointConnections.delete", + "azure.mgmt.postgresqlflexibleservers.operations.PrivateEndpointConnectionsOperations.list_by_server": "Microsoft.DBforPostgreSQL.PrivateEndpointConnections.listByServer", + "azure.mgmt.postgresqlflexibleservers.aio.operations.PrivateEndpointConnectionsOperations.list_by_server": "Microsoft.DBforPostgreSQL.PrivateEndpointConnections.listByServer", + "azure.mgmt.postgresqlflexibleservers.operations.PrivateLinkResourcesOperations.get": "Microsoft.DBforPostgreSQL.PrivateLinkResources.get", + "azure.mgmt.postgresqlflexibleservers.aio.operations.PrivateLinkResourcesOperations.get": "Microsoft.DBforPostgreSQL.PrivateLinkResources.get", + "azure.mgmt.postgresqlflexibleservers.operations.PrivateLinkResourcesOperations.list_by_server": "Microsoft.DBforPostgreSQL.PrivateLinkResources.listByServer", + "azure.mgmt.postgresqlflexibleservers.aio.operations.PrivateLinkResourcesOperations.list_by_server": "Microsoft.DBforPostgreSQL.PrivateLinkResources.listByServer", + "azure.mgmt.postgresqlflexibleservers.operations.VirtualEndpointsOperations.get": "Microsoft.DBforPostgreSQL.VirtualEndpoints.get", + "azure.mgmt.postgresqlflexibleservers.aio.operations.VirtualEndpointsOperations.get": "Microsoft.DBforPostgreSQL.VirtualEndpoints.get", + "azure.mgmt.postgresqlflexibleservers.operations.VirtualEndpointsOperations.begin_create": "Microsoft.DBforPostgreSQL.VirtualEndpoints.create", + "azure.mgmt.postgresqlflexibleservers.aio.operations.VirtualEndpointsOperations.begin_create": "Microsoft.DBforPostgreSQL.VirtualEndpoints.create", + "azure.mgmt.postgresqlflexibleservers.operations.VirtualEndpointsOperations.begin_update": "Microsoft.DBforPostgreSQL.VirtualEndpoints.update", + "azure.mgmt.postgresqlflexibleservers.aio.operations.VirtualEndpointsOperations.begin_update": "Microsoft.DBforPostgreSQL.VirtualEndpoints.update", + "azure.mgmt.postgresqlflexibleservers.operations.VirtualEndpointsOperations.begin_delete": "Microsoft.DBforPostgreSQL.VirtualEndpoints.delete", + "azure.mgmt.postgresqlflexibleservers.aio.operations.VirtualEndpointsOperations.begin_delete": "Microsoft.DBforPostgreSQL.VirtualEndpoints.delete", + "azure.mgmt.postgresqlflexibleservers.operations.VirtualEndpointsOperations.list_by_server": "Microsoft.DBforPostgreSQL.VirtualEndpoints.listByServer", + "azure.mgmt.postgresqlflexibleservers.aio.operations.VirtualEndpointsOperations.list_by_server": "Microsoft.DBforPostgreSQL.VirtualEndpoints.listByServer", + "azure.mgmt.postgresqlflexibleservers.operations.AdministratorsMicrosoftEntraOperations.get": "Microsoft.DBforPostgreSQL.AdministratorMicrosoftEntras.get", + "azure.mgmt.postgresqlflexibleservers.aio.operations.AdministratorsMicrosoftEntraOperations.get": "Microsoft.DBforPostgreSQL.AdministratorMicrosoftEntras.get", + "azure.mgmt.postgresqlflexibleservers.operations.AdministratorsMicrosoftEntraOperations.begin_create_or_update": "Microsoft.DBforPostgreSQL.AdministratorMicrosoftEntras.createOrUpdate", + "azure.mgmt.postgresqlflexibleservers.aio.operations.AdministratorsMicrosoftEntraOperations.begin_create_or_update": "Microsoft.DBforPostgreSQL.AdministratorMicrosoftEntras.createOrUpdate", + "azure.mgmt.postgresqlflexibleservers.operations.AdministratorsMicrosoftEntraOperations.begin_delete": "Microsoft.DBforPostgreSQL.AdministratorMicrosoftEntras.delete", + "azure.mgmt.postgresqlflexibleservers.aio.operations.AdministratorsMicrosoftEntraOperations.begin_delete": "Microsoft.DBforPostgreSQL.AdministratorMicrosoftEntras.delete", + "azure.mgmt.postgresqlflexibleservers.operations.AdministratorsMicrosoftEntraOperations.list_by_server": "Microsoft.DBforPostgreSQL.AdministratorMicrosoftEntras.listByServer", + "azure.mgmt.postgresqlflexibleservers.aio.operations.AdministratorsMicrosoftEntraOperations.list_by_server": "Microsoft.DBforPostgreSQL.AdministratorMicrosoftEntras.listByServer", + "azure.mgmt.postgresqlflexibleservers.operations.CapabilitiesByServerOperations.list": "Microsoft.DBforPostgreSQL.Servers.list", + "azure.mgmt.postgresqlflexibleservers.aio.operations.CapabilitiesByServerOperations.list": "Microsoft.DBforPostgreSQL.Servers.list", + "azure.mgmt.postgresqlflexibleservers.operations.CapturedLogsOperations.list_by_server": "Microsoft.DBforPostgreSQL.Servers.listByServer", + "azure.mgmt.postgresqlflexibleservers.aio.operations.CapturedLogsOperations.list_by_server": "Microsoft.DBforPostgreSQL.Servers.listByServer", + "azure.mgmt.postgresqlflexibleservers.operations.BackupsLongTermRetentionOperations.check_prerequisites": "Microsoft.DBforPostgreSQL.Servers.checkPrerequisites", + "azure.mgmt.postgresqlflexibleservers.aio.operations.BackupsLongTermRetentionOperations.check_prerequisites": "Microsoft.DBforPostgreSQL.Servers.checkPrerequisites", + "azure.mgmt.postgresqlflexibleservers.operations.BackupsLongTermRetentionOperations.begin_start": "Microsoft.DBforPostgreSQL.Servers.start", + "azure.mgmt.postgresqlflexibleservers.aio.operations.BackupsLongTermRetentionOperations.begin_start": "Microsoft.DBforPostgreSQL.Servers.start", + "azure.mgmt.postgresqlflexibleservers.operations.BackupsLongTermRetentionOperations.get": "Microsoft.DBforPostgreSQL.BackupsLongTermRetentionOperations.get", + "azure.mgmt.postgresqlflexibleservers.aio.operations.BackupsLongTermRetentionOperations.get": "Microsoft.DBforPostgreSQL.BackupsLongTermRetentionOperations.get", + "azure.mgmt.postgresqlflexibleservers.operations.BackupsLongTermRetentionOperations.list_by_server": "Microsoft.DBforPostgreSQL.BackupsLongTermRetentionOperations.listByServer", + "azure.mgmt.postgresqlflexibleservers.aio.operations.BackupsLongTermRetentionOperations.list_by_server": "Microsoft.DBforPostgreSQL.BackupsLongTermRetentionOperations.listByServer", + "azure.mgmt.postgresqlflexibleservers.operations.ReplicasOperations.list_by_server": "Microsoft.DBforPostgreSQL.Servers.replicasListByServer", + "azure.mgmt.postgresqlflexibleservers.aio.operations.ReplicasOperations.list_by_server": "Microsoft.DBforPostgreSQL.Servers.replicasListByServer", + "azure.mgmt.postgresqlflexibleservers.operations.AdvancedThreatProtectionSettingsOperations.get": "Microsoft.DBforPostgreSQL.AdvancedThreatProtectionSettingsModels.get", + "azure.mgmt.postgresqlflexibleservers.aio.operations.AdvancedThreatProtectionSettingsOperations.get": "Microsoft.DBforPostgreSQL.AdvancedThreatProtectionSettingsModels.get", + "azure.mgmt.postgresqlflexibleservers.operations.AdvancedThreatProtectionSettingsOperations.list_by_server": "Microsoft.DBforPostgreSQL.AdvancedThreatProtectionSettingsModels.listByServer", + "azure.mgmt.postgresqlflexibleservers.aio.operations.AdvancedThreatProtectionSettingsOperations.list_by_server": "Microsoft.DBforPostgreSQL.AdvancedThreatProtectionSettingsModels.listByServer", + "azure.mgmt.postgresqlflexibleservers.operations.ServerThreatProtectionSettingsOperations.begin_create_or_update": "Microsoft.DBforPostgreSQL.AdvancedThreatProtectionSettingsModels.createOrUpdate", + "azure.mgmt.postgresqlflexibleservers.aio.operations.ServerThreatProtectionSettingsOperations.begin_create_or_update": "Microsoft.DBforPostgreSQL.AdvancedThreatProtectionSettingsModels.createOrUpdate", + "azure.mgmt.postgresqlflexibleservers.operations.BackupsAutomaticAndOnDemandOperations.get": "Microsoft.DBforPostgreSQL.BackupAutomaticAndOnDemands.get", + "azure.mgmt.postgresqlflexibleservers.aio.operations.BackupsAutomaticAndOnDemandOperations.get": "Microsoft.DBforPostgreSQL.BackupAutomaticAndOnDemands.get", + "azure.mgmt.postgresqlflexibleservers.operations.BackupsAutomaticAndOnDemandOperations.begin_create": "Microsoft.DBforPostgreSQL.BackupAutomaticAndOnDemands.create", + "azure.mgmt.postgresqlflexibleservers.aio.operations.BackupsAutomaticAndOnDemandOperations.begin_create": "Microsoft.DBforPostgreSQL.BackupAutomaticAndOnDemands.create", + "azure.mgmt.postgresqlflexibleservers.operations.BackupsAutomaticAndOnDemandOperations.begin_delete": "Microsoft.DBforPostgreSQL.BackupAutomaticAndOnDemands.delete", + "azure.mgmt.postgresqlflexibleservers.aio.operations.BackupsAutomaticAndOnDemandOperations.begin_delete": "Microsoft.DBforPostgreSQL.BackupAutomaticAndOnDemands.delete", + "azure.mgmt.postgresqlflexibleservers.operations.BackupsAutomaticAndOnDemandOperations.list_by_server": "Microsoft.DBforPostgreSQL.BackupAutomaticAndOnDemands.listByServer", + "azure.mgmt.postgresqlflexibleservers.aio.operations.BackupsAutomaticAndOnDemandOperations.list_by_server": "Microsoft.DBforPostgreSQL.BackupAutomaticAndOnDemands.listByServer", + "azure.mgmt.postgresqlflexibleservers.operations.TuningOptionsOperations.get": "Microsoft.DBforPostgreSQL.TuningOptionsOperationGroup.get", + "azure.mgmt.postgresqlflexibleservers.aio.operations.TuningOptionsOperations.get": "Microsoft.DBforPostgreSQL.TuningOptionsOperationGroup.get", + "azure.mgmt.postgresqlflexibleservers.operations.TuningOptionsOperations.list_by_server": "Microsoft.DBforPostgreSQL.TuningOptionsOperationGroup.listByServer", + "azure.mgmt.postgresqlflexibleservers.aio.operations.TuningOptionsOperations.list_by_server": "Microsoft.DBforPostgreSQL.TuningOptionsOperationGroup.listByServer", + "azure.mgmt.postgresqlflexibleservers.operations.TuningOptionsOperations.list_recommendations": "Microsoft.DBforPostgreSQL.TuningOptionsOperationGroup.listRecommendations", + "azure.mgmt.postgresqlflexibleservers.aio.operations.TuningOptionsOperations.list_recommendations": "Microsoft.DBforPostgreSQL.TuningOptionsOperationGroup.listRecommendations", + "azure.mgmt.postgresqlflexibleservers.operations.CapabilitiesByLocationOperations.list": "Microsoft.DBforPostgreSQL.CapabilitiesByLocationOperationGroup.list", + "azure.mgmt.postgresqlflexibleservers.aio.operations.CapabilitiesByLocationOperations.list": "Microsoft.DBforPostgreSQL.CapabilitiesByLocationOperationGroup.list", + "azure.mgmt.postgresqlflexibleservers.operations.NameAvailabilityOperations.check_globally": "Microsoft.DBforPostgreSQL.NameAvailabilityOperationGroup.checkGlobally", + "azure.mgmt.postgresqlflexibleservers.aio.operations.NameAvailabilityOperations.check_globally": "Microsoft.DBforPostgreSQL.NameAvailabilityOperationGroup.checkGlobally", + "azure.mgmt.postgresqlflexibleservers.operations.NameAvailabilityOperations.check_with_location": "Microsoft.DBforPostgreSQL.NameAvailabilityOperationGroup.checkWithLocation", + "azure.mgmt.postgresqlflexibleservers.aio.operations.NameAvailabilityOperations.check_with_location": "Microsoft.DBforPostgreSQL.NameAvailabilityOperationGroup.checkWithLocation", + "azure.mgmt.postgresqlflexibleservers.operations.PrivateDnsZoneSuffixOperations.get": "Microsoft.DBforPostgreSQL.PrivateDnsZoneSuffixOperationGroup.get", + "azure.mgmt.postgresqlflexibleservers.aio.operations.PrivateDnsZoneSuffixOperations.get": "Microsoft.DBforPostgreSQL.PrivateDnsZoneSuffixOperationGroup.get", + "azure.mgmt.postgresqlflexibleservers.operations.QuotaUsagesOperations.list": "Microsoft.DBforPostgreSQL.QuotaUsagesOperationGroup.list", + "azure.mgmt.postgresqlflexibleservers.aio.operations.QuotaUsagesOperations.list": "Microsoft.DBforPostgreSQL.QuotaUsagesOperationGroup.list", + "azure.mgmt.postgresqlflexibleservers.operations.VirtualNetworkSubnetUsageOperations.list": "Microsoft.DBforPostgreSQL.VirtualNetworkSubnetUsageOperationGroup.list", + "azure.mgmt.postgresqlflexibleservers.aio.operations.VirtualNetworkSubnetUsageOperations.list": "Microsoft.DBforPostgreSQL.VirtualNetworkSubnetUsageOperationGroup.list" } } \ No newline at end of file diff --git a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/azure/mgmt/postgresqlflexibleservers/__init__.py b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/azure/mgmt/postgresqlflexibleservers/__init__.py index 465e9c48a700..6534a56248e1 100644 --- a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/azure/mgmt/postgresqlflexibleservers/__init__.py +++ b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/azure/mgmt/postgresqlflexibleservers/__init__.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- # pylint: disable=wrong-import-position @@ -12,7 +12,7 @@ if TYPE_CHECKING: from ._patch import * # pylint: disable=unused-wildcard-import -from ._postgre_sql_management_client import PostgreSQLManagementClient # type: ignore +from ._client import PostgreSQLManagementClient # type: ignore from ._version import VERSION __version__ = VERSION diff --git a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/azure/mgmt/postgresqlflexibleservers/_postgre_sql_management_client.py b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/azure/mgmt/postgresqlflexibleservers/_client.py similarity index 93% rename from sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/azure/mgmt/postgresqlflexibleservers/_postgre_sql_management_client.py rename to sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/azure/mgmt/postgresqlflexibleservers/_client.py index 2895722d9d63..ba4c6b411b98 100644 --- a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/azure/mgmt/postgresqlflexibleservers/_postgre_sql_management_client.py +++ b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/azure/mgmt/postgresqlflexibleservers/_client.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -17,7 +17,6 @@ from azure.mgmt.core.policies import ARMAutoResourceProviderRegistrationPolicy from azure.mgmt.core.tools import get_arm_endpoints -from . import models as _models from ._configuration import PostgreSQLManagementClientConfiguration from ._utils.serialization import Deserializer, Serializer from .operations import ( @@ -57,9 +56,42 @@ class PostgreSQLManagementClient: # pylint: disable=too-many-instance-attribute network configuration, security alert policies, log files and configurations with new business model. + :ivar operations: Operations operations + :vartype operations: azure.mgmt.postgresqlflexibleservers.operations.Operations + :ivar migrations: MigrationsOperations operations + :vartype migrations: azure.mgmt.postgresqlflexibleservers.operations.MigrationsOperations + :ivar servers: ServersOperations operations + :vartype servers: azure.mgmt.postgresqlflexibleservers.operations.ServersOperations + :ivar configurations: ConfigurationsOperations operations + :vartype configurations: + azure.mgmt.postgresqlflexibleservers.operations.ConfigurationsOperations + :ivar databases: DatabasesOperations operations + :vartype databases: azure.mgmt.postgresqlflexibleservers.operations.DatabasesOperations + :ivar firewall_rules: FirewallRulesOperations operations + :vartype firewall_rules: + azure.mgmt.postgresqlflexibleservers.operations.FirewallRulesOperations + :ivar private_endpoint_connections: PrivateEndpointConnectionsOperations operations + :vartype private_endpoint_connections: + azure.mgmt.postgresqlflexibleservers.operations.PrivateEndpointConnectionsOperations + :ivar private_link_resources: PrivateLinkResourcesOperations operations + :vartype private_link_resources: + azure.mgmt.postgresqlflexibleservers.operations.PrivateLinkResourcesOperations + :ivar virtual_endpoints: VirtualEndpointsOperations operations + :vartype virtual_endpoints: + azure.mgmt.postgresqlflexibleservers.operations.VirtualEndpointsOperations :ivar administrators_microsoft_entra: AdministratorsMicrosoftEntraOperations operations :vartype administrators_microsoft_entra: azure.mgmt.postgresqlflexibleservers.operations.AdministratorsMicrosoftEntraOperations + :ivar capabilities_by_server: CapabilitiesByServerOperations operations + :vartype capabilities_by_server: + azure.mgmt.postgresqlflexibleservers.operations.CapabilitiesByServerOperations + :ivar captured_logs: CapturedLogsOperations operations + :vartype captured_logs: azure.mgmt.postgresqlflexibleservers.operations.CapturedLogsOperations + :ivar backups_long_term_retention: BackupsLongTermRetentionOperations operations + :vartype backups_long_term_retention: + azure.mgmt.postgresqlflexibleservers.operations.BackupsLongTermRetentionOperations + :ivar replicas: ReplicasOperations operations + :vartype replicas: azure.mgmt.postgresqlflexibleservers.operations.ReplicasOperations :ivar advanced_threat_protection_settings: AdvancedThreatProtectionSettingsOperations operations :vartype advanced_threat_protection_settings: @@ -70,66 +102,34 @@ class PostgreSQLManagementClient: # pylint: disable=too-many-instance-attribute :ivar backups_automatic_and_on_demand: BackupsAutomaticAndOnDemandOperations operations :vartype backups_automatic_and_on_demand: azure.mgmt.postgresqlflexibleservers.operations.BackupsAutomaticAndOnDemandOperations + :ivar tuning_options: TuningOptionsOperations operations + :vartype tuning_options: + azure.mgmt.postgresqlflexibleservers.operations.TuningOptionsOperations :ivar capabilities_by_location: CapabilitiesByLocationOperations operations :vartype capabilities_by_location: azure.mgmt.postgresqlflexibleservers.operations.CapabilitiesByLocationOperations - :ivar capabilities_by_server: CapabilitiesByServerOperations operations - :vartype capabilities_by_server: - azure.mgmt.postgresqlflexibleservers.operations.CapabilitiesByServerOperations - :ivar captured_logs: CapturedLogsOperations operations - :vartype captured_logs: azure.mgmt.postgresqlflexibleservers.operations.CapturedLogsOperations - :ivar configurations: ConfigurationsOperations operations - :vartype configurations: - azure.mgmt.postgresqlflexibleservers.operations.ConfigurationsOperations - :ivar databases: DatabasesOperations operations - :vartype databases: azure.mgmt.postgresqlflexibleservers.operations.DatabasesOperations - :ivar firewall_rules: FirewallRulesOperations operations - :vartype firewall_rules: - azure.mgmt.postgresqlflexibleservers.operations.FirewallRulesOperations - :ivar backups_long_term_retention: BackupsLongTermRetentionOperations operations - :vartype backups_long_term_retention: - azure.mgmt.postgresqlflexibleservers.operations.BackupsLongTermRetentionOperations - :ivar migrations: MigrationsOperations operations - :vartype migrations: azure.mgmt.postgresqlflexibleservers.operations.MigrationsOperations :ivar name_availability: NameAvailabilityOperations operations :vartype name_availability: azure.mgmt.postgresqlflexibleservers.operations.NameAvailabilityOperations - :ivar operations: Operations operations - :vartype operations: azure.mgmt.postgresqlflexibleservers.operations.Operations :ivar private_dns_zone_suffix: PrivateDnsZoneSuffixOperations operations :vartype private_dns_zone_suffix: azure.mgmt.postgresqlflexibleservers.operations.PrivateDnsZoneSuffixOperations - :ivar private_endpoint_connections: PrivateEndpointConnectionsOperations operations - :vartype private_endpoint_connections: - azure.mgmt.postgresqlflexibleservers.operations.PrivateEndpointConnectionsOperations - :ivar private_link_resources: PrivateLinkResourcesOperations operations - :vartype private_link_resources: - azure.mgmt.postgresqlflexibleservers.operations.PrivateLinkResourcesOperations :ivar quota_usages: QuotaUsagesOperations operations :vartype quota_usages: azure.mgmt.postgresqlflexibleservers.operations.QuotaUsagesOperations - :ivar replicas: ReplicasOperations operations - :vartype replicas: azure.mgmt.postgresqlflexibleservers.operations.ReplicasOperations - :ivar servers: ServersOperations operations - :vartype servers: azure.mgmt.postgresqlflexibleservers.operations.ServersOperations - :ivar tuning_options: TuningOptionsOperations operations - :vartype tuning_options: - azure.mgmt.postgresqlflexibleservers.operations.TuningOptionsOperations - :ivar virtual_endpoints: VirtualEndpointsOperations operations - :vartype virtual_endpoints: - azure.mgmt.postgresqlflexibleservers.operations.VirtualEndpointsOperations :ivar virtual_network_subnet_usage: VirtualNetworkSubnetUsageOperations operations :vartype virtual_network_subnet_usage: azure.mgmt.postgresqlflexibleservers.operations.VirtualNetworkSubnetUsageOperations - :param credential: Credential needed for the client to connect to Azure. Required. + :param credential: Credential used to authenticate requests to the service. Required. :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The ID of the target subscription. The value must be an UUID. Required. :type subscription_id: str - :param base_url: Service URL. Default value is None. + :param base_url: Service host. Default value is None. :type base_url: str :keyword cloud_setting: The cloud setting for which to get the ARM endpoint. Default value is None. :paramtype cloud_setting: ~azure.core.AzureClouds - :keyword api_version: Api Version. Default value is "2025-08-01". Note that overriding this + :keyword api_version: The API version to use for this operation. Known values are + "2026-01-01-preview" and None. Default value is "2026-01-01-preview". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str :keyword int polling_interval: Default waiting time between two polls for LRO operations if no @@ -145,6 +145,7 @@ def __init__( cloud_setting: Optional["AzureClouds"] = None, **kwargs: Any ) -> None: + _endpoint = "{endpoint}" _cloud = cloud_setting or settings.current.azure_cloud # type: ignore _endpoints = get_arm_endpoints(_cloud) if not base_url: @@ -153,6 +154,7 @@ def __init__( self._config = PostgreSQLManagementClientConfiguration( credential=credential, subscription_id=subscription_id, + base_url=cast(str, base_url), cloud_setting=cloud_setting, credential_scopes=credential_scopes, **kwargs @@ -176,69 +178,68 @@ def __init__( policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, self._config.http_logging_policy, ] - self._client: ARMPipelineClient = ARMPipelineClient(base_url=cast(str, base_url), policies=_policies, **kwargs) + self._client: ARMPipelineClient = ARMPipelineClient(base_url=cast(str, _endpoint), policies=_policies, **kwargs) - client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer(client_models) - self._deserialize = Deserializer(client_models) + self._serialize = Serializer() + self._deserialize = Deserializer() self._serialize.client_side_validation = False - self.administrators_microsoft_entra = AdministratorsMicrosoftEntraOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.advanced_threat_protection_settings = AdvancedThreatProtectionSettingsOperations( + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.migrations = MigrationsOperations(self._client, self._config, self._serialize, self._deserialize) + self.servers = ServersOperations(self._client, self._config, self._serialize, self._deserialize) + self.configurations = ConfigurationsOperations(self._client, self._config, self._serialize, self._deserialize) + self.databases = DatabasesOperations(self._client, self._config, self._serialize, self._deserialize) + self.firewall_rules = FirewallRulesOperations(self._client, self._config, self._serialize, self._deserialize) + self.private_endpoint_connections = PrivateEndpointConnectionsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.server_threat_protection_settings = ServerThreatProtectionSettingsOperations( + self.private_link_resources = PrivateLinkResourcesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.backups_automatic_and_on_demand = BackupsAutomaticAndOnDemandOperations( + self.virtual_endpoints = VirtualEndpointsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.capabilities_by_location = CapabilitiesByLocationOperations( + self.administrators_microsoft_entra = AdministratorsMicrosoftEntraOperations( self._client, self._config, self._serialize, self._deserialize ) self.capabilities_by_server = CapabilitiesByServerOperations( self._client, self._config, self._serialize, self._deserialize ) self.captured_logs = CapturedLogsOperations(self._client, self._config, self._serialize, self._deserialize) - self.configurations = ConfigurationsOperations(self._client, self._config, self._serialize, self._deserialize) - self.databases = DatabasesOperations(self._client, self._config, self._serialize, self._deserialize) - self.firewall_rules = FirewallRulesOperations(self._client, self._config, self._serialize, self._deserialize) self.backups_long_term_retention = BackupsLongTermRetentionOperations( self._client, self._config, self._serialize, self._deserialize ) - self.migrations = MigrationsOperations(self._client, self._config, self._serialize, self._deserialize) - self.name_availability = NameAvailabilityOperations( + self.replicas = ReplicasOperations(self._client, self._config, self._serialize, self._deserialize) + self.advanced_threat_protection_settings = AdvancedThreatProtectionSettingsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) - self.private_dns_zone_suffix = PrivateDnsZoneSuffixOperations( + self.server_threat_protection_settings = ServerThreatProtectionSettingsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.private_endpoint_connections = PrivateEndpointConnectionsOperations( + self.backups_automatic_and_on_demand = BackupsAutomaticAndOnDemandOperations( self._client, self._config, self._serialize, self._deserialize ) - self.private_link_resources = PrivateLinkResourcesOperations( + self.tuning_options = TuningOptionsOperations(self._client, self._config, self._serialize, self._deserialize) + self.capabilities_by_location = CapabilitiesByLocationOperations( self._client, self._config, self._serialize, self._deserialize ) - self.quota_usages = QuotaUsagesOperations(self._client, self._config, self._serialize, self._deserialize) - self.replicas = ReplicasOperations(self._client, self._config, self._serialize, self._deserialize) - self.servers = ServersOperations(self._client, self._config, self._serialize, self._deserialize) - self.tuning_options = TuningOptionsOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_endpoints = VirtualEndpointsOperations( + self.name_availability = NameAvailabilityOperations( self._client, self._config, self._serialize, self._deserialize ) + self.private_dns_zone_suffix = PrivateDnsZoneSuffixOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.quota_usages = QuotaUsagesOperations(self._client, self._config, self._serialize, self._deserialize) self.virtual_network_subnet_usage = VirtualNetworkSubnetUsageOperations( self._client, self._config, self._serialize, self._deserialize ) - def _send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse: + def send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest >>> request = HttpRequest("GET", "https://www.example.org/") - >>> response = client._send_request(request) + >>> response = client.send_request(request) For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request @@ -251,7 +252,11 @@ def _send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: """ request_copy = deepcopy(request) - request_copy.url = self._client.format_url(request_copy.url) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + request_copy.url = self._client.format_url(request_copy.url, **path_format_arguments) return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore def close(self) -> None: diff --git a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/azure/mgmt/postgresqlflexibleservers/_configuration.py b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/azure/mgmt/postgresqlflexibleservers/_configuration.py index 4ddcd144107f..2357199eacbd 100644 --- a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/azure/mgmt/postgresqlflexibleservers/_configuration.py +++ b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/azure/mgmt/postgresqlflexibleservers/_configuration.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -24,14 +24,17 @@ class PostgreSQLManagementClientConfiguration: # pylint: disable=too-many-insta Note that all parameters used to create this instance are saved as instance attributes. - :param credential: Credential needed for the client to connect to Azure. Required. + :param credential: Credential used to authenticate requests to the service. Required. :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The ID of the target subscription. The value must be an UUID. Required. :type subscription_id: str + :param base_url: Service host. Default value is "https://management.azure.com". + :type base_url: str :param cloud_setting: The cloud setting for which to get the ARM endpoint. Default value is None. :type cloud_setting: ~azure.core.AzureClouds - :keyword api_version: Api Version. Default value is "2025-08-01". Note that overriding this + :keyword api_version: The API version to use for this operation. Known values are + "2026-01-01-preview" and None. Default value is "2026-01-01-preview". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ @@ -40,10 +43,11 @@ def __init__( self, credential: "TokenCredential", subscription_id: str, + base_url: str = "https://management.azure.com", cloud_setting: Optional["AzureClouds"] = None, **kwargs: Any ) -> None: - api_version: str = kwargs.pop("api_version", "2025-08-01") + api_version: str = kwargs.pop("api_version", "2026-01-01-preview") if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -52,6 +56,7 @@ def __init__( self.credential = credential self.subscription_id = subscription_id + self.base_url = base_url self.cloud_setting = cloud_setting self.api_version = api_version self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) diff --git a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/azure/mgmt/postgresqlflexibleservers/_patch.py b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/azure/mgmt/postgresqlflexibleservers/_patch.py index f7dd32510333..87676c65a8f0 100644 --- a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/azure/mgmt/postgresqlflexibleservers/_patch.py +++ b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/azure/mgmt/postgresqlflexibleservers/_patch.py @@ -1,14 +1,15 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------- """Customize generated code here. Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize """ -from typing import List -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +__all__: list[str] = [] # Add all objects you want publicly available to users at this package level def patch_sdk(): diff --git a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/azure/mgmt/postgresqlflexibleservers/_utils/__init__.py b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/azure/mgmt/postgresqlflexibleservers/_utils/__init__.py index 0af9b28f6607..8026245c2abc 100644 --- a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/azure/mgmt/postgresqlflexibleservers/_utils/__init__.py +++ b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/azure/mgmt/postgresqlflexibleservers/_utils/__init__.py @@ -1,6 +1,6 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- diff --git a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/azure/mgmt/postgresqlflexibleservers/_utils/model_base.py b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/azure/mgmt/postgresqlflexibleservers/_utils/model_base.py new file mode 100644 index 000000000000..c402af2afc63 --- /dev/null +++ b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/azure/mgmt/postgresqlflexibleservers/_utils/model_base.py @@ -0,0 +1,1337 @@ +# pylint: disable=line-too-long,useless-suppression,too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +# pylint: disable=protected-access, broad-except + +import copy +import calendar +import decimal +import functools +import sys +import logging +import base64 +import re +import typing +import enum +import email.utils +from datetime import datetime, date, time, timedelta, timezone +from json import JSONEncoder +import xml.etree.ElementTree as ET +from collections.abc import MutableMapping +from typing_extensions import Self +import isodate +from azure.core.exceptions import DeserializationError +from azure.core import CaseInsensitiveEnumMeta +from azure.core.pipeline import PipelineResponse +from azure.core.serialization import _Null +from azure.core.rest import HttpResponse + +_LOGGER = logging.getLogger(__name__) + +__all__ = ["SdkJSONEncoder", "Model", "rest_field", "rest_discriminator"] + +TZ_UTC = timezone.utc +_T = typing.TypeVar("_T") +_NONE_TYPE = type(None) + + +def _timedelta_as_isostr(td: timedelta) -> str: + """Converts a datetime.timedelta object into an ISO 8601 formatted string, e.g. 'P4DT12H30M05S' + + Function adapted from the Tin Can Python project: https://github.com/RusticiSoftware/TinCanPython + + :param timedelta td: The timedelta to convert + :rtype: str + :return: ISO8601 version of this timedelta + """ + + # Split seconds to larger units + seconds = td.total_seconds() + minutes, seconds = divmod(seconds, 60) + hours, minutes = divmod(minutes, 60) + days, hours = divmod(hours, 24) + + days, hours, minutes = list(map(int, (days, hours, minutes))) + seconds = round(seconds, 6) + + # Build date + date_str = "" + if days: + date_str = "%sD" % days + + if hours or minutes or seconds: + # Build time + time_str = "T" + + # Hours + bigger_exists = date_str or hours + if bigger_exists: + time_str += "{:02}H".format(hours) + + # Minutes + bigger_exists = bigger_exists or minutes + if bigger_exists: + time_str += "{:02}M".format(minutes) + + # Seconds + try: + if seconds.is_integer(): + seconds_string = "{:02}".format(int(seconds)) + else: + # 9 chars long w/ leading 0, 6 digits after decimal + seconds_string = "%09.6f" % seconds + # Remove trailing zeros + seconds_string = seconds_string.rstrip("0") + except AttributeError: # int.is_integer() raises + seconds_string = "{:02}".format(seconds) + + time_str += "{}S".format(seconds_string) + else: + time_str = "" + + return "P" + date_str + time_str + + +def _serialize_bytes(o, format: typing.Optional[str] = None) -> str: + encoded = base64.b64encode(o).decode() + if format == "base64url": + return encoded.strip("=").replace("+", "-").replace("/", "_") + return encoded + + +def _serialize_datetime(o, format: typing.Optional[str] = None): + if hasattr(o, "year") and hasattr(o, "hour"): + if format == "rfc7231": + return email.utils.format_datetime(o, usegmt=True) + if format == "unix-timestamp": + return int(calendar.timegm(o.utctimetuple())) + + # astimezone() fails for naive times in Python 2.7, so make make sure o is aware (tzinfo is set) + if not o.tzinfo: + iso_formatted = o.replace(tzinfo=TZ_UTC).isoformat() + else: + iso_formatted = o.astimezone(TZ_UTC).isoformat() + # Replace the trailing "+00:00" UTC offset with "Z" (RFC 3339: https://www.ietf.org/rfc/rfc3339.txt) + return iso_formatted.replace("+00:00", "Z") + # Next try datetime.date or datetime.time + return o.isoformat() + + +def _is_readonly(p): + try: + return p._visibility == ["read"] + except AttributeError: + return False + + +class SdkJSONEncoder(JSONEncoder): + """A JSON encoder that's capable of serializing datetime objects and bytes.""" + + def __init__(self, *args, exclude_readonly: bool = False, format: typing.Optional[str] = None, **kwargs): + super().__init__(*args, **kwargs) + self.exclude_readonly = exclude_readonly + self.format = format + + def default(self, o): # pylint: disable=too-many-return-statements + if _is_model(o): + if self.exclude_readonly: + readonly_props = [p._rest_name for p in o._attr_to_rest_field.values() if _is_readonly(p)] + return {k: v for k, v in o.items() if k not in readonly_props} + return dict(o.items()) + try: + return super(SdkJSONEncoder, self).default(o) + except TypeError: + if isinstance(o, _Null): + return None + if isinstance(o, decimal.Decimal): + return float(o) + if isinstance(o, (bytes, bytearray)): + return _serialize_bytes(o, self.format) + try: + # First try datetime.datetime + return _serialize_datetime(o, self.format) + except AttributeError: + pass + # Last, try datetime.timedelta + try: + return _timedelta_as_isostr(o) + except AttributeError: + # This will be raised when it hits value.total_seconds in the method above + pass + return super(SdkJSONEncoder, self).default(o) + + +_VALID_DATE = re.compile(r"\d{4}[-]\d{2}[-]\d{2}T\d{2}:\d{2}:\d{2}" + r"\.?\d*Z?[-+]?[\d{2}]?:?[\d{2}]?") +_VALID_RFC7231 = re.compile( + r"(Mon|Tue|Wed|Thu|Fri|Sat|Sun),\s\d{2}\s" + r"(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s\d{4}\s\d{2}:\d{2}:\d{2}\sGMT" +) + +_ARRAY_ENCODE_MAPPING = { + "pipeDelimited": "|", + "spaceDelimited": " ", + "commaDelimited": ",", + "newlineDelimited": "\n", +} + + +def _deserialize_array_encoded(delimit: str, attr): + if isinstance(attr, str): + if attr == "": + return [] + return attr.split(delimit) + return attr + + +def _deserialize_datetime(attr: typing.Union[str, datetime]) -> datetime: + """Deserialize ISO-8601 formatted string into Datetime object. + + :param str attr: response string to be deserialized. + :rtype: ~datetime.datetime + :returns: The datetime object from that input + """ + if isinstance(attr, datetime): + # i'm already deserialized + return attr + attr = attr.upper() + match = _VALID_DATE.match(attr) + if not match: + raise ValueError("Invalid datetime string: " + attr) + + check_decimal = attr.split(".") + if len(check_decimal) > 1: + decimal_str = "" + for digit in check_decimal[1]: + if digit.isdigit(): + decimal_str += digit + else: + break + if len(decimal_str) > 6: + attr = attr.replace(decimal_str, decimal_str[0:6]) + + date_obj = isodate.parse_datetime(attr) + test_utc = date_obj.utctimetuple() + if test_utc.tm_year > 9999 or test_utc.tm_year < 1: + raise OverflowError("Hit max or min date") + return date_obj # type: ignore[no-any-return] + + +def _deserialize_datetime_rfc7231(attr: typing.Union[str, datetime]) -> datetime: + """Deserialize RFC7231 formatted string into Datetime object. + + :param str attr: response string to be deserialized. + :rtype: ~datetime.datetime + :returns: The datetime object from that input + """ + if isinstance(attr, datetime): + # i'm already deserialized + return attr + match = _VALID_RFC7231.match(attr) + if not match: + raise ValueError("Invalid datetime string: " + attr) + + return email.utils.parsedate_to_datetime(attr) + + +def _deserialize_datetime_unix_timestamp(attr: typing.Union[float, datetime]) -> datetime: + """Deserialize unix timestamp into Datetime object. + + :param str attr: response string to be deserialized. + :rtype: ~datetime.datetime + :returns: The datetime object from that input + """ + if isinstance(attr, datetime): + # i'm already deserialized + return attr + return datetime.fromtimestamp(attr, TZ_UTC) + + +def _deserialize_date(attr: typing.Union[str, date]) -> date: + """Deserialize ISO-8601 formatted string into Date object. + :param str attr: response string to be deserialized. + :rtype: date + :returns: The date object from that input + """ + # This must NOT use defaultmonth/defaultday. Using None ensure this raises an exception. + if isinstance(attr, date): + return attr + return isodate.parse_date(attr, defaultmonth=None, defaultday=None) # type: ignore + + +def _deserialize_time(attr: typing.Union[str, time]) -> time: + """Deserialize ISO-8601 formatted string into time object. + + :param str attr: response string to be deserialized. + :rtype: datetime.time + :returns: The time object from that input + """ + if isinstance(attr, time): + return attr + return isodate.parse_time(attr) # type: ignore[no-any-return] + + +def _deserialize_bytes(attr): + if isinstance(attr, (bytes, bytearray)): + return attr + return bytes(base64.b64decode(attr)) + + +def _deserialize_bytes_base64(attr): + if isinstance(attr, (bytes, bytearray)): + return attr + padding = "=" * (3 - (len(attr) + 3) % 4) # type: ignore + attr = attr + padding # type: ignore + encoded = attr.replace("-", "+").replace("_", "/") + return bytes(base64.b64decode(encoded)) + + +def _deserialize_duration(attr): + if isinstance(attr, timedelta): + return attr + return isodate.parse_duration(attr) + + +def _deserialize_decimal(attr): + if isinstance(attr, decimal.Decimal): + return attr + return decimal.Decimal(str(attr)) + + +def _deserialize_int_as_str(attr): + if isinstance(attr, int): + return attr + return int(attr) + + +_DESERIALIZE_MAPPING = { + datetime: _deserialize_datetime, + date: _deserialize_date, + time: _deserialize_time, + bytes: _deserialize_bytes, + bytearray: _deserialize_bytes, + timedelta: _deserialize_duration, + typing.Any: lambda x: x, + decimal.Decimal: _deserialize_decimal, +} + +_DESERIALIZE_MAPPING_WITHFORMAT = { + "rfc3339": _deserialize_datetime, + "rfc7231": _deserialize_datetime_rfc7231, + "unix-timestamp": _deserialize_datetime_unix_timestamp, + "base64": _deserialize_bytes, + "base64url": _deserialize_bytes_base64, +} + + +def get_deserializer(annotation: typing.Any, rf: typing.Optional["_RestField"] = None): + if annotation is int and rf and rf._format == "str": + return _deserialize_int_as_str + if annotation is str and rf and rf._format in _ARRAY_ENCODE_MAPPING: + return functools.partial(_deserialize_array_encoded, _ARRAY_ENCODE_MAPPING[rf._format]) + if rf and rf._format: + return _DESERIALIZE_MAPPING_WITHFORMAT.get(rf._format) + return _DESERIALIZE_MAPPING.get(annotation) # pyright: ignore + + +def _get_type_alias_type(module_name: str, alias_name: str): + types = { + k: v + for k, v in sys.modules[module_name].__dict__.items() + if isinstance(v, typing._GenericAlias) # type: ignore + } + if alias_name not in types: + return alias_name + return types[alias_name] + + +def _get_model(module_name: str, model_name: str): + models = {k: v for k, v in sys.modules[module_name].__dict__.items() if isinstance(v, type)} + module_end = module_name.rsplit(".", 1)[0] + models.update({k: v for k, v in sys.modules[module_end].__dict__.items() if isinstance(v, type)}) + if isinstance(model_name, str): + model_name = model_name.split(".")[-1] + if model_name not in models: + return model_name + return models[model_name] + + +_UNSET = object() + + +class _MyMutableMapping(MutableMapping[str, typing.Any]): + def __init__(self, data: dict[str, typing.Any]) -> None: + self._data = data + + def __contains__(self, key: typing.Any) -> bool: + return key in self._data + + def __getitem__(self, key: str) -> typing.Any: + # If this key has been deserialized (for mutable types), we need to handle serialization + if hasattr(self, "_attr_to_rest_field"): + cache_attr = f"_deserialized_{key}" + if hasattr(self, cache_attr): + rf = _get_rest_field(getattr(self, "_attr_to_rest_field"), key) + if rf: + value = self._data.get(key) + if isinstance(value, (dict, list, set)): + # For mutable types, serialize and return + # But also update _data with serialized form and clear flag + # so mutations via this returned value affect _data + serialized = _serialize(value, rf._format) + # If serialized form is same type (no transformation needed), + # return _data directly so mutations work + if isinstance(serialized, type(value)) and serialized == value: + return self._data.get(key) + # Otherwise return serialized copy and clear flag + try: + object.__delattr__(self, cache_attr) + except AttributeError: + pass + # Store serialized form back + self._data[key] = serialized + return serialized + return self._data.__getitem__(key) + + def __setitem__(self, key: str, value: typing.Any) -> None: + # Clear any cached deserialized value when setting through dictionary access + cache_attr = f"_deserialized_{key}" + try: + object.__delattr__(self, cache_attr) + except AttributeError: + pass + self._data.__setitem__(key, value) + + def __delitem__(self, key: str) -> None: + self._data.__delitem__(key) + + def __iter__(self) -> typing.Iterator[typing.Any]: + return self._data.__iter__() + + def __len__(self) -> int: + return self._data.__len__() + + def __ne__(self, other: typing.Any) -> bool: + return not self.__eq__(other) + + def keys(self) -> typing.KeysView[str]: + """ + :returns: a set-like object providing a view on D's keys + :rtype: ~typing.KeysView + """ + return self._data.keys() + + def values(self) -> typing.ValuesView[typing.Any]: + """ + :returns: an object providing a view on D's values + :rtype: ~typing.ValuesView + """ + return self._data.values() + + def items(self) -> typing.ItemsView[str, typing.Any]: + """ + :returns: set-like object providing a view on D's items + :rtype: ~typing.ItemsView + """ + return self._data.items() + + def get(self, key: str, default: typing.Any = None) -> typing.Any: + """ + Get the value for key if key is in the dictionary, else default. + :param str key: The key to look up. + :param any default: The value to return if key is not in the dictionary. Defaults to None + :returns: D[k] if k in D, else d. + :rtype: any + """ + try: + return self[key] + except KeyError: + return default + + @typing.overload + def pop(self, key: str) -> typing.Any: ... # pylint: disable=arguments-differ + + @typing.overload + def pop(self, key: str, default: _T) -> _T: ... # pylint: disable=signature-differs + + @typing.overload + def pop(self, key: str, default: typing.Any) -> typing.Any: ... # pylint: disable=signature-differs + + def pop(self, key: str, default: typing.Any = _UNSET) -> typing.Any: + """ + Removes specified key and return the corresponding value. + :param str key: The key to pop. + :param any default: The value to return if key is not in the dictionary + :returns: The value corresponding to the key. + :rtype: any + :raises KeyError: If key is not found and default is not given. + """ + if default is _UNSET: + return self._data.pop(key) + return self._data.pop(key, default) + + def popitem(self) -> tuple[str, typing.Any]: + """ + Removes and returns some (key, value) pair + :returns: The (key, value) pair. + :rtype: tuple + :raises KeyError: if D is empty. + """ + return self._data.popitem() + + def clear(self) -> None: + """ + Remove all items from D. + """ + self._data.clear() + + def update(self, *args: typing.Any, **kwargs: typing.Any) -> None: # pylint: disable=arguments-differ + """ + Updates D from mapping/iterable E and F. + :param any args: Either a mapping object or an iterable of key-value pairs. + """ + self._data.update(*args, **kwargs) + + @typing.overload + def setdefault(self, key: str, default: None = None) -> None: ... + + @typing.overload + def setdefault(self, key: str, default: typing.Any) -> typing.Any: ... # pylint: disable=signature-differs + + def setdefault(self, key: str, default: typing.Any = _UNSET) -> typing.Any: + """ + Same as calling D.get(k, d), and setting D[k]=d if k not found + :param str key: The key to look up. + :param any default: The value to set if key is not in the dictionary + :returns: D[k] if k in D, else d. + :rtype: any + """ + if default is _UNSET: + return self._data.setdefault(key) + return self._data.setdefault(key, default) + + def __eq__(self, other: typing.Any) -> bool: + try: + other_model = self.__class__(other) + except Exception: + return False + return self._data == other_model._data + + def __repr__(self) -> str: + return str(self._data) + + +def _is_model(obj: typing.Any) -> bool: + return getattr(obj, "_is_model", False) + + +def _serialize(o, format: typing.Optional[str] = None): # pylint: disable=too-many-return-statements + if isinstance(o, list): + if format in _ARRAY_ENCODE_MAPPING and all(isinstance(x, str) for x in o): + return _ARRAY_ENCODE_MAPPING[format].join(o) + return [_serialize(x, format) for x in o] + if isinstance(o, dict): + return {k: _serialize(v, format) for k, v in o.items()} + if isinstance(o, set): + return {_serialize(x, format) for x in o} + if isinstance(o, tuple): + return tuple(_serialize(x, format) for x in o) + if isinstance(o, (bytes, bytearray)): + return _serialize_bytes(o, format) + if isinstance(o, decimal.Decimal): + return float(o) + if isinstance(o, enum.Enum): + return o.value + if isinstance(o, int): + if format == "str": + return str(o) + return o + try: + # First try datetime.datetime + return _serialize_datetime(o, format) + except AttributeError: + pass + # Last, try datetime.timedelta + try: + return _timedelta_as_isostr(o) + except AttributeError: + # This will be raised when it hits value.total_seconds in the method above + pass + return o + + +def _get_rest_field(attr_to_rest_field: dict[str, "_RestField"], rest_name: str) -> typing.Optional["_RestField"]: + try: + return next(rf for rf in attr_to_rest_field.values() if rf._rest_name == rest_name) + except StopIteration: + return None + + +def _create_value(rf: typing.Optional["_RestField"], value: typing.Any) -> typing.Any: + if not rf: + return _serialize(value, None) + if rf._is_multipart_file_input: + return value + if rf._is_model: + return _deserialize(rf._type, value) + if isinstance(value, ET.Element): + value = _deserialize(rf._type, value) + return _serialize(value, rf._format) + + +class Model(_MyMutableMapping): + _is_model = True + # label whether current class's _attr_to_rest_field has been calculated + # could not see _attr_to_rest_field directly because subclass inherits it from parent class + _calculated: set[str] = set() + + def __init__(self, *args: typing.Any, **kwargs: typing.Any) -> None: + class_name = self.__class__.__name__ + if len(args) > 1: + raise TypeError(f"{class_name}.__init__() takes 2 positional arguments but {len(args) + 1} were given") + dict_to_pass = { + rest_field._rest_name: rest_field._default + for rest_field in self._attr_to_rest_field.values() + if rest_field._default is not _UNSET + } + if args: # pylint: disable=too-many-nested-blocks + if isinstance(args[0], ET.Element): + existed_attr_keys = [] + model_meta = getattr(self, "_xml", {}) + + for rf in self._attr_to_rest_field.values(): + prop_meta = getattr(rf, "_xml", {}) + xml_name = prop_meta.get("name", rf._rest_name) + xml_ns = prop_meta.get("ns", model_meta.get("ns", None)) + if xml_ns: + xml_name = "{" + xml_ns + "}" + xml_name + + # attribute + if prop_meta.get("attribute", False) and args[0].get(xml_name) is not None: + existed_attr_keys.append(xml_name) + dict_to_pass[rf._rest_name] = _deserialize(rf._type, args[0].get(xml_name)) + continue + + # unwrapped element is array + if prop_meta.get("unwrapped", False): + # unwrapped array could either use prop items meta/prop meta + if prop_meta.get("itemsName"): + xml_name = prop_meta.get("itemsName") + xml_ns = prop_meta.get("itemNs") + if xml_ns: + xml_name = "{" + xml_ns + "}" + xml_name + items = args[0].findall(xml_name) # pyright: ignore + if len(items) > 0: + existed_attr_keys.append(xml_name) + dict_to_pass[rf._rest_name] = _deserialize(rf._type, items) + continue + + # text element is primitive type + if prop_meta.get("text", False): + if args[0].text is not None: + dict_to_pass[rf._rest_name] = _deserialize(rf._type, args[0].text) + continue + + # wrapped element could be normal property or array, it should only have one element + item = args[0].find(xml_name) + if item is not None: + existed_attr_keys.append(xml_name) + dict_to_pass[rf._rest_name] = _deserialize(rf._type, item) + + # rest thing is additional properties + for e in args[0]: + if e.tag not in existed_attr_keys: + dict_to_pass[e.tag] = _convert_element(e) + else: + dict_to_pass.update( + {k: _create_value(_get_rest_field(self._attr_to_rest_field, k), v) for k, v in args[0].items()} + ) + else: + non_attr_kwargs = [k for k in kwargs if k not in self._attr_to_rest_field] + if non_attr_kwargs: + # actual type errors only throw the first wrong keyword arg they see, so following that. + raise TypeError(f"{class_name}.__init__() got an unexpected keyword argument '{non_attr_kwargs[0]}'") + dict_to_pass.update( + { + self._attr_to_rest_field[k]._rest_name: _create_value(self._attr_to_rest_field[k], v) + for k, v in kwargs.items() + if v is not None + } + ) + super().__init__(dict_to_pass) + + def copy(self) -> "Model": + return Model(self.__dict__) + + def __new__(cls, *args: typing.Any, **kwargs: typing.Any) -> Self: + if f"{cls.__module__}.{cls.__qualname__}" not in cls._calculated: + # we know the last nine classes in mro are going to be 'Model', '_MyMutableMapping', 'MutableMapping', + # 'Mapping', 'Collection', 'Sized', 'Iterable', 'Container' and 'object' + mros = cls.__mro__[:-9][::-1] # ignore parents, and reverse the mro order + attr_to_rest_field: dict[str, _RestField] = { # map attribute name to rest_field property + k: v for mro_class in mros for k, v in mro_class.__dict__.items() if k[0] != "_" and hasattr(v, "_type") + } + annotations = { + k: v + for mro_class in mros + if hasattr(mro_class, "__annotations__") + for k, v in mro_class.__annotations__.items() + } + for attr, rf in attr_to_rest_field.items(): + rf._module = cls.__module__ + if not rf._type: + rf._type = rf._get_deserialize_callable_from_annotation(annotations.get(attr, None)) + if not rf._rest_name_input: + rf._rest_name_input = attr + cls._attr_to_rest_field: dict[str, _RestField] = dict(attr_to_rest_field.items()) + cls._calculated.add(f"{cls.__module__}.{cls.__qualname__}") + + return super().__new__(cls) + + def __init_subclass__(cls, discriminator: typing.Optional[str] = None) -> None: + for base in cls.__bases__: + if hasattr(base, "__mapping__"): + base.__mapping__[discriminator or cls.__name__] = cls # type: ignore + + @classmethod + def _get_discriminator(cls, exist_discriminators) -> typing.Optional["_RestField"]: + for v in cls.__dict__.values(): + if isinstance(v, _RestField) and v._is_discriminator and v._rest_name not in exist_discriminators: + return v + return None + + @classmethod + def _deserialize(cls, data, exist_discriminators): + if not hasattr(cls, "__mapping__"): + return cls(data) + discriminator = cls._get_discriminator(exist_discriminators) + if discriminator is None: + return cls(data) + exist_discriminators.append(discriminator._rest_name) + if isinstance(data, ET.Element): + model_meta = getattr(cls, "_xml", {}) + prop_meta = getattr(discriminator, "_xml", {}) + xml_name = prop_meta.get("name", discriminator._rest_name) + xml_ns = prop_meta.get("ns", model_meta.get("ns", None)) + if xml_ns: + xml_name = "{" + xml_ns + "}" + xml_name + + if data.get(xml_name) is not None: + discriminator_value = data.get(xml_name) + else: + discriminator_value = data.find(xml_name).text # pyright: ignore + else: + discriminator_value = data.get(discriminator._rest_name) + mapped_cls = cls.__mapping__.get(discriminator_value, cls) # pyright: ignore # pylint: disable=no-member + return mapped_cls._deserialize(data, exist_discriminators) + + def as_dict(self, *, exclude_readonly: bool = False) -> dict[str, typing.Any]: + """Return a dict that can be turned into json using json.dump. + + :keyword bool exclude_readonly: Whether to remove the readonly properties. + :returns: A dict JSON compatible object + :rtype: dict + """ + + result = {} + readonly_props = [] + if exclude_readonly: + readonly_props = [p._rest_name for p in self._attr_to_rest_field.values() if _is_readonly(p)] + for k, v in self.items(): + if exclude_readonly and k in readonly_props: # pyright: ignore + continue + is_multipart_file_input = False + try: + is_multipart_file_input = next( + rf for rf in self._attr_to_rest_field.values() if rf._rest_name == k + )._is_multipart_file_input + except StopIteration: + pass + result[k] = v if is_multipart_file_input else Model._as_dict_value(v, exclude_readonly=exclude_readonly) + return result + + @staticmethod + def _as_dict_value(v: typing.Any, exclude_readonly: bool = False) -> typing.Any: + if v is None or isinstance(v, _Null): + return None + if isinstance(v, (list, tuple, set)): + return type(v)(Model._as_dict_value(x, exclude_readonly=exclude_readonly) for x in v) + if isinstance(v, dict): + return {dk: Model._as_dict_value(dv, exclude_readonly=exclude_readonly) for dk, dv in v.items()} + return v.as_dict(exclude_readonly=exclude_readonly) if hasattr(v, "as_dict") else v + + +def _deserialize_model(model_deserializer: typing.Optional[typing.Callable], obj): + if _is_model(obj): + return obj + return _deserialize(model_deserializer, obj) + + +def _deserialize_with_optional(if_obj_deserializer: typing.Optional[typing.Callable], obj): + if obj is None: + return obj + return _deserialize_with_callable(if_obj_deserializer, obj) + + +def _deserialize_with_union(deserializers, obj): + for deserializer in deserializers: + try: + return _deserialize(deserializer, obj) + except DeserializationError: + pass + raise DeserializationError() + + +def _deserialize_dict( + value_deserializer: typing.Optional[typing.Callable], + module: typing.Optional[str], + obj: dict[typing.Any, typing.Any], +): + if obj is None: + return obj + if isinstance(obj, ET.Element): + obj = {child.tag: child for child in obj} + return {k: _deserialize(value_deserializer, v, module) for k, v in obj.items()} + + +def _deserialize_multiple_sequence( + entry_deserializers: list[typing.Optional[typing.Callable]], + module: typing.Optional[str], + obj, +): + if obj is None: + return obj + return type(obj)(_deserialize(deserializer, entry, module) for entry, deserializer in zip(obj, entry_deserializers)) + + +def _is_array_encoded_deserializer(deserializer: functools.partial) -> bool: + return ( + isinstance(deserializer, functools.partial) + and isinstance(deserializer.args[0], functools.partial) + and deserializer.args[0].func == _deserialize_array_encoded # pylint: disable=comparison-with-callable + ) + + +def _deserialize_sequence( + deserializer: typing.Optional[typing.Callable], + module: typing.Optional[str], + obj, +): + if obj is None: + return obj + if isinstance(obj, ET.Element): + obj = list(obj) + + # encoded string may be deserialized to sequence + if isinstance(obj, str) and isinstance(deserializer, functools.partial): + # for list[str] + if _is_array_encoded_deserializer(deserializer): + return deserializer(obj) + + # for list[Union[...]] + if isinstance(deserializer.args[0], list): + for sub_deserializer in deserializer.args[0]: + if _is_array_encoded_deserializer(sub_deserializer): + return sub_deserializer(obj) + + return type(obj)(_deserialize(deserializer, entry, module) for entry in obj) + + +def _sorted_annotations(types: list[typing.Any]) -> list[typing.Any]: + return sorted( + types, + key=lambda x: hasattr(x, "__name__") and x.__name__.lower() in ("str", "float", "int", "bool"), + ) + + +def _get_deserialize_callable_from_annotation( # pylint: disable=too-many-return-statements, too-many-statements, too-many-branches + annotation: typing.Any, + module: typing.Optional[str], + rf: typing.Optional["_RestField"] = None, +) -> typing.Optional[typing.Callable[[typing.Any], typing.Any]]: + if not annotation: + return None + + # is it a type alias? + if isinstance(annotation, str): + if module is not None: + annotation = _get_type_alias_type(module, annotation) + + # is it a forward ref / in quotes? + if isinstance(annotation, (str, typing.ForwardRef)): + try: + model_name = annotation.__forward_arg__ # type: ignore + except AttributeError: + model_name = annotation + if module is not None: + annotation = _get_model(module, model_name) # type: ignore + + try: + if module and _is_model(annotation): + if rf: + rf._is_model = True + + return functools.partial(_deserialize_model, annotation) # pyright: ignore + except Exception: + pass + + # is it a literal? + try: + if annotation.__origin__ is typing.Literal: # pyright: ignore + return None + except AttributeError: + pass + + # is it optional? + try: + if any(a is _NONE_TYPE for a in annotation.__args__): # pyright: ignore + if len(annotation.__args__) <= 2: # pyright: ignore + if_obj_deserializer = _get_deserialize_callable_from_annotation( + next(a for a in annotation.__args__ if a is not _NONE_TYPE), module, rf # pyright: ignore + ) + + return functools.partial(_deserialize_with_optional, if_obj_deserializer) + # the type is Optional[Union[...]], we need to remove the None type from the Union + annotation_copy = copy.copy(annotation) + annotation_copy.__args__ = [a for a in annotation_copy.__args__ if a is not _NONE_TYPE] # pyright: ignore + return _get_deserialize_callable_from_annotation(annotation_copy, module, rf) + except AttributeError: + pass + + # is it union? + if getattr(annotation, "__origin__", None) is typing.Union: + # initial ordering is we make `string` the last deserialization option, because it is often them most generic + deserializers = [ + _get_deserialize_callable_from_annotation(arg, module, rf) + for arg in _sorted_annotations(annotation.__args__) # pyright: ignore + ] + + return functools.partial(_deserialize_with_union, deserializers) + + try: + annotation_name = ( + annotation.__name__ if hasattr(annotation, "__name__") else annotation._name # pyright: ignore + ) + if annotation_name.lower() == "dict": + value_deserializer = _get_deserialize_callable_from_annotation( + annotation.__args__[1], module, rf # pyright: ignore + ) + + return functools.partial( + _deserialize_dict, + value_deserializer, + module, + ) + except (AttributeError, IndexError): + pass + try: + annotation_name = ( + annotation.__name__ if hasattr(annotation, "__name__") else annotation._name # pyright: ignore + ) + if annotation_name.lower() in ["list", "set", "tuple", "sequence"]: + if len(annotation.__args__) > 1: # pyright: ignore + entry_deserializers = [ + _get_deserialize_callable_from_annotation(dt, module, rf) + for dt in annotation.__args__ # pyright: ignore + ] + return functools.partial(_deserialize_multiple_sequence, entry_deserializers, module) + deserializer = _get_deserialize_callable_from_annotation( + annotation.__args__[0], module, rf # pyright: ignore + ) + + return functools.partial(_deserialize_sequence, deserializer, module) + except (TypeError, IndexError, AttributeError, SyntaxError): + pass + + def _deserialize_default( + deserializer, + obj, + ): + if obj is None: + return obj + try: + return _deserialize_with_callable(deserializer, obj) + except Exception: + pass + return obj + + if get_deserializer(annotation, rf): + return functools.partial(_deserialize_default, get_deserializer(annotation, rf)) + + return functools.partial(_deserialize_default, annotation) + + +def _deserialize_with_callable( + deserializer: typing.Optional[typing.Callable[[typing.Any], typing.Any]], + value: typing.Any, +): # pylint: disable=too-many-return-statements + try: + if value is None or isinstance(value, _Null): + return None + if isinstance(value, ET.Element): + if deserializer is str: + return value.text or "" + if deserializer is int: + return int(value.text) if value.text else None + if deserializer is float: + return float(value.text) if value.text else None + if deserializer is bool: + return value.text == "true" if value.text else None + if deserializer is None: + return value + if deserializer in [int, float, bool]: + return deserializer(value) + if isinstance(deserializer, CaseInsensitiveEnumMeta): + try: + return deserializer(value) + except ValueError: + # for unknown value, return raw value + return value + if isinstance(deserializer, type) and issubclass(deserializer, Model): + return deserializer._deserialize(value, []) + return typing.cast(typing.Callable[[typing.Any], typing.Any], deserializer)(value) + except Exception as e: + raise DeserializationError() from e + + +def _deserialize( + deserializer: typing.Any, + value: typing.Any, + module: typing.Optional[str] = None, + rf: typing.Optional["_RestField"] = None, + format: typing.Optional[str] = None, +) -> typing.Any: + if isinstance(value, PipelineResponse): + value = value.http_response.json() + if rf is None and format: + rf = _RestField(format=format) + if not isinstance(deserializer, functools.partial): + deserializer = _get_deserialize_callable_from_annotation(deserializer, module, rf) + return _deserialize_with_callable(deserializer, value) + + +def _failsafe_deserialize( + deserializer: typing.Any, + response: HttpResponse, + module: typing.Optional[str] = None, + rf: typing.Optional["_RestField"] = None, + format: typing.Optional[str] = None, +) -> typing.Any: + try: + return _deserialize(deserializer, response.json(), module, rf, format) + except Exception: # pylint: disable=broad-except + _LOGGER.warning( + "Ran into a deserialization error. Ignoring since this is failsafe deserialization", exc_info=True + ) + return None + + +def _failsafe_deserialize_xml( + deserializer: typing.Any, + response: HttpResponse, +) -> typing.Any: + try: + return _deserialize_xml(deserializer, response.text()) + except Exception: # pylint: disable=broad-except + _LOGGER.warning( + "Ran into a deserialization error. Ignoring since this is failsafe deserialization", exc_info=True + ) + return None + + +class _RestField: + def __init__( + self, + *, + name: typing.Optional[str] = None, + type: typing.Optional[typing.Callable] = None, # pylint: disable=redefined-builtin + is_discriminator: bool = False, + visibility: typing.Optional[list[str]] = None, + default: typing.Any = _UNSET, + format: typing.Optional[str] = None, + is_multipart_file_input: bool = False, + xml: typing.Optional[dict[str, typing.Any]] = None, + ): + self._type = type + self._rest_name_input = name + self._module: typing.Optional[str] = None + self._is_discriminator = is_discriminator + self._visibility = visibility + self._is_model = False + self._default = default + self._format = format + self._is_multipart_file_input = is_multipart_file_input + self._xml = xml if xml is not None else {} + + @property + def _class_type(self) -> typing.Any: + result = getattr(self._type, "args", [None])[0] + # type may be wrapped by nested functools.partial so we need to check for that + if isinstance(result, functools.partial): + return getattr(result, "args", [None])[0] + return result + + @property + def _rest_name(self) -> str: + if self._rest_name_input is None: + raise ValueError("Rest name was never set") + return self._rest_name_input + + def __get__(self, obj: Model, type=None): # pylint: disable=redefined-builtin + # by this point, type and rest_name will have a value bc we default + # them in __new__ of the Model class + # Use _data.get() directly to avoid triggering __getitem__ which clears the cache + item = obj._data.get(self._rest_name) + if item is None: + return item + if self._is_model: + return item + + # For mutable types, we want mutations to directly affect _data + # Check if we've already deserialized this value + cache_attr = f"_deserialized_{self._rest_name}" + if hasattr(obj, cache_attr): + # Return the value from _data directly (it's been deserialized in place) + return obj._data.get(self._rest_name) + + deserialized = _deserialize(self._type, _serialize(item, self._format), rf=self) + + # For mutable types, store the deserialized value back in _data + # so mutations directly affect _data + if isinstance(deserialized, (dict, list, set)): + obj._data[self._rest_name] = deserialized + object.__setattr__(obj, cache_attr, True) # Mark as deserialized + return deserialized + + return deserialized + + def __set__(self, obj: Model, value) -> None: + # Clear the cached deserialized object when setting a new value + cache_attr = f"_deserialized_{self._rest_name}" + if hasattr(obj, cache_attr): + object.__delattr__(obj, cache_attr) + + if value is None: + # we want to wipe out entries if users set attr to None + try: + obj.__delitem__(self._rest_name) + except KeyError: + pass + return + if self._is_model: + if not _is_model(value): + value = _deserialize(self._type, value) + obj.__setitem__(self._rest_name, value) + return + obj.__setitem__(self._rest_name, _serialize(value, self._format)) + + def _get_deserialize_callable_from_annotation( + self, annotation: typing.Any + ) -> typing.Optional[typing.Callable[[typing.Any], typing.Any]]: + return _get_deserialize_callable_from_annotation(annotation, self._module, self) + + +def rest_field( + *, + name: typing.Optional[str] = None, + type: typing.Optional[typing.Callable] = None, # pylint: disable=redefined-builtin + visibility: typing.Optional[list[str]] = None, + default: typing.Any = _UNSET, + format: typing.Optional[str] = None, + is_multipart_file_input: bool = False, + xml: typing.Optional[dict[str, typing.Any]] = None, +) -> typing.Any: + return _RestField( + name=name, + type=type, + visibility=visibility, + default=default, + format=format, + is_multipart_file_input=is_multipart_file_input, + xml=xml, + ) + + +def rest_discriminator( + *, + name: typing.Optional[str] = None, + type: typing.Optional[typing.Callable] = None, # pylint: disable=redefined-builtin + visibility: typing.Optional[list[str]] = None, + xml: typing.Optional[dict[str, typing.Any]] = None, +) -> typing.Any: + return _RestField(name=name, type=type, is_discriminator=True, visibility=visibility, xml=xml) + + +def serialize_xml(model: Model, exclude_readonly: bool = False) -> str: + """Serialize a model to XML. + + :param Model model: The model to serialize. + :param bool exclude_readonly: Whether to exclude readonly properties. + :returns: The XML representation of the model. + :rtype: str + """ + return ET.tostring(_get_element(model, exclude_readonly), encoding="unicode") # type: ignore + + +def _get_element( + o: typing.Any, + exclude_readonly: bool = False, + parent_meta: typing.Optional[dict[str, typing.Any]] = None, + wrapped_element: typing.Optional[ET.Element] = None, +) -> typing.Union[ET.Element, list[ET.Element]]: + if _is_model(o): + model_meta = getattr(o, "_xml", {}) + + # if prop is a model, then use the prop element directly, else generate a wrapper of model + if wrapped_element is None: + wrapped_element = _create_xml_element( + model_meta.get("name", o.__class__.__name__), + model_meta.get("prefix"), + model_meta.get("ns"), + ) + + readonly_props = [] + if exclude_readonly: + readonly_props = [p._rest_name for p in o._attr_to_rest_field.values() if _is_readonly(p)] + + for k, v in o.items(): + # do not serialize readonly properties + if exclude_readonly and k in readonly_props: + continue + + prop_rest_field = _get_rest_field(o._attr_to_rest_field, k) + if prop_rest_field: + prop_meta = getattr(prop_rest_field, "_xml").copy() + # use the wire name as xml name if no specific name is set + if prop_meta.get("name") is None: + prop_meta["name"] = k + else: + # additional properties will not have rest field, use the wire name as xml name + prop_meta = {"name": k} + + # if no ns for prop, use model's + if prop_meta.get("ns") is None and model_meta.get("ns"): + prop_meta["ns"] = model_meta.get("ns") + prop_meta["prefix"] = model_meta.get("prefix") + + if prop_meta.get("unwrapped", False): + # unwrapped could only set on array + wrapped_element.extend(_get_element(v, exclude_readonly, prop_meta)) + elif prop_meta.get("text", False): + # text could only set on primitive type + wrapped_element.text = _get_primitive_type_value(v) + elif prop_meta.get("attribute", False): + xml_name = prop_meta.get("name", k) + if prop_meta.get("ns"): + ET.register_namespace(prop_meta.get("prefix"), prop_meta.get("ns")) # pyright: ignore + xml_name = "{" + prop_meta.get("ns") + "}" + xml_name # pyright: ignore + # attribute should be primitive type + wrapped_element.set(xml_name, _get_primitive_type_value(v)) + else: + # other wrapped prop element + wrapped_element.append(_get_wrapped_element(v, exclude_readonly, prop_meta)) + return wrapped_element + if isinstance(o, list): + return [_get_element(x, exclude_readonly, parent_meta) for x in o] # type: ignore + if isinstance(o, dict): + result = [] + for k, v in o.items(): + result.append( + _get_wrapped_element( + v, + exclude_readonly, + { + "name": k, + "ns": parent_meta.get("ns") if parent_meta else None, + "prefix": parent_meta.get("prefix") if parent_meta else None, + }, + ) + ) + return result + + # primitive case need to create element based on parent_meta + if parent_meta: + return _get_wrapped_element( + o, + exclude_readonly, + { + "name": parent_meta.get("itemsName", parent_meta.get("name")), + "prefix": parent_meta.get("itemsPrefix", parent_meta.get("prefix")), + "ns": parent_meta.get("itemsNs", parent_meta.get("ns")), + }, + ) + + raise ValueError("Could not serialize value into xml: " + o) + + +def _get_wrapped_element( + v: typing.Any, + exclude_readonly: bool, + meta: typing.Optional[dict[str, typing.Any]], +) -> ET.Element: + wrapped_element = _create_xml_element( + meta.get("name") if meta else None, meta.get("prefix") if meta else None, meta.get("ns") if meta else None + ) + if isinstance(v, (dict, list)): + wrapped_element.extend(_get_element(v, exclude_readonly, meta)) + elif _is_model(v): + _get_element(v, exclude_readonly, meta, wrapped_element) + else: + wrapped_element.text = _get_primitive_type_value(v) + return wrapped_element # type: ignore[no-any-return] + + +def _get_primitive_type_value(v) -> str: + if v is True: + return "true" + if v is False: + return "false" + if isinstance(v, _Null): + return "" + return str(v) + + +def _create_xml_element( + tag: typing.Any, prefix: typing.Optional[str] = None, ns: typing.Optional[str] = None +) -> ET.Element: + if prefix and ns: + ET.register_namespace(prefix, ns) + if ns: + return ET.Element("{" + ns + "}" + tag) + return ET.Element(tag) + + +def _deserialize_xml( + deserializer: typing.Any, + value: str, +) -> typing.Any: + element = ET.fromstring(value) # nosec + return _deserialize(deserializer, element) + + +def _convert_element(e: ET.Element): + # dict case + if len(e.attrib) > 0 or len({child.tag for child in e}) > 1: + dict_result: dict[str, typing.Any] = {} + for child in e: + if dict_result.get(child.tag) is not None: + if isinstance(dict_result[child.tag], list): + dict_result[child.tag].append(_convert_element(child)) + else: + dict_result[child.tag] = [dict_result[child.tag], _convert_element(child)] + else: + dict_result[child.tag] = _convert_element(child) + dict_result.update(e.attrib) + return dict_result + # array case + if len(e) > 0: + array_result: list[typing.Any] = [] + for child in e: + array_result.append(_convert_element(child)) + return array_result + # primitive case + return e.text diff --git a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/azure/mgmt/postgresqlflexibleservers/_utils/serialization.py b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/azure/mgmt/postgresqlflexibleservers/_utils/serialization.py index ff543ed937ff..81ec1de5922b 100644 --- a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/azure/mgmt/postgresqlflexibleservers/_utils/serialization.py +++ b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/azure/mgmt/postgresqlflexibleservers/_utils/serialization.py @@ -3,7 +3,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -821,13 +821,20 @@ def serialize_basic(cls, data, data_type, **kwargs): :param str data_type: Type of object in the iterable. :rtype: str, int, float, bool :return: serialized object + :raises TypeError: raise if data_type is not one of str, int, float, bool. """ custom_serializer = cls._get_custom_serializers(data_type, **kwargs) if custom_serializer: return custom_serializer(data) if data_type == "str": return cls.serialize_unicode(data) - return eval(data_type)(data) # nosec # pylint: disable=eval-used + if data_type == "int": + return int(data) + if data_type == "float": + return float(data) + if data_type == "bool": + return bool(data) + raise TypeError("Unknown basic data type: {}".format(data_type)) @classmethod def serialize_unicode(cls, data): @@ -1757,7 +1764,7 @@ def deserialize_basic(self, attr, data_type): # pylint: disable=too-many-return :param str data_type: deserialization data type. :return: Deserialized basic type. :rtype: str, int, float or bool - :raises TypeError: if string format is not valid. + :raises TypeError: if string format is not valid or data_type is not one of str, int, float, bool. """ # If we're here, data is supposed to be a basic type. # If it's still an XML node, take the text @@ -1783,7 +1790,11 @@ def deserialize_basic(self, attr, data_type): # pylint: disable=too-many-return if data_type == "str": return self.deserialize_unicode(attr) - return eval(data_type)(attr) # nosec # pylint: disable=eval-used + if data_type == "int": + return int(attr) + if data_type == "float": + return float(attr) + raise TypeError("Unknown basic data type: {}".format(data_type)) @staticmethod def deserialize_unicode(data): diff --git a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/azure/mgmt/postgresqlflexibleservers/_validation.py b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/azure/mgmt/postgresqlflexibleservers/_validation.py new file mode 100644 index 000000000000..f5af3a4eb8a2 --- /dev/null +++ b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/azure/mgmt/postgresqlflexibleservers/_validation.py @@ -0,0 +1,66 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import functools + + +def api_version_validation(**kwargs): + params_added_on = kwargs.pop("params_added_on", {}) + method_added_on = kwargs.pop("method_added_on", "") + api_versions_list = kwargs.pop("api_versions_list", []) + + def _index_with_default(value: str, default: int = -1) -> int: + """Get the index of value in lst, or return default if not found. + + :param value: The value to search for in the api_versions_list. + :type value: str + :param default: The default value to return if the value is not found. + :type default: int + :return: The index of the value in the list, or the default value if not found. + :rtype: int + """ + try: + return api_versions_list.index(value) + except ValueError: + return default + + def decorator(func): + @functools.wraps(func) + def wrapper(*args, **kwargs): + try: + # this assumes the client has an _api_version attribute + client = args[0] + client_api_version = client._config.api_version # pylint: disable=protected-access + except AttributeError: + return func(*args, **kwargs) + + if _index_with_default(method_added_on) > _index_with_default(client_api_version): + raise ValueError( + f"'{func.__name__}' is not available in API version " + f"{client_api_version}. Pass service API version {method_added_on} or newer to your client." + ) + + unsupported = { + parameter: api_version + for api_version, parameters in params_added_on.items() + for parameter in parameters + if parameter in kwargs and _index_with_default(api_version) > _index_with_default(client_api_version) + } + if unsupported: + raise ValueError( + "".join( + [ + f"'{param}' is not available in API version {client_api_version}. " + f"Use service API version {version} or newer.\n" + for param, version in unsupported.items() + ] + ) + ) + return func(*args, **kwargs) + + return wrapper + + return decorator diff --git a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/azure/mgmt/postgresqlflexibleservers/_version.py b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/azure/mgmt/postgresqlflexibleservers/_version.py index 48944bf3938a..fd5e9189cf06 100644 --- a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/azure/mgmt/postgresqlflexibleservers/_version.py +++ b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/azure/mgmt/postgresqlflexibleservers/_version.py @@ -2,8 +2,8 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "2.0.0" +VERSION = "3.0.0b1" diff --git a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/azure/mgmt/postgresqlflexibleservers/aio/__init__.py b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/azure/mgmt/postgresqlflexibleservers/aio/__init__.py index 8a0842526bc9..56b391f6ff1d 100644 --- a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/azure/mgmt/postgresqlflexibleservers/aio/__init__.py +++ b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/azure/mgmt/postgresqlflexibleservers/aio/__init__.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- # pylint: disable=wrong-import-position @@ -12,7 +12,7 @@ if TYPE_CHECKING: from ._patch import * # pylint: disable=unused-wildcard-import -from ._postgre_sql_management_client import PostgreSQLManagementClient # type: ignore +from ._client import PostgreSQLManagementClient # type: ignore try: from ._patch import __all__ as _patch_all diff --git a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/azure/mgmt/postgresqlflexibleservers/aio/_postgre_sql_management_client.py b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/azure/mgmt/postgresqlflexibleservers/aio/_client.py similarity index 93% rename from sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/azure/mgmt/postgresqlflexibleservers/aio/_postgre_sql_management_client.py rename to sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/azure/mgmt/postgresqlflexibleservers/aio/_client.py index 8ad880fe7ccb..b249ec57b560 100644 --- a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/azure/mgmt/postgresqlflexibleservers/aio/_postgre_sql_management_client.py +++ b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/azure/mgmt/postgresqlflexibleservers/aio/_client.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -17,7 +17,6 @@ from azure.mgmt.core.policies import AsyncARMAutoResourceProviderRegistrationPolicy from azure.mgmt.core.tools import get_arm_endpoints -from .. import models as _models from .._utils.serialization import Deserializer, Serializer from ._configuration import PostgreSQLManagementClientConfiguration from .operations import ( @@ -57,9 +56,43 @@ class PostgreSQLManagementClient: # pylint: disable=too-many-instance-attribute network configuration, security alert policies, log files and configurations with new business model. + :ivar operations: Operations operations + :vartype operations: azure.mgmt.postgresqlflexibleservers.aio.operations.Operations + :ivar migrations: MigrationsOperations operations + :vartype migrations: azure.mgmt.postgresqlflexibleservers.aio.operations.MigrationsOperations + :ivar servers: ServersOperations operations + :vartype servers: azure.mgmt.postgresqlflexibleservers.aio.operations.ServersOperations + :ivar configurations: ConfigurationsOperations operations + :vartype configurations: + azure.mgmt.postgresqlflexibleservers.aio.operations.ConfigurationsOperations + :ivar databases: DatabasesOperations operations + :vartype databases: azure.mgmt.postgresqlflexibleservers.aio.operations.DatabasesOperations + :ivar firewall_rules: FirewallRulesOperations operations + :vartype firewall_rules: + azure.mgmt.postgresqlflexibleservers.aio.operations.FirewallRulesOperations + :ivar private_endpoint_connections: PrivateEndpointConnectionsOperations operations + :vartype private_endpoint_connections: + azure.mgmt.postgresqlflexibleservers.aio.operations.PrivateEndpointConnectionsOperations + :ivar private_link_resources: PrivateLinkResourcesOperations operations + :vartype private_link_resources: + azure.mgmt.postgresqlflexibleservers.aio.operations.PrivateLinkResourcesOperations + :ivar virtual_endpoints: VirtualEndpointsOperations operations + :vartype virtual_endpoints: + azure.mgmt.postgresqlflexibleservers.aio.operations.VirtualEndpointsOperations :ivar administrators_microsoft_entra: AdministratorsMicrosoftEntraOperations operations :vartype administrators_microsoft_entra: azure.mgmt.postgresqlflexibleservers.aio.operations.AdministratorsMicrosoftEntraOperations + :ivar capabilities_by_server: CapabilitiesByServerOperations operations + :vartype capabilities_by_server: + azure.mgmt.postgresqlflexibleservers.aio.operations.CapabilitiesByServerOperations + :ivar captured_logs: CapturedLogsOperations operations + :vartype captured_logs: + azure.mgmt.postgresqlflexibleservers.aio.operations.CapturedLogsOperations + :ivar backups_long_term_retention: BackupsLongTermRetentionOperations operations + :vartype backups_long_term_retention: + azure.mgmt.postgresqlflexibleservers.aio.operations.BackupsLongTermRetentionOperations + :ivar replicas: ReplicasOperations operations + :vartype replicas: azure.mgmt.postgresqlflexibleservers.aio.operations.ReplicasOperations :ivar advanced_threat_protection_settings: AdvancedThreatProtectionSettingsOperations operations :vartype advanced_threat_protection_settings: @@ -70,68 +103,35 @@ class PostgreSQLManagementClient: # pylint: disable=too-many-instance-attribute :ivar backups_automatic_and_on_demand: BackupsAutomaticAndOnDemandOperations operations :vartype backups_automatic_and_on_demand: azure.mgmt.postgresqlflexibleservers.aio.operations.BackupsAutomaticAndOnDemandOperations + :ivar tuning_options: TuningOptionsOperations operations + :vartype tuning_options: + azure.mgmt.postgresqlflexibleservers.aio.operations.TuningOptionsOperations :ivar capabilities_by_location: CapabilitiesByLocationOperations operations :vartype capabilities_by_location: azure.mgmt.postgresqlflexibleservers.aio.operations.CapabilitiesByLocationOperations - :ivar capabilities_by_server: CapabilitiesByServerOperations operations - :vartype capabilities_by_server: - azure.mgmt.postgresqlflexibleservers.aio.operations.CapabilitiesByServerOperations - :ivar captured_logs: CapturedLogsOperations operations - :vartype captured_logs: - azure.mgmt.postgresqlflexibleservers.aio.operations.CapturedLogsOperations - :ivar configurations: ConfigurationsOperations operations - :vartype configurations: - azure.mgmt.postgresqlflexibleservers.aio.operations.ConfigurationsOperations - :ivar databases: DatabasesOperations operations - :vartype databases: azure.mgmt.postgresqlflexibleservers.aio.operations.DatabasesOperations - :ivar firewall_rules: FirewallRulesOperations operations - :vartype firewall_rules: - azure.mgmt.postgresqlflexibleservers.aio.operations.FirewallRulesOperations - :ivar backups_long_term_retention: BackupsLongTermRetentionOperations operations - :vartype backups_long_term_retention: - azure.mgmt.postgresqlflexibleservers.aio.operations.BackupsLongTermRetentionOperations - :ivar migrations: MigrationsOperations operations - :vartype migrations: azure.mgmt.postgresqlflexibleservers.aio.operations.MigrationsOperations :ivar name_availability: NameAvailabilityOperations operations :vartype name_availability: azure.mgmt.postgresqlflexibleservers.aio.operations.NameAvailabilityOperations - :ivar operations: Operations operations - :vartype operations: azure.mgmt.postgresqlflexibleservers.aio.operations.Operations :ivar private_dns_zone_suffix: PrivateDnsZoneSuffixOperations operations :vartype private_dns_zone_suffix: azure.mgmt.postgresqlflexibleservers.aio.operations.PrivateDnsZoneSuffixOperations - :ivar private_endpoint_connections: PrivateEndpointConnectionsOperations operations - :vartype private_endpoint_connections: - azure.mgmt.postgresqlflexibleservers.aio.operations.PrivateEndpointConnectionsOperations - :ivar private_link_resources: PrivateLinkResourcesOperations operations - :vartype private_link_resources: - azure.mgmt.postgresqlflexibleservers.aio.operations.PrivateLinkResourcesOperations :ivar quota_usages: QuotaUsagesOperations operations :vartype quota_usages: azure.mgmt.postgresqlflexibleservers.aio.operations.QuotaUsagesOperations - :ivar replicas: ReplicasOperations operations - :vartype replicas: azure.mgmt.postgresqlflexibleservers.aio.operations.ReplicasOperations - :ivar servers: ServersOperations operations - :vartype servers: azure.mgmt.postgresqlflexibleservers.aio.operations.ServersOperations - :ivar tuning_options: TuningOptionsOperations operations - :vartype tuning_options: - azure.mgmt.postgresqlflexibleservers.aio.operations.TuningOptionsOperations - :ivar virtual_endpoints: VirtualEndpointsOperations operations - :vartype virtual_endpoints: - azure.mgmt.postgresqlflexibleservers.aio.operations.VirtualEndpointsOperations :ivar virtual_network_subnet_usage: VirtualNetworkSubnetUsageOperations operations :vartype virtual_network_subnet_usage: azure.mgmt.postgresqlflexibleservers.aio.operations.VirtualNetworkSubnetUsageOperations - :param credential: Credential needed for the client to connect to Azure. Required. + :param credential: Credential used to authenticate requests to the service. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The ID of the target subscription. The value must be an UUID. Required. :type subscription_id: str - :param base_url: Service URL. Default value is None. + :param base_url: Service host. Default value is None. :type base_url: str :keyword cloud_setting: The cloud setting for which to get the ARM endpoint. Default value is None. :paramtype cloud_setting: ~azure.core.AzureClouds - :keyword api_version: Api Version. Default value is "2025-08-01". Note that overriding this + :keyword api_version: The API version to use for this operation. Known values are + "2026-01-01-preview" and None. Default value is "2026-01-01-preview". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str :keyword int polling_interval: Default waiting time between two polls for LRO operations if no @@ -147,6 +147,7 @@ def __init__( cloud_setting: Optional["AzureClouds"] = None, **kwargs: Any ) -> None: + _endpoint = "{endpoint}" _cloud = cloud_setting or settings.current.azure_cloud # type: ignore _endpoints = get_arm_endpoints(_cloud) if not base_url: @@ -155,6 +156,7 @@ def __init__( self._config = PostgreSQLManagementClientConfiguration( credential=credential, subscription_id=subscription_id, + base_url=cast(str, base_url), cloud_setting=cloud_setting, credential_scopes=credential_scopes, **kwargs @@ -179,64 +181,63 @@ def __init__( self._config.http_logging_policy, ] self._client: AsyncARMPipelineClient = AsyncARMPipelineClient( - base_url=cast(str, base_url), policies=_policies, **kwargs + base_url=cast(str, _endpoint), policies=_policies, **kwargs ) - client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer(client_models) - self._deserialize = Deserializer(client_models) + self._serialize = Serializer() + self._deserialize = Deserializer() self._serialize.client_side_validation = False - self.administrators_microsoft_entra = AdministratorsMicrosoftEntraOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.advanced_threat_protection_settings = AdvancedThreatProtectionSettingsOperations( + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.migrations = MigrationsOperations(self._client, self._config, self._serialize, self._deserialize) + self.servers = ServersOperations(self._client, self._config, self._serialize, self._deserialize) + self.configurations = ConfigurationsOperations(self._client, self._config, self._serialize, self._deserialize) + self.databases = DatabasesOperations(self._client, self._config, self._serialize, self._deserialize) + self.firewall_rules = FirewallRulesOperations(self._client, self._config, self._serialize, self._deserialize) + self.private_endpoint_connections = PrivateEndpointConnectionsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.server_threat_protection_settings = ServerThreatProtectionSettingsOperations( + self.private_link_resources = PrivateLinkResourcesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.backups_automatic_and_on_demand = BackupsAutomaticAndOnDemandOperations( + self.virtual_endpoints = VirtualEndpointsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.capabilities_by_location = CapabilitiesByLocationOperations( + self.administrators_microsoft_entra = AdministratorsMicrosoftEntraOperations( self._client, self._config, self._serialize, self._deserialize ) self.capabilities_by_server = CapabilitiesByServerOperations( self._client, self._config, self._serialize, self._deserialize ) self.captured_logs = CapturedLogsOperations(self._client, self._config, self._serialize, self._deserialize) - self.configurations = ConfigurationsOperations(self._client, self._config, self._serialize, self._deserialize) - self.databases = DatabasesOperations(self._client, self._config, self._serialize, self._deserialize) - self.firewall_rules = FirewallRulesOperations(self._client, self._config, self._serialize, self._deserialize) self.backups_long_term_retention = BackupsLongTermRetentionOperations( self._client, self._config, self._serialize, self._deserialize ) - self.migrations = MigrationsOperations(self._client, self._config, self._serialize, self._deserialize) - self.name_availability = NameAvailabilityOperations( + self.replicas = ReplicasOperations(self._client, self._config, self._serialize, self._deserialize) + self.advanced_threat_protection_settings = AdvancedThreatProtectionSettingsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) - self.private_dns_zone_suffix = PrivateDnsZoneSuffixOperations( + self.server_threat_protection_settings = ServerThreatProtectionSettingsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.private_endpoint_connections = PrivateEndpointConnectionsOperations( + self.backups_automatic_and_on_demand = BackupsAutomaticAndOnDemandOperations( self._client, self._config, self._serialize, self._deserialize ) - self.private_link_resources = PrivateLinkResourcesOperations( + self.tuning_options = TuningOptionsOperations(self._client, self._config, self._serialize, self._deserialize) + self.capabilities_by_location = CapabilitiesByLocationOperations( self._client, self._config, self._serialize, self._deserialize ) - self.quota_usages = QuotaUsagesOperations(self._client, self._config, self._serialize, self._deserialize) - self.replicas = ReplicasOperations(self._client, self._config, self._serialize, self._deserialize) - self.servers = ServersOperations(self._client, self._config, self._serialize, self._deserialize) - self.tuning_options = TuningOptionsOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_endpoints = VirtualEndpointsOperations( + self.name_availability = NameAvailabilityOperations( self._client, self._config, self._serialize, self._deserialize ) + self.private_dns_zone_suffix = PrivateDnsZoneSuffixOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.quota_usages = QuotaUsagesOperations(self._client, self._config, self._serialize, self._deserialize) self.virtual_network_subnet_usage = VirtualNetworkSubnetUsageOperations( self._client, self._config, self._serialize, self._deserialize ) - def _send_request( + def send_request( self, request: HttpRequest, *, stream: bool = False, **kwargs: Any ) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. @@ -244,7 +245,7 @@ def _send_request( >>> from azure.core.rest import HttpRequest >>> request = HttpRequest("GET", "https://www.example.org/") - >>> response = await client._send_request(request) + >>> response = await client.send_request(request) For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request @@ -257,7 +258,11 @@ def _send_request( """ request_copy = deepcopy(request) - request_copy.url = self._client.format_url(request_copy.url) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + request_copy.url = self._client.format_url(request_copy.url, **path_format_arguments) return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore async def close(self) -> None: diff --git a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/azure/mgmt/postgresqlflexibleservers/aio/_configuration.py b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/azure/mgmt/postgresqlflexibleservers/aio/_configuration.py index 096a7285ac43..e602b95298e9 100644 --- a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/azure/mgmt/postgresqlflexibleservers/aio/_configuration.py +++ b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/azure/mgmt/postgresqlflexibleservers/aio/_configuration.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -24,14 +24,17 @@ class PostgreSQLManagementClientConfiguration: # pylint: disable=too-many-insta Note that all parameters used to create this instance are saved as instance attributes. - :param credential: Credential needed for the client to connect to Azure. Required. + :param credential: Credential used to authenticate requests to the service. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The ID of the target subscription. The value must be an UUID. Required. :type subscription_id: str + :param base_url: Service host. Default value is "https://management.azure.com". + :type base_url: str :param cloud_setting: The cloud setting for which to get the ARM endpoint. Default value is None. :type cloud_setting: ~azure.core.AzureClouds - :keyword api_version: Api Version. Default value is "2025-08-01". Note that overriding this + :keyword api_version: The API version to use for this operation. Known values are + "2026-01-01-preview" and None. Default value is "2026-01-01-preview". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ @@ -40,10 +43,11 @@ def __init__( self, credential: "AsyncTokenCredential", subscription_id: str, + base_url: str = "https://management.azure.com", cloud_setting: Optional["AzureClouds"] = None, **kwargs: Any ) -> None: - api_version: str = kwargs.pop("api_version", "2025-08-01") + api_version: str = kwargs.pop("api_version", "2026-01-01-preview") if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -52,6 +56,7 @@ def __init__( self.credential = credential self.subscription_id = subscription_id + self.base_url = base_url self.cloud_setting = cloud_setting self.api_version = api_version self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) diff --git a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/azure/mgmt/postgresqlflexibleservers/aio/_patch.py b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/azure/mgmt/postgresqlflexibleservers/aio/_patch.py index f7dd32510333..87676c65a8f0 100644 --- a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/azure/mgmt/postgresqlflexibleservers/aio/_patch.py +++ b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/azure/mgmt/postgresqlflexibleservers/aio/_patch.py @@ -1,14 +1,15 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------- """Customize generated code here. Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize """ -from typing import List -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +__all__: list[str] = [] # Add all objects you want publicly available to users at this package level def patch_sdk(): diff --git a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/azure/mgmt/postgresqlflexibleservers/aio/operations/__init__.py b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/azure/mgmt/postgresqlflexibleservers/aio/operations/__init__.py index e3f2cc110001..ec5ea57d4214 100644 --- a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/azure/mgmt/postgresqlflexibleservers/aio/operations/__init__.py +++ b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/azure/mgmt/postgresqlflexibleservers/aio/operations/__init__.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- # pylint: disable=wrong-import-position @@ -12,57 +12,57 @@ if TYPE_CHECKING: from ._patch import * # pylint: disable=unused-wildcard-import -from ._administrators_microsoft_entra_operations import AdministratorsMicrosoftEntraOperations # type: ignore -from ._advanced_threat_protection_settings_operations import AdvancedThreatProtectionSettingsOperations # type: ignore -from ._server_threat_protection_settings_operations import ServerThreatProtectionSettingsOperations # type: ignore -from ._backups_automatic_and_on_demand_operations import BackupsAutomaticAndOnDemandOperations # type: ignore -from ._capabilities_by_location_operations import CapabilitiesByLocationOperations # type: ignore -from ._capabilities_by_server_operations import CapabilitiesByServerOperations # type: ignore -from ._captured_logs_operations import CapturedLogsOperations # type: ignore -from ._configurations_operations import ConfigurationsOperations # type: ignore -from ._databases_operations import DatabasesOperations # type: ignore -from ._firewall_rules_operations import FirewallRulesOperations # type: ignore -from ._backups_long_term_retention_operations import BackupsLongTermRetentionOperations # type: ignore -from ._migrations_operations import MigrationsOperations # type: ignore -from ._name_availability_operations import NameAvailabilityOperations # type: ignore from ._operations import Operations # type: ignore -from ._private_dns_zone_suffix_operations import PrivateDnsZoneSuffixOperations # type: ignore -from ._private_endpoint_connections_operations import PrivateEndpointConnectionsOperations # type: ignore -from ._private_link_resources_operations import PrivateLinkResourcesOperations # type: ignore -from ._quota_usages_operations import QuotaUsagesOperations # type: ignore -from ._replicas_operations import ReplicasOperations # type: ignore -from ._servers_operations import ServersOperations # type: ignore -from ._tuning_options_operations import TuningOptionsOperations # type: ignore -from ._virtual_endpoints_operations import VirtualEndpointsOperations # type: ignore -from ._virtual_network_subnet_usage_operations import VirtualNetworkSubnetUsageOperations # type: ignore +from ._operations import MigrationsOperations # type: ignore +from ._operations import ServersOperations # type: ignore +from ._operations import ConfigurationsOperations # type: ignore +from ._operations import DatabasesOperations # type: ignore +from ._operations import FirewallRulesOperations # type: ignore +from ._operations import PrivateEndpointConnectionsOperations # type: ignore +from ._operations import PrivateLinkResourcesOperations # type: ignore +from ._operations import VirtualEndpointsOperations # type: ignore +from ._operations import AdministratorsMicrosoftEntraOperations # type: ignore +from ._operations import CapabilitiesByServerOperations # type: ignore +from ._operations import CapturedLogsOperations # type: ignore +from ._operations import BackupsLongTermRetentionOperations # type: ignore +from ._operations import ReplicasOperations # type: ignore +from ._operations import AdvancedThreatProtectionSettingsOperations # type: ignore +from ._operations import ServerThreatProtectionSettingsOperations # type: ignore +from ._operations import BackupsAutomaticAndOnDemandOperations # type: ignore +from ._operations import TuningOptionsOperations # type: ignore +from ._operations import CapabilitiesByLocationOperations # type: ignore +from ._operations import NameAvailabilityOperations # type: ignore +from ._operations import PrivateDnsZoneSuffixOperations # type: ignore +from ._operations import QuotaUsagesOperations # type: ignore +from ._operations import VirtualNetworkSubnetUsageOperations # type: ignore from ._patch import __all__ as _patch_all from ._patch import * from ._patch import patch_sdk as _patch_sdk __all__ = [ + "Operations", + "MigrationsOperations", + "ServersOperations", + "ConfigurationsOperations", + "DatabasesOperations", + "FirewallRulesOperations", + "PrivateEndpointConnectionsOperations", + "PrivateLinkResourcesOperations", + "VirtualEndpointsOperations", "AdministratorsMicrosoftEntraOperations", + "CapabilitiesByServerOperations", + "CapturedLogsOperations", + "BackupsLongTermRetentionOperations", + "ReplicasOperations", "AdvancedThreatProtectionSettingsOperations", "ServerThreatProtectionSettingsOperations", "BackupsAutomaticAndOnDemandOperations", + "TuningOptionsOperations", "CapabilitiesByLocationOperations", - "CapabilitiesByServerOperations", - "CapturedLogsOperations", - "ConfigurationsOperations", - "DatabasesOperations", - "FirewallRulesOperations", - "BackupsLongTermRetentionOperations", - "MigrationsOperations", "NameAvailabilityOperations", - "Operations", "PrivateDnsZoneSuffixOperations", - "PrivateEndpointConnectionsOperations", - "PrivateLinkResourcesOperations", "QuotaUsagesOperations", - "ReplicasOperations", - "ServersOperations", - "TuningOptionsOperations", - "VirtualEndpointsOperations", "VirtualNetworkSubnetUsageOperations", ] __all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore diff --git a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/azure/mgmt/postgresqlflexibleservers/aio/operations/_administrators_microsoft_entra_operations.py b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/azure/mgmt/postgresqlflexibleservers/aio/operations/_administrators_microsoft_entra_operations.py deleted file mode 100644 index 5ac0227edb7f..000000000000 --- a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/azure/mgmt/postgresqlflexibleservers/aio/operations/_administrators_microsoft_entra_operations.py +++ /dev/null @@ -1,569 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from collections.abc import MutableMapping -from io import IOBase -from typing import Any, AsyncIterator, Callable, IO, Optional, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core import AsyncPipelineClient -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import AsyncHttpResponse, HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling - -from ... import models as _models -from ..._utils.serialization import Deserializer, Serializer -from ...operations._administrators_microsoft_entra_operations import ( - build_create_or_update_request, - build_delete_request, - build_get_request, - build_list_by_server_request, -) -from .._configuration import PostgreSQLManagementClientConfiguration - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] -List = list - - -class AdministratorsMicrosoftEntraOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.postgresqlflexibleservers.aio.PostgreSQLManagementClient`'s - :attr:`administrators_microsoft_entra` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: PostgreSQLManagementClientConfiguration = ( - input_args.pop(0) if input_args else kwargs.pop("config") - ) - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - async def _create_or_update_initial( - self, - resource_group_name: str, - server_name: str, - object_id: str, - parameters: Union[_models.AdministratorMicrosoftEntraAdd, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "AdministratorMicrosoftEntraAdd") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - server_name=server_name, - object_id=object_id, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize( - _models.ErrorResponse, - pipeline_response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - response_headers = {} - if response.status_code == 202: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - server_name: str, - object_id: str, - parameters: _models.AdministratorMicrosoftEntraAdd, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.AdministratorMicrosoftEntra]: - """Creates a new server administrator associated to a Microsoft Entra principal. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param object_id: Object identifier of the Microsoft Entra principal. Required. - :type object_id: str - :param parameters: Required parameters for adding a server administrator associated to a - Microsoft Entra principal. Required. - :type parameters: ~azure.mgmt.postgresqlflexibleservers.models.AdministratorMicrosoftEntraAdd - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either AdministratorMicrosoftEntra or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.postgresqlflexibleservers.models.AdministratorMicrosoftEntra] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - server_name: str, - object_id: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.AdministratorMicrosoftEntra]: - """Creates a new server administrator associated to a Microsoft Entra principal. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param object_id: Object identifier of the Microsoft Entra principal. Required. - :type object_id: str - :param parameters: Required parameters for adding a server administrator associated to a - Microsoft Entra principal. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either AdministratorMicrosoftEntra or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.postgresqlflexibleservers.models.AdministratorMicrosoftEntra] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_create_or_update( - self, - resource_group_name: str, - server_name: str, - object_id: str, - parameters: Union[_models.AdministratorMicrosoftEntraAdd, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.AdministratorMicrosoftEntra]: - """Creates a new server administrator associated to a Microsoft Entra principal. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param object_id: Object identifier of the Microsoft Entra principal. Required. - :type object_id: str - :param parameters: Required parameters for adding a server administrator associated to a - Microsoft Entra principal. Is either a AdministratorMicrosoftEntraAdd type or a IO[bytes] type. - Required. - :type parameters: ~azure.mgmt.postgresqlflexibleservers.models.AdministratorMicrosoftEntraAdd - or IO[bytes] - :return: An instance of AsyncLROPoller that returns either AdministratorMicrosoftEntra or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.postgresqlflexibleservers.models.AdministratorMicrosoftEntra] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.AdministratorMicrosoftEntra] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._create_or_update_initial( - resource_group_name=resource_group_name, - server_name=server_name, - object_id=object_id, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("AdministratorMicrosoftEntra", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - if polling is True: - polling_method: AsyncPollingMethod = cast( - AsyncPollingMethod, - AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[_models.AdministratorMicrosoftEntra].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.AdministratorMicrosoftEntra]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _delete_initial( - self, resource_group_name: str, server_name: str, object_id: str, **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_delete_request( - resource_group_name=resource_group_name, - server_name=server_name, - object_id=object_id, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [202, 204]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize( - _models.ErrorResponse, - pipeline_response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - response_headers = {} - if response.status_code == 202: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def begin_delete( - self, resource_group_name: str, server_name: str, object_id: str, **kwargs: Any - ) -> AsyncLROPoller[None]: - """Deletes an existing server administrator associated to a Microsoft Entra principal. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param object_id: Object identifier of the Microsoft Entra principal. Required. - :type object_id: str - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._delete_initial( - resource_group_name=resource_group_name, - server_name=server_name, - object_id=object_id, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: AsyncPollingMethod = cast( - AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - @distributed_trace_async - async def get( - self, resource_group_name: str, server_name: str, object_id: str, **kwargs: Any - ) -> _models.AdministratorMicrosoftEntra: - """Gets information about a server administrator associated to a Microsoft Entra principal. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param object_id: Object identifier of the Microsoft Entra principal. Required. - :type object_id: str - :return: AdministratorMicrosoftEntra or the result of cls(response) - :rtype: ~azure.mgmt.postgresqlflexibleservers.models.AdministratorMicrosoftEntra - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.AdministratorMicrosoftEntra] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - server_name=server_name, - object_id=object_id, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize( - _models.ErrorResponse, - pipeline_response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("AdministratorMicrosoftEntra", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def list_by_server( - self, resource_group_name: str, server_name: str, **kwargs: Any - ) -> AsyncItemPaged["_models.AdministratorMicrosoftEntra"]: - """List all server administrators associated to a Microsoft Entra principal. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :return: An iterator like instance of either AdministratorMicrosoftEntra or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.postgresqlflexibleservers.models.AdministratorMicrosoftEntra] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.AdministratorMicrosoftEntraList] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_by_server_request( - resource_group_name=resource_group_name, - server_name=server_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("AdministratorMicrosoftEntraList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize( - _models.ErrorResponse, - pipeline_response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) diff --git a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/azure/mgmt/postgresqlflexibleservers/aio/operations/_advanced_threat_protection_settings_operations.py b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/azure/mgmt/postgresqlflexibleservers/aio/operations/_advanced_threat_protection_settings_operations.py deleted file mode 100644 index 8e7654d38c45..000000000000 --- a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/azure/mgmt/postgresqlflexibleservers/aio/operations/_advanced_threat_protection_settings_operations.py +++ /dev/null @@ -1,221 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from collections.abc import MutableMapping -from typing import Any, Callable, Optional, TypeVar, Union -import urllib.parse - -from azure.core import AsyncPipelineClient -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.rest import AsyncHttpResponse, HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._utils.serialization import Deserializer, Serializer -from ...operations._advanced_threat_protection_settings_operations import ( - build_get_request, - build_list_by_server_request, -) -from .._configuration import PostgreSQLManagementClientConfiguration - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] -List = list - - -class AdvancedThreatProtectionSettingsOperations: # pylint: disable=name-too-long - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.postgresqlflexibleservers.aio.PostgreSQLManagementClient`'s - :attr:`advanced_threat_protection_settings` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: PostgreSQLManagementClientConfiguration = ( - input_args.pop(0) if input_args else kwargs.pop("config") - ) - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def list_by_server( - self, resource_group_name: str, server_name: str, **kwargs: Any - ) -> AsyncItemPaged["_models.AdvancedThreatProtectionSettingsModel"]: - """Lists state of advanced threat protection settings for a server. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :return: An iterator like instance of either AdvancedThreatProtectionSettingsModel or the - result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.postgresqlflexibleservers.models.AdvancedThreatProtectionSettingsModel] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.AdvancedThreatProtectionSettingsList] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_by_server_request( - resource_group_name=resource_group_name, - server_name=server_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("AdvancedThreatProtectionSettingsList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize( - _models.ErrorResponse, - pipeline_response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace_async - async def get( - self, - resource_group_name: str, - server_name: str, - threat_protection_name: Union[str, _models.ThreatProtectionName], - **kwargs: Any - ) -> _models.AdvancedThreatProtectionSettingsModel: - """Gets state of advanced threat protection settings for a server. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param threat_protection_name: Name of the advanced threat protection settings. "Default" - Required. - :type threat_protection_name: str or - ~azure.mgmt.postgresqlflexibleservers.models.ThreatProtectionName - :return: AdvancedThreatProtectionSettingsModel or the result of cls(response) - :rtype: ~azure.mgmt.postgresqlflexibleservers.models.AdvancedThreatProtectionSettingsModel - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.AdvancedThreatProtectionSettingsModel] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - server_name=server_name, - threat_protection_name=threat_protection_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize( - _models.ErrorResponse, - pipeline_response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("AdvancedThreatProtectionSettingsModel", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/azure/mgmt/postgresqlflexibleservers/aio/operations/_backups_automatic_and_on_demand_operations.py b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/azure/mgmt/postgresqlflexibleservers/aio/operations/_backups_automatic_and_on_demand_operations.py deleted file mode 100644 index 14d4097364c2..000000000000 --- a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/azure/mgmt/postgresqlflexibleservers/aio/operations/_backups_automatic_and_on_demand_operations.py +++ /dev/null @@ -1,472 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from collections.abc import MutableMapping -from typing import Any, AsyncIterator, Callable, Optional, TypeVar, Union, cast -import urllib.parse - -from azure.core import AsyncPipelineClient -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import AsyncHttpResponse, HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling - -from ... import models as _models -from ..._utils.serialization import Deserializer, Serializer -from ...operations._backups_automatic_and_on_demand_operations import ( - build_create_request, - build_delete_request, - build_get_request, - build_list_by_server_request, -) -from .._configuration import PostgreSQLManagementClientConfiguration - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] -List = list - - -class BackupsAutomaticAndOnDemandOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.postgresqlflexibleservers.aio.PostgreSQLManagementClient`'s - :attr:`backups_automatic_and_on_demand` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: PostgreSQLManagementClientConfiguration = ( - input_args.pop(0) if input_args else kwargs.pop("config") - ) - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - async def _create_initial( - self, resource_group_name: str, server_name: str, backup_name: str, **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_create_request( - resource_group_name=resource_group_name, - server_name=server_name, - backup_name=backup_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize( - _models.ErrorResponse, - pipeline_response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - response_headers = {} - if response.status_code == 202: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def begin_create( - self, resource_group_name: str, server_name: str, backup_name: str, **kwargs: Any - ) -> AsyncLROPoller[_models.BackupAutomaticAndOnDemand]: - """Creates an on demand backup of a server. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param backup_name: Name of the backup. Required. - :type backup_name: str - :return: An instance of AsyncLROPoller that returns either BackupAutomaticAndOnDemand or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.postgresqlflexibleservers.models.BackupAutomaticAndOnDemand] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.BackupAutomaticAndOnDemand] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._create_initial( - resource_group_name=resource_group_name, - server_name=server_name, - backup_name=backup_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("BackupAutomaticAndOnDemand", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - if polling is True: - polling_method: AsyncPollingMethod = cast( - AsyncPollingMethod, - AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[_models.BackupAutomaticAndOnDemand].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.BackupAutomaticAndOnDemand]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _delete_initial( - self, resource_group_name: str, server_name: str, backup_name: str, **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_delete_request( - resource_group_name=resource_group_name, - server_name=server_name, - backup_name=backup_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [202, 204]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize( - _models.ErrorResponse, - pipeline_response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - response_headers = {} - if response.status_code == 202: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def begin_delete( - self, resource_group_name: str, server_name: str, backup_name: str, **kwargs: Any - ) -> AsyncLROPoller[None]: - """Deletes a specific backup, given its name. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param backup_name: Name of the backup. Required. - :type backup_name: str - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._delete_initial( - resource_group_name=resource_group_name, - server_name=server_name, - backup_name=backup_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: AsyncPollingMethod = cast( - AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - @distributed_trace_async - async def get( - self, resource_group_name: str, server_name: str, backup_name: str, **kwargs: Any - ) -> _models.BackupAutomaticAndOnDemand: - """Gets information of an on demand backup, given its name. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param backup_name: Name of the backup. Required. - :type backup_name: str - :return: BackupAutomaticAndOnDemand or the result of cls(response) - :rtype: ~azure.mgmt.postgresqlflexibleservers.models.BackupAutomaticAndOnDemand - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.BackupAutomaticAndOnDemand] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - server_name=server_name, - backup_name=backup_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize( - _models.ErrorResponse, - pipeline_response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("BackupAutomaticAndOnDemand", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def list_by_server( - self, resource_group_name: str, server_name: str, **kwargs: Any - ) -> AsyncItemPaged["_models.BackupAutomaticAndOnDemand"]: - """Lists all available backups of a server. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :return: An iterator like instance of either BackupAutomaticAndOnDemand or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.postgresqlflexibleservers.models.BackupAutomaticAndOnDemand] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.BackupAutomaticAndOnDemandList] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_by_server_request( - resource_group_name=resource_group_name, - server_name=server_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("BackupAutomaticAndOnDemandList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize( - _models.ErrorResponse, - pipeline_response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) diff --git a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/azure/mgmt/postgresqlflexibleservers/aio/operations/_backups_long_term_retention_operations.py b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/azure/mgmt/postgresqlflexibleservers/aio/operations/_backups_long_term_retention_operations.py deleted file mode 100644 index 71e86a4ef808..000000000000 --- a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/azure/mgmt/postgresqlflexibleservers/aio/operations/_backups_long_term_retention_operations.py +++ /dev/null @@ -1,577 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from collections.abc import MutableMapping -from io import IOBase -from typing import Any, AsyncIterator, Callable, IO, Optional, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core import AsyncPipelineClient -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import AsyncHttpResponse, HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling - -from ... import models as _models -from ..._utils.serialization import Deserializer, Serializer -from ...operations._backups_long_term_retention_operations import ( - build_check_prerequisites_request, - build_get_request, - build_list_by_server_request, - build_start_request, -) -from .._configuration import PostgreSQLManagementClientConfiguration - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] -List = list - - -class BackupsLongTermRetentionOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.postgresqlflexibleservers.aio.PostgreSQLManagementClient`'s - :attr:`backups_long_term_retention` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: PostgreSQLManagementClientConfiguration = ( - input_args.pop(0) if input_args else kwargs.pop("config") - ) - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @overload - async def check_prerequisites( - self, - resource_group_name: str, - server_name: str, - parameters: _models.LtrPreBackupRequest, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.LtrPreBackupResponse: - """Performs all checks required for a long term retention backup operation to succeed. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param parameters: Request body for operation. Required. - :type parameters: ~azure.mgmt.postgresqlflexibleservers.models.LtrPreBackupRequest - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: LtrPreBackupResponse or the result of cls(response) - :rtype: ~azure.mgmt.postgresqlflexibleservers.models.LtrPreBackupResponse - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def check_prerequisites( - self, - resource_group_name: str, - server_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.LtrPreBackupResponse: - """Performs all checks required for a long term retention backup operation to succeed. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param parameters: Request body for operation. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: LtrPreBackupResponse or the result of cls(response) - :rtype: ~azure.mgmt.postgresqlflexibleservers.models.LtrPreBackupResponse - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def check_prerequisites( - self, - resource_group_name: str, - server_name: str, - parameters: Union[_models.LtrPreBackupRequest, IO[bytes]], - **kwargs: Any - ) -> _models.LtrPreBackupResponse: - """Performs all checks required for a long term retention backup operation to succeed. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param parameters: Request body for operation. Is either a LtrPreBackupRequest type or a - IO[bytes] type. Required. - :type parameters: ~azure.mgmt.postgresqlflexibleservers.models.LtrPreBackupRequest or IO[bytes] - :return: LtrPreBackupResponse or the result of cls(response) - :rtype: ~azure.mgmt.postgresqlflexibleservers.models.LtrPreBackupResponse - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.LtrPreBackupResponse] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "LtrPreBackupRequest") - - _request = build_check_prerequisites_request( - resource_group_name=resource_group_name, - server_name=server_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize( - _models.ErrorResponse, - pipeline_response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - response_headers = {} - response_headers["x-ms-request-id"] = self._deserialize("str", response.headers.get("x-ms-request-id")) - - deserialized = self._deserialize("LtrPreBackupResponse", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - async def _start_initial( - self, - resource_group_name: str, - server_name: str, - parameters: Union[_models.BackupsLongTermRetentionRequest, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "BackupsLongTermRetentionRequest") - - _request = build_start_request( - resource_group_name=resource_group_name, - server_name=server_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize( - _models.ErrorResponse, - pipeline_response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - response_headers = {} - if response.status_code == 200: - response_headers["x-ms-request-id"] = self._deserialize("str", response.headers.get("x-ms-request-id")) - - if response.status_code == 202: - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - response_headers["x-ms-request-id"] = self._deserialize("str", response.headers.get("x-ms-request-id")) - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @overload - async def begin_start( - self, - resource_group_name: str, - server_name: str, - parameters: _models.BackupsLongTermRetentionRequest, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.BackupsLongTermRetentionResponse]: - """Initiates a long term retention backup. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param parameters: Request body for operation. Required. - :type parameters: ~azure.mgmt.postgresqlflexibleservers.models.BackupsLongTermRetentionRequest - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either BackupsLongTermRetentionResponse or - the result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.postgresqlflexibleservers.models.BackupsLongTermRetentionResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_start( - self, - resource_group_name: str, - server_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.BackupsLongTermRetentionResponse]: - """Initiates a long term retention backup. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param parameters: Request body for operation. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either BackupsLongTermRetentionResponse or - the result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.postgresqlflexibleservers.models.BackupsLongTermRetentionResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_start( - self, - resource_group_name: str, - server_name: str, - parameters: Union[_models.BackupsLongTermRetentionRequest, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.BackupsLongTermRetentionResponse]: - """Initiates a long term retention backup. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param parameters: Request body for operation. Is either a BackupsLongTermRetentionRequest type - or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.postgresqlflexibleservers.models.BackupsLongTermRetentionRequest - or IO[bytes] - :return: An instance of AsyncLROPoller that returns either BackupsLongTermRetentionResponse or - the result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.postgresqlflexibleservers.models.BackupsLongTermRetentionResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.BackupsLongTermRetentionResponse] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._start_initial( - resource_group_name=resource_group_name, - server_name=server_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - response_headers = {} - response = pipeline_response.http_response - response_headers["x-ms-request-id"] = self._deserialize("str", response.headers.get("x-ms-request-id")) - - deserialized = self._deserialize("BackupsLongTermRetentionResponse", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - return deserialized - - if polling is True: - polling_method: AsyncPollingMethod = cast( - AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[_models.BackupsLongTermRetentionResponse].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.BackupsLongTermRetentionResponse]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - @distributed_trace_async - async def get( - self, resource_group_name: str, server_name: str, backup_name: str, **kwargs: Any - ) -> _models.BackupsLongTermRetentionOperation: - """Gets the results of a long retention backup operation for a server. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param backup_name: The name of the backup. Required. - :type backup_name: str - :return: BackupsLongTermRetentionOperation or the result of cls(response) - :rtype: ~azure.mgmt.postgresqlflexibleservers.models.BackupsLongTermRetentionOperation - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.BackupsLongTermRetentionOperation] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - server_name=server_name, - backup_name=backup_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize( - _models.ErrorResponse, - pipeline_response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("BackupsLongTermRetentionOperation", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def list_by_server( - self, resource_group_name: str, server_name: str, **kwargs: Any - ) -> AsyncItemPaged["_models.BackupsLongTermRetentionOperation"]: - """Lists the results of the long term retention backup operations for a server. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :return: An iterator like instance of either BackupsLongTermRetentionOperation or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.postgresqlflexibleservers.models.BackupsLongTermRetentionOperation] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.LtrServerBackupOperationList] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_by_server_request( - resource_group_name=resource_group_name, - server_name=server_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("LtrServerBackupOperationList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize( - _models.ErrorResponse, - pipeline_response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) diff --git a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/azure/mgmt/postgresqlflexibleservers/aio/operations/_capabilities_by_location_operations.py b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/azure/mgmt/postgresqlflexibleservers/aio/operations/_capabilities_by_location_operations.py deleted file mode 100644 index a4e5ee04a742..000000000000 --- a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/azure/mgmt/postgresqlflexibleservers/aio/operations/_capabilities_by_location_operations.py +++ /dev/null @@ -1,139 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from collections.abc import MutableMapping -from typing import Any, Callable, Optional, TypeVar -import urllib.parse - -from azure.core import AsyncPipelineClient -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.rest import AsyncHttpResponse, HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._utils.serialization import Deserializer, Serializer -from ...operations._capabilities_by_location_operations import build_list_request -from .._configuration import PostgreSQLManagementClientConfiguration - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] -List = list - - -class CapabilitiesByLocationOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.postgresqlflexibleservers.aio.PostgreSQLManagementClient`'s - :attr:`capabilities_by_location` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: PostgreSQLManagementClientConfiguration = ( - input_args.pop(0) if input_args else kwargs.pop("config") - ) - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def list(self, location_name: str, **kwargs: Any) -> AsyncItemPaged["_models.Capability"]: - """Lists the capabilities available in a given location for a specific subscription. - - :param location_name: The name of the location. Required. - :type location_name: str - :return: An iterator like instance of either Capability or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.postgresqlflexibleservers.models.Capability] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.CapabilityList] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_request( - location_name=location_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("CapabilityList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize( - _models.ErrorResponse, - pipeline_response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) diff --git a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/azure/mgmt/postgresqlflexibleservers/aio/operations/_capabilities_by_server_operations.py b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/azure/mgmt/postgresqlflexibleservers/aio/operations/_capabilities_by_server_operations.py deleted file mode 100644 index 755b6958b13b..000000000000 --- a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/azure/mgmt/postgresqlflexibleservers/aio/operations/_capabilities_by_server_operations.py +++ /dev/null @@ -1,143 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from collections.abc import MutableMapping -from typing import Any, Callable, Optional, TypeVar -import urllib.parse - -from azure.core import AsyncPipelineClient -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.rest import AsyncHttpResponse, HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._utils.serialization import Deserializer, Serializer -from ...operations._capabilities_by_server_operations import build_list_request -from .._configuration import PostgreSQLManagementClientConfiguration - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] -List = list - - -class CapabilitiesByServerOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.postgresqlflexibleservers.aio.PostgreSQLManagementClient`'s - :attr:`capabilities_by_server` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: PostgreSQLManagementClientConfiguration = ( - input_args.pop(0) if input_args else kwargs.pop("config") - ) - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def list(self, resource_group_name: str, server_name: str, **kwargs: Any) -> AsyncItemPaged["_models.Capability"]: - """Lists the capabilities available for a given server. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :return: An iterator like instance of either Capability or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.postgresqlflexibleservers.models.Capability] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.CapabilityList] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_request( - resource_group_name=resource_group_name, - server_name=server_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("CapabilityList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize( - _models.ErrorResponse, - pipeline_response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) diff --git a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/azure/mgmt/postgresqlflexibleservers/aio/operations/_captured_logs_operations.py b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/azure/mgmt/postgresqlflexibleservers/aio/operations/_captured_logs_operations.py deleted file mode 100644 index 804ca63c71a0..000000000000 --- a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/azure/mgmt/postgresqlflexibleservers/aio/operations/_captured_logs_operations.py +++ /dev/null @@ -1,145 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from collections.abc import MutableMapping -from typing import Any, Callable, Optional, TypeVar -import urllib.parse - -from azure.core import AsyncPipelineClient -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.rest import AsyncHttpResponse, HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._utils.serialization import Deserializer, Serializer -from ...operations._captured_logs_operations import build_list_by_server_request -from .._configuration import PostgreSQLManagementClientConfiguration - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] -List = list - - -class CapturedLogsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.postgresqlflexibleservers.aio.PostgreSQLManagementClient`'s - :attr:`captured_logs` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: PostgreSQLManagementClientConfiguration = ( - input_args.pop(0) if input_args else kwargs.pop("config") - ) - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def list_by_server( - self, resource_group_name: str, server_name: str, **kwargs: Any - ) -> AsyncItemPaged["_models.CapturedLog"]: - """Lists all captured logs for download in a server. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :return: An iterator like instance of either CapturedLog or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.postgresqlflexibleservers.models.CapturedLog] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.CapturedLogList] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_by_server_request( - resource_group_name=resource_group_name, - server_name=server_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("CapturedLogList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize( - _models.ErrorResponse, - pipeline_response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) diff --git a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/azure/mgmt/postgresqlflexibleservers/aio/operations/_configurations_operations.py b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/azure/mgmt/postgresqlflexibleservers/aio/operations/_configurations_operations.py deleted file mode 100644 index 52ce2660f6b9..000000000000 --- a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/azure/mgmt/postgresqlflexibleservers/aio/operations/_configurations_operations.py +++ /dev/null @@ -1,683 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from collections.abc import MutableMapping -from io import IOBase -from typing import Any, AsyncIterator, Callable, IO, Optional, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core import AsyncPipelineClient -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import AsyncHttpResponse, HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling - -from ... import models as _models -from ..._utils.serialization import Deserializer, Serializer -from ...operations._configurations_operations import ( - build_get_request, - build_list_by_server_request, - build_put_request, - build_update_request, -) -from .._configuration import PostgreSQLManagementClientConfiguration - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] -List = list - - -class ConfigurationsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.postgresqlflexibleservers.aio.PostgreSQLManagementClient`'s - :attr:`configurations` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: PostgreSQLManagementClientConfiguration = ( - input_args.pop(0) if input_args else kwargs.pop("config") - ) - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def list_by_server( - self, resource_group_name: str, server_name: str, **kwargs: Any - ) -> AsyncItemPaged["_models.Configuration"]: - """Lists all configurations (also known as server parameters) of a server. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :return: An iterator like instance of either Configuration or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.postgresqlflexibleservers.models.Configuration] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.ConfigurationList] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_by_server_request( - resource_group_name=resource_group_name, - server_name=server_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("ConfigurationList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize( - _models.ErrorResponse, - pipeline_response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace_async - async def get( - self, resource_group_name: str, server_name: str, configuration_name: str, **kwargs: Any - ) -> _models.Configuration: - """Gets information about a specific configuration (also known as server parameter) of a server. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param configuration_name: Name of the configuration (also known as server parameter). - Required. - :type configuration_name: str - :return: Configuration or the result of cls(response) - :rtype: ~azure.mgmt.postgresqlflexibleservers.models.Configuration - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.Configuration] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - server_name=server_name, - configuration_name=configuration_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize( - _models.ErrorResponse, - pipeline_response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("Configuration", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - async def _update_initial( - self, - resource_group_name: str, - server_name: str, - configuration_name: str, - parameters: Union[_models.ConfigurationForUpdate, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "ConfigurationForUpdate") - - _request = build_update_request( - resource_group_name=resource_group_name, - server_name=server_name, - configuration_name=configuration_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize( - _models.ErrorResponse, - pipeline_response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - response_headers = {} - if response.status_code == 202: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @overload - async def begin_update( - self, - resource_group_name: str, - server_name: str, - configuration_name: str, - parameters: _models.ConfigurationForUpdate, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.Configuration]: - """Updates the value assigned to a specific modifiable configuration (also known as server - parameter) of a server. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param configuration_name: Name of the configuration (also known as server parameter). - Required. - :type configuration_name: str - :param parameters: Parameters required to update the value of a specific modifiable - configuration (also known as server parameter). Required. - :type parameters: ~azure.mgmt.postgresqlflexibleservers.models.ConfigurationForUpdate - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either Configuration or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.postgresqlflexibleservers.models.Configuration] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_update( - self, - resource_group_name: str, - server_name: str, - configuration_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.Configuration]: - """Updates the value assigned to a specific modifiable configuration (also known as server - parameter) of a server. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param configuration_name: Name of the configuration (also known as server parameter). - Required. - :type configuration_name: str - :param parameters: Parameters required to update the value of a specific modifiable - configuration (also known as server parameter). Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either Configuration or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.postgresqlflexibleservers.models.Configuration] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_update( - self, - resource_group_name: str, - server_name: str, - configuration_name: str, - parameters: Union[_models.ConfigurationForUpdate, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.Configuration]: - """Updates the value assigned to a specific modifiable configuration (also known as server - parameter) of a server. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param configuration_name: Name of the configuration (also known as server parameter). - Required. - :type configuration_name: str - :param parameters: Parameters required to update the value of a specific modifiable - configuration (also known as server parameter). Is either a ConfigurationForUpdate type or a - IO[bytes] type. Required. - :type parameters: ~azure.mgmt.postgresqlflexibleservers.models.ConfigurationForUpdate or - IO[bytes] - :return: An instance of AsyncLROPoller that returns either Configuration or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.postgresqlflexibleservers.models.Configuration] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.Configuration] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._update_initial( - resource_group_name=resource_group_name, - server_name=server_name, - configuration_name=configuration_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Configuration", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - if polling is True: - polling_method: AsyncPollingMethod = cast( - AsyncPollingMethod, - AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[_models.Configuration].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.Configuration]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _put_initial( - self, - resource_group_name: str, - server_name: str, - configuration_name: str, - parameters: Union[_models.ConfigurationForUpdate, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "ConfigurationForUpdate") - - _request = build_put_request( - resource_group_name=resource_group_name, - server_name=server_name, - configuration_name=configuration_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize( - _models.ErrorResponse, - pipeline_response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - response_headers = {} - if response.status_code == 202: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @overload - async def begin_put( - self, - resource_group_name: str, - server_name: str, - configuration_name: str, - parameters: _models.ConfigurationForUpdate, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.Configuration]: - """Updates, using Put verb, the value assigned to a specific modifiable configuration (also known - as server parameter) of a server. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param configuration_name: Name of the configuration (also known as server parameter). - Required. - :type configuration_name: str - :param parameters: Parameters required to update the value of a specific modifiable - configuration (also known as server parameter). Required. - :type parameters: ~azure.mgmt.postgresqlflexibleservers.models.ConfigurationForUpdate - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either Configuration or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.postgresqlflexibleservers.models.Configuration] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_put( - self, - resource_group_name: str, - server_name: str, - configuration_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.Configuration]: - """Updates, using Put verb, the value assigned to a specific modifiable configuration (also known - as server parameter) of a server. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param configuration_name: Name of the configuration (also known as server parameter). - Required. - :type configuration_name: str - :param parameters: Parameters required to update the value of a specific modifiable - configuration (also known as server parameter). Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either Configuration or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.postgresqlflexibleservers.models.Configuration] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_put( - self, - resource_group_name: str, - server_name: str, - configuration_name: str, - parameters: Union[_models.ConfigurationForUpdate, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.Configuration]: - """Updates, using Put verb, the value assigned to a specific modifiable configuration (also known - as server parameter) of a server. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param configuration_name: Name of the configuration (also known as server parameter). - Required. - :type configuration_name: str - :param parameters: Parameters required to update the value of a specific modifiable - configuration (also known as server parameter). Is either a ConfigurationForUpdate type or a - IO[bytes] type. Required. - :type parameters: ~azure.mgmt.postgresqlflexibleservers.models.ConfigurationForUpdate or - IO[bytes] - :return: An instance of AsyncLROPoller that returns either Configuration or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.postgresqlflexibleservers.models.Configuration] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.Configuration] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._put_initial( - resource_group_name=resource_group_name, - server_name=server_name, - configuration_name=configuration_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Configuration", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - if polling is True: - polling_method: AsyncPollingMethod = cast( - AsyncPollingMethod, - AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[_models.Configuration].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.Configuration]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) diff --git a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/azure/mgmt/postgresqlflexibleservers/aio/operations/_databases_operations.py b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/azure/mgmt/postgresqlflexibleservers/aio/operations/_databases_operations.py deleted file mode 100644 index 6b4d8c7166c2..000000000000 --- a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/azure/mgmt/postgresqlflexibleservers/aio/operations/_databases_operations.py +++ /dev/null @@ -1,568 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from collections.abc import MutableMapping -from io import IOBase -from typing import Any, AsyncIterator, Callable, IO, Optional, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core import AsyncPipelineClient -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import AsyncHttpResponse, HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling - -from ... import models as _models -from ..._utils.serialization import Deserializer, Serializer -from ...operations._databases_operations import ( - build_create_request, - build_delete_request, - build_get_request, - build_list_by_server_request, -) -from .._configuration import PostgreSQLManagementClientConfiguration - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] -List = list - - -class DatabasesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.postgresqlflexibleservers.aio.PostgreSQLManagementClient`'s - :attr:`databases` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: PostgreSQLManagementClientConfiguration = ( - input_args.pop(0) if input_args else kwargs.pop("config") - ) - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - async def _create_initial( - self, - resource_group_name: str, - server_name: str, - database_name: str, - parameters: Union[_models.Database, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "Database") - - _request = build_create_request( - resource_group_name=resource_group_name, - server_name=server_name, - database_name=database_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize( - _models.ErrorResponse, - pipeline_response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - response_headers = {} - if response.status_code == 202: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @overload - async def begin_create( - self, - resource_group_name: str, - server_name: str, - database_name: str, - parameters: _models.Database, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.Database]: - """Creates a new database. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param database_name: Name of the database (case-sensitive). Exact database names can be - retrieved by getting the list of all existing databases in a server. Required. - :type database_name: str - :param parameters: Parameters required to create a new database. Required. - :type parameters: ~azure.mgmt.postgresqlflexibleservers.models.Database - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either Database or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.postgresqlflexibleservers.models.Database] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_create( - self, - resource_group_name: str, - server_name: str, - database_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.Database]: - """Creates a new database. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param database_name: Name of the database (case-sensitive). Exact database names can be - retrieved by getting the list of all existing databases in a server. Required. - :type database_name: str - :param parameters: Parameters required to create a new database. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either Database or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.postgresqlflexibleservers.models.Database] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_create( - self, - resource_group_name: str, - server_name: str, - database_name: str, - parameters: Union[_models.Database, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.Database]: - """Creates a new database. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param database_name: Name of the database (case-sensitive). Exact database names can be - retrieved by getting the list of all existing databases in a server. Required. - :type database_name: str - :param parameters: Parameters required to create a new database. Is either a Database type or a - IO[bytes] type. Required. - :type parameters: ~azure.mgmt.postgresqlflexibleservers.models.Database or IO[bytes] - :return: An instance of AsyncLROPoller that returns either Database or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.postgresqlflexibleservers.models.Database] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.Database] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._create_initial( - resource_group_name=resource_group_name, - server_name=server_name, - database_name=database_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Database", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - if polling is True: - polling_method: AsyncPollingMethod = cast( - AsyncPollingMethod, - AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[_models.Database].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.Database]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _delete_initial( - self, resource_group_name: str, server_name: str, database_name: str, **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_delete_request( - resource_group_name=resource_group_name, - server_name=server_name, - database_name=database_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [202, 204]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize( - _models.ErrorResponse, - pipeline_response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - response_headers = {} - if response.status_code == 202: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def begin_delete( - self, resource_group_name: str, server_name: str, database_name: str, **kwargs: Any - ) -> AsyncLROPoller[None]: - """Deletes an existing database. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param database_name: Name of the database (case-sensitive). Exact database names can be - retrieved by getting the list of all existing databases in a server. Required. - :type database_name: str - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._delete_initial( - resource_group_name=resource_group_name, - server_name=server_name, - database_name=database_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: AsyncPollingMethod = cast( - AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - @distributed_trace_async - async def get( - self, resource_group_name: str, server_name: str, database_name: str, **kwargs: Any - ) -> _models.Database: - """Gets information about an existing database. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param database_name: Name of the database (case-sensitive). Exact database names can be - retrieved by getting the list of all existing databases in a server. Required. - :type database_name: str - :return: Database or the result of cls(response) - :rtype: ~azure.mgmt.postgresqlflexibleservers.models.Database - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.Database] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - server_name=server_name, - database_name=database_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize( - _models.ErrorResponse, - pipeline_response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("Database", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def list_by_server( - self, resource_group_name: str, server_name: str, **kwargs: Any - ) -> AsyncItemPaged["_models.Database"]: - """Lists all databases in a server. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :return: An iterator like instance of either Database or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.postgresqlflexibleservers.models.Database] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.DatabaseList] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_by_server_request( - resource_group_name=resource_group_name, - server_name=server_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("DatabaseList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize( - _models.ErrorResponse, - pipeline_response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) diff --git a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/azure/mgmt/postgresqlflexibleservers/aio/operations/_firewall_rules_operations.py b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/azure/mgmt/postgresqlflexibleservers/aio/operations/_firewall_rules_operations.py deleted file mode 100644 index afef4ce1e291..000000000000 --- a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/azure/mgmt/postgresqlflexibleservers/aio/operations/_firewall_rules_operations.py +++ /dev/null @@ -1,563 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from collections.abc import MutableMapping -from io import IOBase -from typing import Any, AsyncIterator, Callable, IO, Optional, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core import AsyncPipelineClient -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import AsyncHttpResponse, HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling - -from ... import models as _models -from ..._utils.serialization import Deserializer, Serializer -from ...operations._firewall_rules_operations import ( - build_create_or_update_request, - build_delete_request, - build_get_request, - build_list_by_server_request, -) -from .._configuration import PostgreSQLManagementClientConfiguration - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] -List = list - - -class FirewallRulesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.postgresqlflexibleservers.aio.PostgreSQLManagementClient`'s - :attr:`firewall_rules` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: PostgreSQLManagementClientConfiguration = ( - input_args.pop(0) if input_args else kwargs.pop("config") - ) - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - async def _create_or_update_initial( - self, - resource_group_name: str, - server_name: str, - firewall_rule_name: str, - parameters: Union[_models.FirewallRule, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "FirewallRule") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - server_name=server_name, - firewall_rule_name=firewall_rule_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize( - _models.ErrorResponse, - pipeline_response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - response_headers = {} - if response.status_code == 202: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - server_name: str, - firewall_rule_name: str, - parameters: _models.FirewallRule, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.FirewallRule]: - """Creates a new firewall rule or updates an existing firewall rule. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param firewall_rule_name: Name of the firewall rule. Required. - :type firewall_rule_name: str - :param parameters: Parameters required for creating or updating a firewall rule. Required. - :type parameters: ~azure.mgmt.postgresqlflexibleservers.models.FirewallRule - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either FirewallRule or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.postgresqlflexibleservers.models.FirewallRule] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - server_name: str, - firewall_rule_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.FirewallRule]: - """Creates a new firewall rule or updates an existing firewall rule. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param firewall_rule_name: Name of the firewall rule. Required. - :type firewall_rule_name: str - :param parameters: Parameters required for creating or updating a firewall rule. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either FirewallRule or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.postgresqlflexibleservers.models.FirewallRule] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_create_or_update( - self, - resource_group_name: str, - server_name: str, - firewall_rule_name: str, - parameters: Union[_models.FirewallRule, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.FirewallRule]: - """Creates a new firewall rule or updates an existing firewall rule. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param firewall_rule_name: Name of the firewall rule. Required. - :type firewall_rule_name: str - :param parameters: Parameters required for creating or updating a firewall rule. Is either a - FirewallRule type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.postgresqlflexibleservers.models.FirewallRule or IO[bytes] - :return: An instance of AsyncLROPoller that returns either FirewallRule or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.postgresqlflexibleservers.models.FirewallRule] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.FirewallRule] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._create_or_update_initial( - resource_group_name=resource_group_name, - server_name=server_name, - firewall_rule_name=firewall_rule_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("FirewallRule", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - if polling is True: - polling_method: AsyncPollingMethod = cast( - AsyncPollingMethod, - AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[_models.FirewallRule].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.FirewallRule]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _delete_initial( - self, resource_group_name: str, server_name: str, firewall_rule_name: str, **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_delete_request( - resource_group_name=resource_group_name, - server_name=server_name, - firewall_rule_name=firewall_rule_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [202, 204]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize( - _models.ErrorResponse, - pipeline_response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - response_headers = {} - if response.status_code == 202: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def begin_delete( - self, resource_group_name: str, server_name: str, firewall_rule_name: str, **kwargs: Any - ) -> AsyncLROPoller[None]: - """Deletes an existing firewall rule. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param firewall_rule_name: Name of the firewall rule. Required. - :type firewall_rule_name: str - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._delete_initial( - resource_group_name=resource_group_name, - server_name=server_name, - firewall_rule_name=firewall_rule_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: AsyncPollingMethod = cast( - AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - @distributed_trace_async - async def get( - self, resource_group_name: str, server_name: str, firewall_rule_name: str, **kwargs: Any - ) -> _models.FirewallRule: - """Gets information about a firewall rule in a server. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param firewall_rule_name: Name of the firewall rule. Required. - :type firewall_rule_name: str - :return: FirewallRule or the result of cls(response) - :rtype: ~azure.mgmt.postgresqlflexibleservers.models.FirewallRule - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.FirewallRule] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - server_name=server_name, - firewall_rule_name=firewall_rule_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize( - _models.ErrorResponse, - pipeline_response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("FirewallRule", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def list_by_server( - self, resource_group_name: str, server_name: str, **kwargs: Any - ) -> AsyncItemPaged["_models.FirewallRule"]: - """Lists information about all firewall rules in a server. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :return: An iterator like instance of either FirewallRule or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.postgresqlflexibleservers.models.FirewallRule] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.FirewallRuleList] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_by_server_request( - resource_group_name=resource_group_name, - server_name=server_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("FirewallRuleList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize( - _models.ErrorResponse, - pipeline_response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) diff --git a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/azure/mgmt/postgresqlflexibleservers/aio/operations/_migrations_operations.py b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/azure/mgmt/postgresqlflexibleservers/aio/operations/_migrations_operations.py deleted file mode 100644 index e28231e7539b..000000000000 --- a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/azure/mgmt/postgresqlflexibleservers/aio/operations/_migrations_operations.py +++ /dev/null @@ -1,732 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from collections.abc import MutableMapping -from io import IOBase -from typing import Any, Callable, IO, Optional, TypeVar, Union, overload -import urllib.parse - -from azure.core import AsyncPipelineClient -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.rest import AsyncHttpResponse, HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._utils.serialization import Deserializer, Serializer -from ...operations._migrations_operations import ( - build_cancel_request, - build_check_name_availability_request, - build_create_request, - build_get_request, - build_list_by_target_server_request, - build_update_request, -) -from .._configuration import PostgreSQLManagementClientConfiguration - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] -List = list - - -class MigrationsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.postgresqlflexibleservers.aio.PostgreSQLManagementClient`'s - :attr:`migrations` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: PostgreSQLManagementClientConfiguration = ( - input_args.pop(0) if input_args else kwargs.pop("config") - ) - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @overload - async def create( - self, - resource_group_name: str, - server_name: str, - migration_name: str, - parameters: _models.Migration, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.Migration: - """Creates a new migration. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param migration_name: Name of migration. Required. - :type migration_name: str - :param parameters: Parameters required for creating a migration. Required. - :type parameters: ~azure.mgmt.postgresqlflexibleservers.models.Migration - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: Migration or the result of cls(response) - :rtype: ~azure.mgmt.postgresqlflexibleservers.models.Migration - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def create( - self, - resource_group_name: str, - server_name: str, - migration_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.Migration: - """Creates a new migration. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param migration_name: Name of migration. Required. - :type migration_name: str - :param parameters: Parameters required for creating a migration. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: Migration or the result of cls(response) - :rtype: ~azure.mgmt.postgresqlflexibleservers.models.Migration - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def create( - self, - resource_group_name: str, - server_name: str, - migration_name: str, - parameters: Union[_models.Migration, IO[bytes]], - **kwargs: Any - ) -> _models.Migration: - """Creates a new migration. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param migration_name: Name of migration. Required. - :type migration_name: str - :param parameters: Parameters required for creating a migration. Is either a Migration type or - a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.postgresqlflexibleservers.models.Migration or IO[bytes] - :return: Migration or the result of cls(response) - :rtype: ~azure.mgmt.postgresqlflexibleservers.models.Migration - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.Migration] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "Migration") - - _request = build_create_request( - resource_group_name=resource_group_name, - server_name=server_name, - migration_name=migration_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize( - _models.ErrorResponse, - pipeline_response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("Migration", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def get( - self, resource_group_name: str, server_name: str, migration_name: str, **kwargs: Any - ) -> _models.Migration: - """Gets information about a migration. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param migration_name: Name of migration. Required. - :type migration_name: str - :return: Migration or the result of cls(response) - :rtype: ~azure.mgmt.postgresqlflexibleservers.models.Migration - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.Migration] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - server_name=server_name, - migration_name=migration_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize( - _models.ErrorResponse, - pipeline_response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("Migration", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def update( - self, - resource_group_name: str, - server_name: str, - migration_name: str, - parameters: _models.MigrationResourceForPatch, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.Migration: - """Updates an existing migration. The request body can contain one to many of the mutable - properties present in the migration definition. Certain property updates initiate migration - state transitions. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param migration_name: Name of migration. Required. - :type migration_name: str - :param parameters: Parameters required to update an existing migration. Required. - :type parameters: ~azure.mgmt.postgresqlflexibleservers.models.MigrationResourceForPatch - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: Migration or the result of cls(response) - :rtype: ~azure.mgmt.postgresqlflexibleservers.models.Migration - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def update( - self, - resource_group_name: str, - server_name: str, - migration_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.Migration: - """Updates an existing migration. The request body can contain one to many of the mutable - properties present in the migration definition. Certain property updates initiate migration - state transitions. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param migration_name: Name of migration. Required. - :type migration_name: str - :param parameters: Parameters required to update an existing migration. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: Migration or the result of cls(response) - :rtype: ~azure.mgmt.postgresqlflexibleservers.models.Migration - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def update( - self, - resource_group_name: str, - server_name: str, - migration_name: str, - parameters: Union[_models.MigrationResourceForPatch, IO[bytes]], - **kwargs: Any - ) -> _models.Migration: - """Updates an existing migration. The request body can contain one to many of the mutable - properties present in the migration definition. Certain property updates initiate migration - state transitions. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param migration_name: Name of migration. Required. - :type migration_name: str - :param parameters: Parameters required to update an existing migration. Is either a - MigrationResourceForPatch type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.postgresqlflexibleservers.models.MigrationResourceForPatch or - IO[bytes] - :return: Migration or the result of cls(response) - :rtype: ~azure.mgmt.postgresqlflexibleservers.models.Migration - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.Migration] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "MigrationResourceForPatch") - - _request = build_update_request( - resource_group_name=resource_group_name, - server_name=server_name, - migration_name=migration_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize( - _models.ErrorResponse, - pipeline_response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("Migration", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def cancel( - self, resource_group_name: str, server_name: str, migration_name: str, **kwargs: Any - ) -> Optional[_models.Migration]: - """Cancels an active migration. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param migration_name: Name of migration. Required. - :type migration_name: str - :return: Migration or None or the result of cls(response) - :rtype: ~azure.mgmt.postgresqlflexibleservers.models.Migration or None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[Optional[_models.Migration]] = kwargs.pop("cls", None) - - _request = build_cancel_request( - resource_group_name=resource_group_name, - server_name=server_name, - migration_name=migration_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize( - _models.ErrorResponse, - pipeline_response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize("Migration", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def list_by_target_server( - self, - resource_group_name: str, - server_name: str, - migration_list_filter: Optional[Union[str, _models.MigrationListFilter]] = None, - **kwargs: Any - ) -> AsyncItemPaged["_models.Migration"]: - """Lists all migrations of a target flexible server. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param migration_list_filter: Migration list filter. Indicates if the request should retrieve - only active migrations or all migrations. Defaults to Active. Known values are: "Active" and - "All". Default value is None. - :type migration_list_filter: str or - ~azure.mgmt.postgresqlflexibleservers.models.MigrationListFilter - :return: An iterator like instance of either Migration or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.postgresqlflexibleservers.models.Migration] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.MigrationList] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_by_target_server_request( - resource_group_name=resource_group_name, - server_name=server_name, - subscription_id=self._config.subscription_id, - migration_list_filter=migration_list_filter, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("MigrationList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize( - _models.ErrorResponse, - pipeline_response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @overload - async def check_name_availability( - self, - resource_group_name: str, - server_name: str, - parameters: _models.MigrationNameAvailability, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.MigrationNameAvailability: - """Check the validity and availability of the given name, to assign it to a new migration. - - Checks if a proposed migration name is valid and available. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param parameters: Parameters required to check if a migration name is valid and available. - Required. - :type parameters: ~azure.mgmt.postgresqlflexibleservers.models.MigrationNameAvailability - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: MigrationNameAvailability or the result of cls(response) - :rtype: ~azure.mgmt.postgresqlflexibleservers.models.MigrationNameAvailability - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def check_name_availability( - self, - resource_group_name: str, - server_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.MigrationNameAvailability: - """Check the validity and availability of the given name, to assign it to a new migration. - - Checks if a proposed migration name is valid and available. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param parameters: Parameters required to check if a migration name is valid and available. - Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: MigrationNameAvailability or the result of cls(response) - :rtype: ~azure.mgmt.postgresqlflexibleservers.models.MigrationNameAvailability - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def check_name_availability( - self, - resource_group_name: str, - server_name: str, - parameters: Union[_models.MigrationNameAvailability, IO[bytes]], - **kwargs: Any - ) -> _models.MigrationNameAvailability: - """Check the validity and availability of the given name, to assign it to a new migration. - - Checks if a proposed migration name is valid and available. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param parameters: Parameters required to check if a migration name is valid and available. Is - either a MigrationNameAvailability type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.postgresqlflexibleservers.models.MigrationNameAvailability or - IO[bytes] - :return: MigrationNameAvailability or the result of cls(response) - :rtype: ~azure.mgmt.postgresqlflexibleservers.models.MigrationNameAvailability - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.MigrationNameAvailability] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "MigrationNameAvailability") - - _request = build_check_name_availability_request( - resource_group_name=resource_group_name, - server_name=server_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize( - _models.ErrorResponse, - pipeline_response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("MigrationNameAvailability", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/azure/mgmt/postgresqlflexibleservers/aio/operations/_name_availability_operations.py b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/azure/mgmt/postgresqlflexibleservers/aio/operations/_name_availability_operations.py deleted file mode 100644 index c9a106edb2e6..000000000000 --- a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/azure/mgmt/postgresqlflexibleservers/aio/operations/_name_availability_operations.py +++ /dev/null @@ -1,285 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from collections.abc import MutableMapping -from io import IOBase -from typing import Any, Callable, IO, Optional, TypeVar, Union, overload - -from azure.core import AsyncPipelineClient -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.rest import AsyncHttpResponse, HttpRequest -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._utils.serialization import Deserializer, Serializer -from ...operations._name_availability_operations import build_check_globally_request, build_check_with_location_request -from .._configuration import PostgreSQLManagementClientConfiguration - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] -List = list - - -class NameAvailabilityOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.postgresqlflexibleservers.aio.PostgreSQLManagementClient`'s - :attr:`name_availability` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: PostgreSQLManagementClientConfiguration = ( - input_args.pop(0) if input_args else kwargs.pop("config") - ) - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @overload - async def check_globally( - self, parameters: _models.CheckNameAvailabilityRequest, *, content_type: str = "application/json", **kwargs: Any - ) -> _models.NameAvailabilityModel: - """Checks the validity and availability of the given name, to assign it to a new server or to use - it as the base name of a new pair of virtual endpoints. - - :param parameters: Parameters required to check if a given name is valid and available to - assign it to a new server or to use it as the base name of a new pair of virtual endpoints. - Required. - :type parameters: ~azure.mgmt.postgresqlflexibleservers.models.CheckNameAvailabilityRequest - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: NameAvailabilityModel or the result of cls(response) - :rtype: ~azure.mgmt.postgresqlflexibleservers.models.NameAvailabilityModel - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def check_globally( - self, parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> _models.NameAvailabilityModel: - """Checks the validity and availability of the given name, to assign it to a new server or to use - it as the base name of a new pair of virtual endpoints. - - :param parameters: Parameters required to check if a given name is valid and available to - assign it to a new server or to use it as the base name of a new pair of virtual endpoints. - Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: NameAvailabilityModel or the result of cls(response) - :rtype: ~azure.mgmt.postgresqlflexibleservers.models.NameAvailabilityModel - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def check_globally( - self, parameters: Union[_models.CheckNameAvailabilityRequest, IO[bytes]], **kwargs: Any - ) -> _models.NameAvailabilityModel: - """Checks the validity and availability of the given name, to assign it to a new server or to use - it as the base name of a new pair of virtual endpoints. - - :param parameters: Parameters required to check if a given name is valid and available to - assign it to a new server or to use it as the base name of a new pair of virtual endpoints. Is - either a CheckNameAvailabilityRequest type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.postgresqlflexibleservers.models.CheckNameAvailabilityRequest or - IO[bytes] - :return: NameAvailabilityModel or the result of cls(response) - :rtype: ~azure.mgmt.postgresqlflexibleservers.models.NameAvailabilityModel - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.NameAvailabilityModel] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "CheckNameAvailabilityRequest") - - _request = build_check_globally_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize( - _models.ErrorResponse, - pipeline_response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("NameAvailabilityModel", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def check_with_location( - self, - location_name: str, - parameters: _models.CheckNameAvailabilityRequest, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.NameAvailabilityModel: - """Check the availability of name for resource. - - :param location_name: The name of the location. Required. - :type location_name: str - :param parameters: Parameters required to check if a given name is valid and available to - assign it to a new server or to use it as the base name of a new pair of virtual endpoints. - Required. - :type parameters: ~azure.mgmt.postgresqlflexibleservers.models.CheckNameAvailabilityRequest - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: NameAvailabilityModel or the result of cls(response) - :rtype: ~azure.mgmt.postgresqlflexibleservers.models.NameAvailabilityModel - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def check_with_location( - self, location_name: str, parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> _models.NameAvailabilityModel: - """Check the availability of name for resource. - - :param location_name: The name of the location. Required. - :type location_name: str - :param parameters: Parameters required to check if a given name is valid and available to - assign it to a new server or to use it as the base name of a new pair of virtual endpoints. - Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: NameAvailabilityModel or the result of cls(response) - :rtype: ~azure.mgmt.postgresqlflexibleservers.models.NameAvailabilityModel - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def check_with_location( - self, location_name: str, parameters: Union[_models.CheckNameAvailabilityRequest, IO[bytes]], **kwargs: Any - ) -> _models.NameAvailabilityModel: - """Check the availability of name for resource. - - :param location_name: The name of the location. Required. - :type location_name: str - :param parameters: Parameters required to check if a given name is valid and available to - assign it to a new server or to use it as the base name of a new pair of virtual endpoints. Is - either a CheckNameAvailabilityRequest type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.postgresqlflexibleservers.models.CheckNameAvailabilityRequest or - IO[bytes] - :return: NameAvailabilityModel or the result of cls(response) - :rtype: ~azure.mgmt.postgresqlflexibleservers.models.NameAvailabilityModel - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.NameAvailabilityModel] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "CheckNameAvailabilityRequest") - - _request = build_check_with_location_request( - location_name=location_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize( - _models.ErrorResponse, - pipeline_response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("NameAvailabilityModel", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/azure/mgmt/postgresqlflexibleservers/aio/operations/_operations.py b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/azure/mgmt/postgresqlflexibleservers/aio/operations/_operations.py index bc6c66ad71c0..7233674acd3d 100644 --- a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/azure/mgmt/postgresqlflexibleservers/aio/operations/_operations.py +++ b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/azure/mgmt/postgresqlflexibleservers/aio/operations/_operations.py @@ -1,12 +1,15 @@ +# pylint: disable=line-too-long,useless-suppression,too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from collections.abc import MutableMapping -from typing import Any, Callable, Optional, TypeVar +from io import IOBase +import json +from typing import Any, AsyncIterator, Callable, IO, Optional, TypeVar, Union, cast, overload import urllib.parse from azure.core import AsyncPipelineClient @@ -17,21 +20,97 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.pipeline import PipelineResponse +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models +from ..._utils.model_base import SdkJSONEncoder, _deserialize, _failsafe_deserialize from ..._utils.serialization import Deserializer, Serializer -from ...operations._operations import build_list_request +from ..._validation import api_version_validation +from ...operations._operations import ( + build_administrators_microsoft_entra_create_or_update_request, + build_administrators_microsoft_entra_delete_request, + build_administrators_microsoft_entra_get_request, + build_administrators_microsoft_entra_list_by_server_request, + build_advanced_threat_protection_settings_get_request, + build_advanced_threat_protection_settings_list_by_server_request, + build_backups_automatic_and_on_demand_create_request, + build_backups_automatic_and_on_demand_delete_request, + build_backups_automatic_and_on_demand_get_request, + build_backups_automatic_and_on_demand_list_by_server_request, + build_backups_long_term_retention_check_prerequisites_request, + build_backups_long_term_retention_get_request, + build_backups_long_term_retention_list_by_server_request, + build_backups_long_term_retention_start_request, + build_capabilities_by_location_list_request, + build_capabilities_by_server_list_request, + build_captured_logs_list_by_server_request, + build_configurations_get_request, + build_configurations_list_by_server_request, + build_configurations_put_request, + build_configurations_update_request, + build_databases_create_request, + build_databases_delete_request, + build_databases_get_request, + build_databases_list_by_server_request, + build_firewall_rules_create_or_update_request, + build_firewall_rules_delete_request, + build_firewall_rules_get_request, + build_firewall_rules_list_by_server_request, + build_migrations_cancel_request, + build_migrations_check_name_availability_request, + build_migrations_create_request, + build_migrations_get_request, + build_migrations_list_by_target_server_request, + build_migrations_update_request, + build_name_availability_check_globally_request, + build_name_availability_check_with_location_request, + build_operations_list_request, + build_private_dns_zone_suffix_get_request, + build_private_endpoint_connections_delete_request, + build_private_endpoint_connections_get_request, + build_private_endpoint_connections_list_by_server_request, + build_private_endpoint_connections_update_request, + build_private_link_resources_get_request, + build_private_link_resources_list_by_server_request, + build_quota_usages_list_request, + build_replicas_list_by_server_request, + build_server_threat_protection_settings_create_or_update_request, + build_servers_create_or_update_request, + build_servers_delete_request, + build_servers_get_request, + build_servers_list_by_resource_group_request, + build_servers_list_by_subscription_request, + build_servers_migrate_network_mode_request, + build_servers_restart_request, + build_servers_start_request, + build_servers_stop_request, + build_servers_update_request, + build_tuning_options_get_request, + build_tuning_options_list_by_server_request, + build_tuning_options_list_recommendations_request, + build_virtual_endpoints_create_request, + build_virtual_endpoints_delete_request, + build_virtual_endpoints_get_request, + build_virtual_endpoints_list_by_server_request, + build_virtual_endpoints_update_request, + build_virtual_network_subnet_usage_list_request, +) from .._configuration import PostgreSQLManagementClientConfiguration T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] +JSON = MutableMapping[str, Any] List = list @@ -45,8 +124,6 @@ class Operations: :attr:`operations` attribute. """ - models = _models - def __init__(self, *args, **kwargs) -> None: input_args = list(args) self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") @@ -60,16 +137,662 @@ def __init__(self, *args, **kwargs) -> None: def list(self, **kwargs: Any) -> AsyncItemPaged["_models.Operation"]: """Lists all available REST API operations. - :return: An iterator like instance of either Operation or the result of cls(response) + :return: An iterator like instance of Operation :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.postgresqlflexibleservers.models.Operation] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.Operation]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_operations_list_request( + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize(List[_models.Operation], deserialized.get("value", [])) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class MigrationsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.postgresqlflexibleservers.aio.PostgreSQLManagementClient`'s + :attr:`migrations` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: PostgreSQLManagementClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async + async def get( + self, resource_group_name: str, server_name: str, migration_name: str, **kwargs: Any + ) -> _models.Migration: + """Gets information about a migration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param migration_name: Name of migration. Required. + :type migration_name: str + :return: Migration. The Migration is compatible with MutableMapping + :rtype: ~azure.mgmt.postgresqlflexibleservers.models.Migration + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.Migration] = kwargs.pop("cls", None) + + _request = build_migrations_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + migration_name=migration_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() + else: + deserialized = _deserialize(_models.Migration, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + async def create( + self, + resource_group_name: str, + server_name: str, + migration_name: str, + parameters: _models.Migration, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Migration: + """Creates a new migration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param migration_name: Name of migration. Required. + :type migration_name: str + :param parameters: Parameters required for creating a migration. Required. + :type parameters: ~azure.mgmt.postgresqlflexibleservers.models.Migration + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: Migration. The Migration is compatible with MutableMapping + :rtype: ~azure.mgmt.postgresqlflexibleservers.models.Migration + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create( + self, + resource_group_name: str, + server_name: str, + migration_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Migration: + """Creates a new migration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param migration_name: Name of migration. Required. + :type migration_name: str + :param parameters: Parameters required for creating a migration. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: Migration. The Migration is compatible with MutableMapping + :rtype: ~azure.mgmt.postgresqlflexibleservers.models.Migration + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create( + self, + resource_group_name: str, + server_name: str, + migration_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Migration: + """Creates a new migration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param migration_name: Name of migration. Required. + :type migration_name: str + :param parameters: Parameters required for creating a migration. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: Migration. The Migration is compatible with MutableMapping + :rtype: ~azure.mgmt.postgresqlflexibleservers.models.Migration + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create( + self, + resource_group_name: str, + server_name: str, + migration_name: str, + parameters: Union[_models.Migration, JSON, IO[bytes]], + **kwargs: Any + ) -> _models.Migration: + """Creates a new migration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param migration_name: Name of migration. Required. + :type migration_name: str + :param parameters: Parameters required for creating a migration. Is one of the following types: + Migration, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.postgresqlflexibleservers.models.Migration or JSON or IO[bytes] + :return: Migration. The Migration is compatible with MutableMapping + :rtype: ~azure.mgmt.postgresqlflexibleservers.models.Migration + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Migration] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_migrations_create_request( + resource_group_name=resource_group_name, + server_name=server_name, + migration_name=migration_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() + else: + deserialized = _deserialize(_models.Migration, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + async def update( + self, + resource_group_name: str, + server_name: str, + migration_name: str, + parameters: _models.MigrationResourceForPatch, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Migration: + """Updates an existing migration. The request body can contain one to many of the mutable + properties present in the migration definition. Certain property updates initiate migration + state transitions. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param migration_name: Name of migration. Required. + :type migration_name: str + :param parameters: Parameters required to update an existing migration. Required. + :type parameters: ~azure.mgmt.postgresqlflexibleservers.models.MigrationResourceForPatch + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: Migration. The Migration is compatible with MutableMapping + :rtype: ~azure.mgmt.postgresqlflexibleservers.models.Migration + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + server_name: str, + migration_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Migration: + """Updates an existing migration. The request body can contain one to many of the mutable + properties present in the migration definition. Certain property updates initiate migration + state transitions. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param migration_name: Name of migration. Required. + :type migration_name: str + :param parameters: Parameters required to update an existing migration. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: Migration. The Migration is compatible with MutableMapping + :rtype: ~azure.mgmt.postgresqlflexibleservers.models.Migration + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + server_name: str, + migration_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Migration: + """Updates an existing migration. The request body can contain one to many of the mutable + properties present in the migration definition. Certain property updates initiate migration + state transitions. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param migration_name: Name of migration. Required. + :type migration_name: str + :param parameters: Parameters required to update an existing migration. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: Migration. The Migration is compatible with MutableMapping + :rtype: ~azure.mgmt.postgresqlflexibleservers.models.Migration + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + server_name: str, + migration_name: str, + parameters: Union[_models.MigrationResourceForPatch, JSON, IO[bytes]], + **kwargs: Any + ) -> _models.Migration: + """Updates an existing migration. The request body can contain one to many of the mutable + properties present in the migration definition. Certain property updates initiate migration + state transitions. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param migration_name: Name of migration. Required. + :type migration_name: str + :param parameters: Parameters required to update an existing migration. Is one of the following + types: MigrationResourceForPatch, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.postgresqlflexibleservers.models.MigrationResourceForPatch or + JSON or IO[bytes] + :return: Migration. The Migration is compatible with MutableMapping + :rtype: ~azure.mgmt.postgresqlflexibleservers.models.Migration + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Migration] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_migrations_update_request( + resource_group_name=resource_group_name, + server_name=server_name, + migration_name=migration_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() + else: + deserialized = _deserialize(_models.Migration, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def cancel( + self, resource_group_name: str, server_name: str, migration_name: str, **kwargs: Any + ) -> Optional[_models.Migration]: + """Cancels an active migration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param migration_name: Name of migration. Required. + :type migration_name: str + :return: Migration or None. The Migration is compatible with MutableMapping + :rtype: ~azure.mgmt.postgresqlflexibleservers.models.Migration or None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[Optional[_models.Migration]] = kwargs.pop("cls", None) + + _request = build_migrations_cancel_request( + resource_group_name=resource_group_name, + server_name=server_name, + migration_name=migration_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + if _stream: + deserialized = response.iter_bytes() + else: + deserialized = _deserialize(_models.Migration, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list_by_target_server( + self, + resource_group_name: str, + server_name: str, + *, + migration_list_filter: Optional[Union[str, _models.MigrationListFilter]] = None, + **kwargs: Any + ) -> AsyncItemPaged["_models.Migration"]: + """Lists all migrations of a target flexible server. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :keyword migration_list_filter: Migration list filter. Indicates if the request should retrieve + only active migrations or all migrations. Defaults to Active. Known values are: "Active" and + "All". Default value is None. + :paramtype migration_list_filter: str or + ~azure.mgmt.postgresqlflexibleservers.models.MigrationListFilter + :return: An iterator like instance of Migration + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.postgresqlflexibleservers.models.Migration] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.OperationList] = kwargs.pop("cls", None) + cls: ClsType[List[_models.Migration]] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -82,12 +805,21 @@ def list(self, **kwargs: Any) -> AsyncItemPaged["_models.Operation"]: def prepare_request(next_link=None): if not next_link: - _request = build_list_request( - api_version=api_version, + _request = build_migrations_list_by_target_server_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + migration_list_filter=migration_list_filter, + api_version=self._config.api_version, headers=_headers, params=_params, ) - _request.url = self._client.format_url(_request.url) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) else: # make call to next link with the client's api-version @@ -102,16 +834,21 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + return _request async def extract_data(pipeline_response): - deserialized = self._deserialize("OperationList", pipeline_response) - list_of_elem = deserialized.value + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize(List[_models.Migration], deserialized.get("value", [])) if cls: list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) async def get_next(next_link=None): _request = prepare_request(next_link) @@ -124,12 +861,8789 @@ async def get_next(next_link=None): if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize( + error = _failsafe_deserialize( _models.ErrorResponse, - pipeline_response, + response, ) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response return AsyncItemPaged(get_next, extract_data) + + @overload + async def check_name_availability( + self, + resource_group_name: str, + server_name: str, + parameters: _models.MigrationNameAvailability, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.MigrationNameAvailability: + """Check the validity and availability of the given name, to assign it to a new migration. + + Checks if a proposed migration name is valid and available. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param parameters: Parameters required to check if a migration name is valid and available. + Required. + :type parameters: ~azure.mgmt.postgresqlflexibleservers.models.MigrationNameAvailability + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: MigrationNameAvailability. The MigrationNameAvailability is compatible with + MutableMapping + :rtype: ~azure.mgmt.postgresqlflexibleservers.models.MigrationNameAvailability + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def check_name_availability( + self, + resource_group_name: str, + server_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.MigrationNameAvailability: + """Check the validity and availability of the given name, to assign it to a new migration. + + Checks if a proposed migration name is valid and available. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param parameters: Parameters required to check if a migration name is valid and available. + Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: MigrationNameAvailability. The MigrationNameAvailability is compatible with + MutableMapping + :rtype: ~azure.mgmt.postgresqlflexibleservers.models.MigrationNameAvailability + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def check_name_availability( + self, + resource_group_name: str, + server_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.MigrationNameAvailability: + """Check the validity and availability of the given name, to assign it to a new migration. + + Checks if a proposed migration name is valid and available. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param parameters: Parameters required to check if a migration name is valid and available. + Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: MigrationNameAvailability. The MigrationNameAvailability is compatible with + MutableMapping + :rtype: ~azure.mgmt.postgresqlflexibleservers.models.MigrationNameAvailability + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def check_name_availability( + self, + resource_group_name: str, + server_name: str, + parameters: Union[_models.MigrationNameAvailability, JSON, IO[bytes]], + **kwargs: Any + ) -> _models.MigrationNameAvailability: + """Check the validity and availability of the given name, to assign it to a new migration. + + Checks if a proposed migration name is valid and available. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param parameters: Parameters required to check if a migration name is valid and available. Is + one of the following types: MigrationNameAvailability, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.postgresqlflexibleservers.models.MigrationNameAvailability or + JSON or IO[bytes] + :return: MigrationNameAvailability. The MigrationNameAvailability is compatible with + MutableMapping + :rtype: ~azure.mgmt.postgresqlflexibleservers.models.MigrationNameAvailability + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.MigrationNameAvailability] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_migrations_check_name_availability_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() + else: + deserialized = _deserialize(_models.MigrationNameAvailability, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + +class ServersOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.postgresqlflexibleservers.aio.PostgreSQLManagementClient`'s + :attr:`servers` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: PostgreSQLManagementClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async + async def get(self, resource_group_name: str, server_name: str, **kwargs: Any) -> _models.Server: + """Gets information about an existing server. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :return: Server. The Server is compatible with MutableMapping + :rtype: ~azure.mgmt.postgresqlflexibleservers.models.Server + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.Server] = kwargs.pop("cls", None) + + _request = build_servers_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() + else: + deserialized = _deserialize(_models.Server, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + async def _create_or_update_initial( + self, + resource_group_name: str, + server_name: str, + parameters: Union[_models.Server, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_servers_create_or_update_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + parameters: _models.Server, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Server]: + """Creates a new server. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param parameters: Parameters required to create a new server or to update an existing server. + Required. + :type parameters: ~azure.mgmt.postgresqlflexibleservers.models.Server + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns Server. The Server is compatible with + MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.postgresqlflexibleservers.models.Server] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Server]: + """Creates a new server. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param parameters: Parameters required to create a new server or to update an existing server. + Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns Server. The Server is compatible with + MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.postgresqlflexibleservers.models.Server] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Server]: + """Creates a new server. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param parameters: Parameters required to create a new server or to update an existing server. + Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns Server. The Server is compatible with + MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.postgresqlflexibleservers.models.Server] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + parameters: Union[_models.Server, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.Server]: + """Creates a new server. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param parameters: Parameters required to create a new server or to update an existing server. + Is one of the following types: Server, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.postgresqlflexibleservers.models.Server or JSON or IO[bytes] + :return: An instance of AsyncLROPoller that returns Server. The Server is compatible with + MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.postgresqlflexibleservers.models.Server] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Server] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._create_or_update_initial( + resource_group_name=resource_group_name, + server_name=server_name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response_headers = {} + response = pipeline_response.http_response + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = _deserialize(_models.Server, response.json()) + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.Server].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.Server]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + async def _update_initial( + self, + resource_group_name: str, + server_name: str, + parameters: Union[_models.ServerForPatch, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_servers_update_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_update( + self, + resource_group_name: str, + server_name: str, + parameters: _models.ServerForPatch, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Server]: + """Updates an existing server. The request body can contain one or multiple of the properties + present in the normal server definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param parameters: Parameters required to update a server. Required. + :type parameters: ~azure.mgmt.postgresqlflexibleservers.models.ServerForPatch + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns Server. The Server is compatible with + MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.postgresqlflexibleservers.models.Server] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + server_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Server]: + """Updates an existing server. The request body can contain one or multiple of the properties + present in the normal server definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param parameters: Parameters required to update a server. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns Server. The Server is compatible with + MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.postgresqlflexibleservers.models.Server] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + server_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Server]: + """Updates an existing server. The request body can contain one or multiple of the properties + present in the normal server definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param parameters: Parameters required to update a server. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns Server. The Server is compatible with + MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.postgresqlflexibleservers.models.Server] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_update( + self, + resource_group_name: str, + server_name: str, + parameters: Union[_models.ServerForPatch, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.Server]: + """Updates an existing server. The request body can contain one or multiple of the properties + present in the normal server definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param parameters: Parameters required to update a server. Is one of the following types: + ServerForPatch, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.postgresqlflexibleservers.models.ServerForPatch or JSON or + IO[bytes] + :return: An instance of AsyncLROPoller that returns Server. The Server is compatible with + MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.postgresqlflexibleservers.models.Server] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Server] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._update_initial( + resource_group_name=resource_group_name, + server_name=server_name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response_headers = {} + response = pipeline_response.http_response + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = _deserialize(_models.Server, response.json()) + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.Server].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.Server]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + async def _delete_initial(self, resource_group_name: str, server_name: str, **kwargs: Any) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_servers_delete_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [202, 204]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def begin_delete(self, resource_group_name: str, server_name: str, **kwargs: Any) -> AsyncLROPoller[None]: + """Deletes or drops an existing server. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :return: An instance of AsyncLROPoller that returns None + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._delete_initial( + resource_group_name=resource_group_name, + server_name=server_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> AsyncItemPaged["_models.Server"]: + """Lists all servers in a resource group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :return: An iterator like instance of Server + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.postgresqlflexibleservers.models.Server] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.Server]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_servers_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize(List[_models.Server], deserialized.get("value", [])) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace + def list_by_subscription(self, **kwargs: Any) -> AsyncItemPaged["_models.Server"]: + """Lists all servers in a subscription. + + :return: An iterator like instance of Server + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.postgresqlflexibleservers.models.Server] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.Server]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_servers_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize(List[_models.Server], deserialized.get("value", [])) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + async def _restart_initial( + self, + resource_group_name: str, + server_name: str, + parameters: Optional[Union[_models.RestartParameter, JSON, IO[bytes]]] = None, + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + content_type = content_type if parameters else None + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" if parameters else None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + if parameters is not None: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + else: + _content = None + + _request = build_servers_restart_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_restart( + self, + resource_group_name: str, + server_name: str, + parameters: Optional[_models.RestartParameter] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Restarts PostgreSQL database engine in a server. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param parameters: Parameters to restart a server. Default value is None. + :type parameters: ~azure.mgmt.postgresqlflexibleservers.models.RestartParameter + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns None + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_restart( + self, + resource_group_name: str, + server_name: str, + parameters: Optional[JSON] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Restarts PostgreSQL database engine in a server. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param parameters: Parameters to restart a server. Default value is None. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns None + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_restart( + self, + resource_group_name: str, + server_name: str, + parameters: Optional[IO[bytes]] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Restarts PostgreSQL database engine in a server. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param parameters: Parameters to restart a server. Default value is None. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns None + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_restart( + self, + resource_group_name: str, + server_name: str, + parameters: Optional[Union[_models.RestartParameter, JSON, IO[bytes]]] = None, + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Restarts PostgreSQL database engine in a server. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param parameters: Parameters to restart a server. Is one of the following types: + RestartParameter, JSON, IO[bytes] Default value is None. + :type parameters: ~azure.mgmt.postgresqlflexibleservers.models.RestartParameter or JSON or + IO[bytes] + :return: An instance of AsyncLROPoller that returns None + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + content_type = content_type if parameters else None + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._restart_initial( + resource_group_name=resource_group_name, + server_name=server_name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + async def _start_initial(self, resource_group_name: str, server_name: str, **kwargs: Any) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_servers_start_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def begin_start(self, resource_group_name: str, server_name: str, **kwargs: Any) -> AsyncLROPoller[None]: + """Starts a stopped server. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :return: An instance of AsyncLROPoller that returns None + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._start_initial( + resource_group_name=resource_group_name, + server_name=server_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + async def _stop_initial(self, resource_group_name: str, server_name: str, **kwargs: Any) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_servers_stop_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def begin_stop(self, resource_group_name: str, server_name: str, **kwargs: Any) -> AsyncLROPoller[None]: + """Stops a server. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :return: An instance of AsyncLROPoller that returns None + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._stop_initial( + resource_group_name=resource_group_name, + server_name=server_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @api_version_validation( + method_added_on="2026-01-01-preview", + params_added_on={ + "2026-01-01-preview": ["api_version", "subscription_id", "resource_group_name", "server_name", "accept"] + }, + api_versions_list=["2026-01-01-preview"], + ) + async def _migrate_network_mode_initial( + self, resource_group_name: str, server_name: str, **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_servers_migrate_network_mode_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 200: + response_headers["x-ms-request-id"] = self._deserialize("str", response.headers.get("x-ms-request-id")) + + if response.status_code == 202: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + response_headers["x-ms-request-id"] = self._deserialize("str", response.headers.get("x-ms-request-id")) + + deserialized = response.iter_bytes() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + @api_version_validation( + method_added_on="2026-01-01-preview", + params_added_on={ + "2026-01-01-preview": ["api_version", "subscription_id", "resource_group_name", "server_name", "accept"] + }, + api_versions_list=["2026-01-01-preview"], + ) + async def begin_migrate_network_mode( + self, resource_group_name: str, server_name: str, **kwargs: Any + ) -> AsyncLROPoller[_models.MigrateNetworkStatus]: + """Migrates the network configuration of a PostgreSQL flexible server from customer owned VNET to + Microsoft owned VNET with support for private endpoints, or from Microsoft owned VNET with no + support for private endpoints to Microsoft owned VNET with support for private endpoints. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :return: An instance of AsyncLROPoller that returns MigrateNetworkStatus. The + MigrateNetworkStatus is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.postgresqlflexibleservers.models.MigrateNetworkStatus] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.MigrateNetworkStatus] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._migrate_network_mode_initial( + resource_group_name=resource_group_name, + server_name=server_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response_headers = {} + response = pipeline_response.http_response + response_headers["x-ms-request-id"] = self._deserialize("str", response.headers.get("x-ms-request-id")) + + deserialized = _deserialize(_models.MigrateNetworkStatus, response.json()) + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.MigrateNetworkStatus].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.MigrateNetworkStatus]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + +class ConfigurationsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.postgresqlflexibleservers.aio.PostgreSQLManagementClient`'s + :attr:`configurations` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: PostgreSQLManagementClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async + async def get( + self, resource_group_name: str, server_name: str, configuration_name: str, **kwargs: Any + ) -> _models.Configuration: + """Gets information about a specific configuration (also known as server parameter) of a server. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param configuration_name: Name of the configuration (also known as server parameter). + Required. + :type configuration_name: str + :return: Configuration. The Configuration is compatible with MutableMapping + :rtype: ~azure.mgmt.postgresqlflexibleservers.models.Configuration + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.Configuration] = kwargs.pop("cls", None) + + _request = build_configurations_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + configuration_name=configuration_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() + else: + deserialized = _deserialize(_models.Configuration, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + async def _put_initial( + self, + resource_group_name: str, + server_name: str, + configuration_name: str, + parameters: Union[_models.ConfigurationForUpdate, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_configurations_put_request( + resource_group_name=resource_group_name, + server_name=server_name, + configuration_name=configuration_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_put( + self, + resource_group_name: str, + server_name: str, + configuration_name: str, + parameters: _models.ConfigurationForUpdate, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Configuration]: + """Updates, using Put verb, the value assigned to a specific modifiable configuration (also known + as server parameter) of a server. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param configuration_name: Name of the configuration (also known as server parameter). + Required. + :type configuration_name: str + :param parameters: Parameters required to update the value of a specific modifiable + configuration (also known as server parameter). Required. + :type parameters: ~azure.mgmt.postgresqlflexibleservers.models.ConfigurationForUpdate + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns Configuration. The Configuration is + compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.postgresqlflexibleservers.models.Configuration] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_put( + self, + resource_group_name: str, + server_name: str, + configuration_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Configuration]: + """Updates, using Put verb, the value assigned to a specific modifiable configuration (also known + as server parameter) of a server. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param configuration_name: Name of the configuration (also known as server parameter). + Required. + :type configuration_name: str + :param parameters: Parameters required to update the value of a specific modifiable + configuration (also known as server parameter). Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns Configuration. The Configuration is + compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.postgresqlflexibleservers.models.Configuration] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_put( + self, + resource_group_name: str, + server_name: str, + configuration_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Configuration]: + """Updates, using Put verb, the value assigned to a specific modifiable configuration (also known + as server parameter) of a server. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param configuration_name: Name of the configuration (also known as server parameter). + Required. + :type configuration_name: str + :param parameters: Parameters required to update the value of a specific modifiable + configuration (also known as server parameter). Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns Configuration. The Configuration is + compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.postgresqlflexibleservers.models.Configuration] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_put( + self, + resource_group_name: str, + server_name: str, + configuration_name: str, + parameters: Union[_models.ConfigurationForUpdate, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.Configuration]: + """Updates, using Put verb, the value assigned to a specific modifiable configuration (also known + as server parameter) of a server. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param configuration_name: Name of the configuration (also known as server parameter). + Required. + :type configuration_name: str + :param parameters: Parameters required to update the value of a specific modifiable + configuration (also known as server parameter). Is one of the following types: + ConfigurationForUpdate, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.postgresqlflexibleservers.models.ConfigurationForUpdate or JSON + or IO[bytes] + :return: An instance of AsyncLROPoller that returns Configuration. The Configuration is + compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.postgresqlflexibleservers.models.Configuration] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Configuration] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._put_initial( + resource_group_name=resource_group_name, + server_name=server_name, + configuration_name=configuration_name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response_headers = {} + response = pipeline_response.http_response + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = _deserialize(_models.Configuration, response.json()) + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.Configuration].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.Configuration]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + async def _update_initial( + self, + resource_group_name: str, + server_name: str, + configuration_name: str, + parameters: Union[_models.ConfigurationForUpdate, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_configurations_update_request( + resource_group_name=resource_group_name, + server_name=server_name, + configuration_name=configuration_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_update( + self, + resource_group_name: str, + server_name: str, + configuration_name: str, + parameters: _models.ConfigurationForUpdate, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Configuration]: + """Updates the value assigned to a specific modifiable configuration (also known as server + parameter) of a server. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param configuration_name: Name of the configuration (also known as server parameter). + Required. + :type configuration_name: str + :param parameters: Parameters required to update the value of a specific modifiable + configuration (also known as server parameter). Required. + :type parameters: ~azure.mgmt.postgresqlflexibleservers.models.ConfigurationForUpdate + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns Configuration. The Configuration is + compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.postgresqlflexibleservers.models.Configuration] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + server_name: str, + configuration_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Configuration]: + """Updates the value assigned to a specific modifiable configuration (also known as server + parameter) of a server. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param configuration_name: Name of the configuration (also known as server parameter). + Required. + :type configuration_name: str + :param parameters: Parameters required to update the value of a specific modifiable + configuration (also known as server parameter). Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns Configuration. The Configuration is + compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.postgresqlflexibleservers.models.Configuration] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + server_name: str, + configuration_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Configuration]: + """Updates the value assigned to a specific modifiable configuration (also known as server + parameter) of a server. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param configuration_name: Name of the configuration (also known as server parameter). + Required. + :type configuration_name: str + :param parameters: Parameters required to update the value of a specific modifiable + configuration (also known as server parameter). Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns Configuration. The Configuration is + compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.postgresqlflexibleservers.models.Configuration] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_update( + self, + resource_group_name: str, + server_name: str, + configuration_name: str, + parameters: Union[_models.ConfigurationForUpdate, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.Configuration]: + """Updates the value assigned to a specific modifiable configuration (also known as server + parameter) of a server. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param configuration_name: Name of the configuration (also known as server parameter). + Required. + :type configuration_name: str + :param parameters: Parameters required to update the value of a specific modifiable + configuration (also known as server parameter). Is one of the following types: + ConfigurationForUpdate, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.postgresqlflexibleservers.models.ConfigurationForUpdate or JSON + or IO[bytes] + :return: An instance of AsyncLROPoller that returns Configuration. The Configuration is + compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.postgresqlflexibleservers.models.Configuration] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Configuration] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._update_initial( + resource_group_name=resource_group_name, + server_name=server_name, + configuration_name=configuration_name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response_headers = {} + response = pipeline_response.http_response + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = _deserialize(_models.Configuration, response.json()) + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.Configuration].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.Configuration]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + @distributed_trace + def list_by_server( + self, resource_group_name: str, server_name: str, **kwargs: Any + ) -> AsyncItemPaged["_models.Configuration"]: + """Lists all configurations (also known as server parameters) of a server. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :return: An iterator like instance of Configuration + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.postgresqlflexibleservers.models.Configuration] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.Configuration]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_configurations_list_by_server_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize(List[_models.Configuration], deserialized.get("value", [])) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class DatabasesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.postgresqlflexibleservers.aio.PostgreSQLManagementClient`'s + :attr:`databases` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: PostgreSQLManagementClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async + async def get( + self, resource_group_name: str, server_name: str, database_name: str, **kwargs: Any + ) -> _models.Database: + """Gets information about an existing database. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param database_name: Name of the database (case-sensitive). Exact database names can be + retrieved by getting the list of all existing databases in a server. Required. + :type database_name: str + :return: Database. The Database is compatible with MutableMapping + :rtype: ~azure.mgmt.postgresqlflexibleservers.models.Database + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.Database] = kwargs.pop("cls", None) + + _request = build_databases_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() + else: + deserialized = _deserialize(_models.Database, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + async def _create_initial( + self, + resource_group_name: str, + server_name: str, + database_name: str, + parameters: Union[_models.Database, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_databases_create_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_create( + self, + resource_group_name: str, + server_name: str, + database_name: str, + parameters: _models.Database, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Database]: + """Creates a new database. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param database_name: Name of the database (case-sensitive). Exact database names can be + retrieved by getting the list of all existing databases in a server. Required. + :type database_name: str + :param parameters: Parameters required to create a new database. Required. + :type parameters: ~azure.mgmt.postgresqlflexibleservers.models.Database + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns Database. The Database is compatible with + MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.postgresqlflexibleservers.models.Database] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create( + self, + resource_group_name: str, + server_name: str, + database_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Database]: + """Creates a new database. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param database_name: Name of the database (case-sensitive). Exact database names can be + retrieved by getting the list of all existing databases in a server. Required. + :type database_name: str + :param parameters: Parameters required to create a new database. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns Database. The Database is compatible with + MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.postgresqlflexibleservers.models.Database] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create( + self, + resource_group_name: str, + server_name: str, + database_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Database]: + """Creates a new database. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param database_name: Name of the database (case-sensitive). Exact database names can be + retrieved by getting the list of all existing databases in a server. Required. + :type database_name: str + :param parameters: Parameters required to create a new database. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns Database. The Database is compatible with + MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.postgresqlflexibleservers.models.Database] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create( + self, + resource_group_name: str, + server_name: str, + database_name: str, + parameters: Union[_models.Database, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.Database]: + """Creates a new database. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param database_name: Name of the database (case-sensitive). Exact database names can be + retrieved by getting the list of all existing databases in a server. Required. + :type database_name: str + :param parameters: Parameters required to create a new database. Is one of the following types: + Database, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.postgresqlflexibleservers.models.Database or JSON or IO[bytes] + :return: An instance of AsyncLROPoller that returns Database. The Database is compatible with + MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.postgresqlflexibleservers.models.Database] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Database] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._create_initial( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response_headers = {} + response = pipeline_response.http_response + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = _deserialize(_models.Database, response.json()) + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.Database].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.Database]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + async def _delete_initial( + self, resource_group_name: str, server_name: str, database_name: str, **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_databases_delete_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [202, 204]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def begin_delete( + self, resource_group_name: str, server_name: str, database_name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Deletes an existing database. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param database_name: Name of the database (case-sensitive). Exact database names can be + retrieved by getting the list of all existing databases in a server. Required. + :type database_name: str + :return: An instance of AsyncLROPoller that returns None + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._delete_initial( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + def list_by_server( + self, resource_group_name: str, server_name: str, **kwargs: Any + ) -> AsyncItemPaged["_models.Database"]: + """Lists all databases in a server. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :return: An iterator like instance of Database + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.postgresqlflexibleservers.models.Database] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.Database]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_databases_list_by_server_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize(List[_models.Database], deserialized.get("value", [])) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class FirewallRulesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.postgresqlflexibleservers.aio.PostgreSQLManagementClient`'s + :attr:`firewall_rules` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: PostgreSQLManagementClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async + async def get( + self, resource_group_name: str, server_name: str, firewall_rule_name: str, **kwargs: Any + ) -> _models.FirewallRule: + """Gets information about a firewall rule in a server. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param firewall_rule_name: Name of the firewall rule. Required. + :type firewall_rule_name: str + :return: FirewallRule. The FirewallRule is compatible with MutableMapping + :rtype: ~azure.mgmt.postgresqlflexibleservers.models.FirewallRule + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.FirewallRule] = kwargs.pop("cls", None) + + _request = build_firewall_rules_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + firewall_rule_name=firewall_rule_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() + else: + deserialized = _deserialize(_models.FirewallRule, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + async def _create_or_update_initial( + self, + resource_group_name: str, + server_name: str, + firewall_rule_name: str, + parameters: Union[_models.FirewallRule, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_firewall_rules_create_or_update_request( + resource_group_name=resource_group_name, + server_name=server_name, + firewall_rule_name=firewall_rule_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + firewall_rule_name: str, + parameters: _models.FirewallRule, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.FirewallRule]: + """Creates a new firewall rule or updates an existing firewall rule. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param firewall_rule_name: Name of the firewall rule. Required. + :type firewall_rule_name: str + :param parameters: Parameters required for creating or updating a firewall rule. Required. + :type parameters: ~azure.mgmt.postgresqlflexibleservers.models.FirewallRule + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns FirewallRule. The FirewallRule is + compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.postgresqlflexibleservers.models.FirewallRule] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + firewall_rule_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.FirewallRule]: + """Creates a new firewall rule or updates an existing firewall rule. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param firewall_rule_name: Name of the firewall rule. Required. + :type firewall_rule_name: str + :param parameters: Parameters required for creating or updating a firewall rule. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns FirewallRule. The FirewallRule is + compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.postgresqlflexibleservers.models.FirewallRule] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + firewall_rule_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.FirewallRule]: + """Creates a new firewall rule or updates an existing firewall rule. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param firewall_rule_name: Name of the firewall rule. Required. + :type firewall_rule_name: str + :param parameters: Parameters required for creating or updating a firewall rule. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns FirewallRule. The FirewallRule is + compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.postgresqlflexibleservers.models.FirewallRule] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + firewall_rule_name: str, + parameters: Union[_models.FirewallRule, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.FirewallRule]: + """Creates a new firewall rule or updates an existing firewall rule. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param firewall_rule_name: Name of the firewall rule. Required. + :type firewall_rule_name: str + :param parameters: Parameters required for creating or updating a firewall rule. Is one of the + following types: FirewallRule, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.postgresqlflexibleservers.models.FirewallRule or JSON or + IO[bytes] + :return: An instance of AsyncLROPoller that returns FirewallRule. The FirewallRule is + compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.postgresqlflexibleservers.models.FirewallRule] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.FirewallRule] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._create_or_update_initial( + resource_group_name=resource_group_name, + server_name=server_name, + firewall_rule_name=firewall_rule_name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response_headers = {} + response = pipeline_response.http_response + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = _deserialize(_models.FirewallRule, response.json()) + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.FirewallRule].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.FirewallRule]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + async def _delete_initial( + self, resource_group_name: str, server_name: str, firewall_rule_name: str, **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_firewall_rules_delete_request( + resource_group_name=resource_group_name, + server_name=server_name, + firewall_rule_name=firewall_rule_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [202, 204]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def begin_delete( + self, resource_group_name: str, server_name: str, firewall_rule_name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Deletes an existing firewall rule. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param firewall_rule_name: Name of the firewall rule. Required. + :type firewall_rule_name: str + :return: An instance of AsyncLROPoller that returns None + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._delete_initial( + resource_group_name=resource_group_name, + server_name=server_name, + firewall_rule_name=firewall_rule_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + def list_by_server( + self, resource_group_name: str, server_name: str, **kwargs: Any + ) -> AsyncItemPaged["_models.FirewallRule"]: + """Lists information about all firewall rules in a server. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :return: An iterator like instance of FirewallRule + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.postgresqlflexibleservers.models.FirewallRule] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.FirewallRule]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_firewall_rules_list_by_server_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize(List[_models.FirewallRule], deserialized.get("value", [])) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class PrivateEndpointConnectionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.postgresqlflexibleservers.aio.PostgreSQLManagementClient`'s + :attr:`private_endpoint_connections` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: PostgreSQLManagementClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async + async def get( + self, resource_group_name: str, server_name: str, private_endpoint_connection_name: str, **kwargs: Any + ) -> _models.PrivateEndpointConnection: + """Gets a private endpoint connection. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection associated + with the Azure resource. Required. + :type private_endpoint_connection_name: str + :return: PrivateEndpointConnection. The PrivateEndpointConnection is compatible with + MutableMapping + :rtype: ~azure.mgmt.postgresqlflexibleservers.models.PrivateEndpointConnection + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) + + _request = build_private_endpoint_connections_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + private_endpoint_connection_name=private_endpoint_connection_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() + else: + deserialized = _deserialize(_models.PrivateEndpointConnection, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + async def _update_initial( + self, + resource_group_name: str, + server_name: str, + private_endpoint_connection_name: str, + parameters: Union[_models.PrivateEndpointConnection, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_private_endpoint_connections_update_request( + resource_group_name=resource_group_name, + server_name=server_name, + private_endpoint_connection_name=private_endpoint_connection_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_update( + self, + resource_group_name: str, + server_name: str, + private_endpoint_connection_name: str, + parameters: _models.PrivateEndpointConnection, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.PrivateEndpointConnection]: + """Approves or rejects a private endpoint connection. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection associated + with the Azure resource. Required. + :type private_endpoint_connection_name: str + :param parameters: Parameters required to update a private endpoint connection. Required. + :type parameters: ~azure.mgmt.postgresqlflexibleservers.models.PrivateEndpointConnection + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns PrivateEndpointConnection. The + PrivateEndpointConnection is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.postgresqlflexibleservers.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + server_name: str, + private_endpoint_connection_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.PrivateEndpointConnection]: + """Approves or rejects a private endpoint connection. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection associated + with the Azure resource. Required. + :type private_endpoint_connection_name: str + :param parameters: Parameters required to update a private endpoint connection. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns PrivateEndpointConnection. The + PrivateEndpointConnection is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.postgresqlflexibleservers.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + server_name: str, + private_endpoint_connection_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.PrivateEndpointConnection]: + """Approves or rejects a private endpoint connection. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection associated + with the Azure resource. Required. + :type private_endpoint_connection_name: str + :param parameters: Parameters required to update a private endpoint connection. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns PrivateEndpointConnection. The + PrivateEndpointConnection is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.postgresqlflexibleservers.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_update( + self, + resource_group_name: str, + server_name: str, + private_endpoint_connection_name: str, + parameters: Union[_models.PrivateEndpointConnection, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.PrivateEndpointConnection]: + """Approves or rejects a private endpoint connection. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection associated + with the Azure resource. Required. + :type private_endpoint_connection_name: str + :param parameters: Parameters required to update a private endpoint connection. Is one of the + following types: PrivateEndpointConnection, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.postgresqlflexibleservers.models.PrivateEndpointConnection or + JSON or IO[bytes] + :return: An instance of AsyncLROPoller that returns PrivateEndpointConnection. The + PrivateEndpointConnection is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.postgresqlflexibleservers.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._update_initial( + resource_group_name=resource_group_name, + server_name=server_name, + private_endpoint_connection_name=private_endpoint_connection_name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response_headers = {} + response = pipeline_response.http_response + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = _deserialize(_models.PrivateEndpointConnection, response.json()) + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.PrivateEndpointConnection].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.PrivateEndpointConnection]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + async def _delete_initial( + self, resource_group_name: str, server_name: str, private_endpoint_connection_name: str, **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_private_endpoint_connections_delete_request( + resource_group_name=resource_group_name, + server_name=server_name, + private_endpoint_connection_name=private_endpoint_connection_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [202, 204]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def begin_delete( + self, resource_group_name: str, server_name: str, private_endpoint_connection_name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Deletes a private endpoint connection. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection associated + with the Azure resource. Required. + :type private_endpoint_connection_name: str + :return: An instance of AsyncLROPoller that returns None + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._delete_initial( + resource_group_name=resource_group_name, + server_name=server_name, + private_endpoint_connection_name=private_endpoint_connection_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + def list_by_server( + self, resource_group_name: str, server_name: str, **kwargs: Any + ) -> AsyncItemPaged["_models.PrivateEndpointConnection"]: + """Lists all private endpoint connections on a server. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :return: An iterator like instance of PrivateEndpointConnection + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.postgresqlflexibleservers.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.PrivateEndpointConnection]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_private_endpoint_connections_list_by_server_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize(List[_models.PrivateEndpointConnection], deserialized.get("value", [])) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class PrivateLinkResourcesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.postgresqlflexibleservers.aio.PostgreSQLManagementClient`'s + :attr:`private_link_resources` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: PostgreSQLManagementClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async + async def get( + self, resource_group_name: str, server_name: str, group_name: str, **kwargs: Any + ) -> _models.PrivateLinkResource: + """Gets a private link resource for PostgreSQL server. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param group_name: The name of the private link resource. Required. + :type group_name: str + :return: PrivateLinkResource. The PrivateLinkResource is compatible with MutableMapping + :rtype: ~azure.mgmt.postgresqlflexibleservers.models.PrivateLinkResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.PrivateLinkResource] = kwargs.pop("cls", None) + + _request = build_private_link_resources_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + group_name=group_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() + else: + deserialized = _deserialize(_models.PrivateLinkResource, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list_by_server( + self, resource_group_name: str, server_name: str, **kwargs: Any + ) -> AsyncItemPaged["_models.PrivateLinkResource"]: + """Gets the private link resources for PostgreSQL server. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :return: An iterator like instance of PrivateLinkResource + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.postgresqlflexibleservers.models.PrivateLinkResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.PrivateLinkResource]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_private_link_resources_list_by_server_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize(List[_models.PrivateLinkResource], deserialized.get("value", [])) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class VirtualEndpointsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.postgresqlflexibleservers.aio.PostgreSQLManagementClient`'s + :attr:`virtual_endpoints` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: PostgreSQLManagementClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async + async def get( + self, resource_group_name: str, server_name: str, virtual_endpoint_name: str, **kwargs: Any + ) -> _models.VirtualEndpoint: + """Gets information about a pair of virtual endpoints. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param virtual_endpoint_name: Base name of the virtual endpoints. Required. + :type virtual_endpoint_name: str + :return: VirtualEndpoint. The VirtualEndpoint is compatible with MutableMapping + :rtype: ~azure.mgmt.postgresqlflexibleservers.models.VirtualEndpoint + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.VirtualEndpoint] = kwargs.pop("cls", None) + + _request = build_virtual_endpoints_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + virtual_endpoint_name=virtual_endpoint_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() + else: + deserialized = _deserialize(_models.VirtualEndpoint, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + async def _create_initial( + self, + resource_group_name: str, + server_name: str, + virtual_endpoint_name: str, + parameters: Union[_models.VirtualEndpoint, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_virtual_endpoints_create_request( + resource_group_name=resource_group_name, + server_name=server_name, + virtual_endpoint_name=virtual_endpoint_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_create( + self, + resource_group_name: str, + server_name: str, + virtual_endpoint_name: str, + parameters: _models.VirtualEndpoint, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.VirtualEndpoint]: + """Creates a pair of virtual endpoints for a server. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param virtual_endpoint_name: Base name of the virtual endpoints. Required. + :type virtual_endpoint_name: str + :param parameters: Parameters required to create or update a pair of virtual endpoints. + Required. + :type parameters: ~azure.mgmt.postgresqlflexibleservers.models.VirtualEndpoint + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns VirtualEndpoint. The VirtualEndpoint is + compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.postgresqlflexibleservers.models.VirtualEndpoint] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create( + self, + resource_group_name: str, + server_name: str, + virtual_endpoint_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.VirtualEndpoint]: + """Creates a pair of virtual endpoints for a server. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param virtual_endpoint_name: Base name of the virtual endpoints. Required. + :type virtual_endpoint_name: str + :param parameters: Parameters required to create or update a pair of virtual endpoints. + Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns VirtualEndpoint. The VirtualEndpoint is + compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.postgresqlflexibleservers.models.VirtualEndpoint] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create( + self, + resource_group_name: str, + server_name: str, + virtual_endpoint_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.VirtualEndpoint]: + """Creates a pair of virtual endpoints for a server. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param virtual_endpoint_name: Base name of the virtual endpoints. Required. + :type virtual_endpoint_name: str + :param parameters: Parameters required to create or update a pair of virtual endpoints. + Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns VirtualEndpoint. The VirtualEndpoint is + compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.postgresqlflexibleservers.models.VirtualEndpoint] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create( + self, + resource_group_name: str, + server_name: str, + virtual_endpoint_name: str, + parameters: Union[_models.VirtualEndpoint, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.VirtualEndpoint]: + """Creates a pair of virtual endpoints for a server. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param virtual_endpoint_name: Base name of the virtual endpoints. Required. + :type virtual_endpoint_name: str + :param parameters: Parameters required to create or update a pair of virtual endpoints. Is one + of the following types: VirtualEndpoint, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.postgresqlflexibleservers.models.VirtualEndpoint or JSON or + IO[bytes] + :return: An instance of AsyncLROPoller that returns VirtualEndpoint. The VirtualEndpoint is + compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.postgresqlflexibleservers.models.VirtualEndpoint] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.VirtualEndpoint] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._create_initial( + resource_group_name=resource_group_name, + server_name=server_name, + virtual_endpoint_name=virtual_endpoint_name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response_headers = {} + response = pipeline_response.http_response + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = _deserialize(_models.VirtualEndpoint, response.json()) + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.VirtualEndpoint].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.VirtualEndpoint]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + async def _update_initial( + self, + resource_group_name: str, + server_name: str, + virtual_endpoint_name: str, + parameters: Union[_models.VirtualEndpointResourceForPatch, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_virtual_endpoints_update_request( + resource_group_name=resource_group_name, + server_name=server_name, + virtual_endpoint_name=virtual_endpoint_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_update( + self, + resource_group_name: str, + server_name: str, + virtual_endpoint_name: str, + parameters: _models.VirtualEndpointResourceForPatch, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.VirtualEndpoint]: + """Updates a pair of virtual endpoints for a server. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param virtual_endpoint_name: Base name of the virtual endpoints. Required. + :type virtual_endpoint_name: str + :param parameters: Parameters required to update a pair of virtual endpoints. Required. + :type parameters: ~azure.mgmt.postgresqlflexibleservers.models.VirtualEndpointResourceForPatch + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns VirtualEndpoint. The VirtualEndpoint is + compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.postgresqlflexibleservers.models.VirtualEndpoint] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + server_name: str, + virtual_endpoint_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.VirtualEndpoint]: + """Updates a pair of virtual endpoints for a server. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param virtual_endpoint_name: Base name of the virtual endpoints. Required. + :type virtual_endpoint_name: str + :param parameters: Parameters required to update a pair of virtual endpoints. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns VirtualEndpoint. The VirtualEndpoint is + compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.postgresqlflexibleservers.models.VirtualEndpoint] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + server_name: str, + virtual_endpoint_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.VirtualEndpoint]: + """Updates a pair of virtual endpoints for a server. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param virtual_endpoint_name: Base name of the virtual endpoints. Required. + :type virtual_endpoint_name: str + :param parameters: Parameters required to update a pair of virtual endpoints. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns VirtualEndpoint. The VirtualEndpoint is + compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.postgresqlflexibleservers.models.VirtualEndpoint] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_update( + self, + resource_group_name: str, + server_name: str, + virtual_endpoint_name: str, + parameters: Union[_models.VirtualEndpointResourceForPatch, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.VirtualEndpoint]: + """Updates a pair of virtual endpoints for a server. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param virtual_endpoint_name: Base name of the virtual endpoints. Required. + :type virtual_endpoint_name: str + :param parameters: Parameters required to update a pair of virtual endpoints. Is one of the + following types: VirtualEndpointResourceForPatch, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.postgresqlflexibleservers.models.VirtualEndpointResourceForPatch + or JSON or IO[bytes] + :return: An instance of AsyncLROPoller that returns VirtualEndpoint. The VirtualEndpoint is + compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.postgresqlflexibleservers.models.VirtualEndpoint] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.VirtualEndpoint] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._update_initial( + resource_group_name=resource_group_name, + server_name=server_name, + virtual_endpoint_name=virtual_endpoint_name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response_headers = {} + response = pipeline_response.http_response + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = _deserialize(_models.VirtualEndpoint, response.json()) + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.VirtualEndpoint].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.VirtualEndpoint]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + async def _delete_initial( + self, resource_group_name: str, server_name: str, virtual_endpoint_name: str, **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_virtual_endpoints_delete_request( + resource_group_name=resource_group_name, + server_name=server_name, + virtual_endpoint_name=virtual_endpoint_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [202, 204]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def begin_delete( + self, resource_group_name: str, server_name: str, virtual_endpoint_name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Deletes a pair of virtual endpoints. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param virtual_endpoint_name: Base name of the virtual endpoints. Required. + :type virtual_endpoint_name: str + :return: An instance of AsyncLROPoller that returns None + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._delete_initial( + resource_group_name=resource_group_name, + server_name=server_name, + virtual_endpoint_name=virtual_endpoint_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + def list_by_server( + self, resource_group_name: str, server_name: str, **kwargs: Any + ) -> AsyncItemPaged["_models.VirtualEndpoint"]: + """Lists pair of virtual endpoints associated to a server. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :return: An iterator like instance of VirtualEndpoint + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.postgresqlflexibleservers.models.VirtualEndpoint] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.VirtualEndpoint]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_virtual_endpoints_list_by_server_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize(List[_models.VirtualEndpoint], deserialized.get("value", [])) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class AdministratorsMicrosoftEntraOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.postgresqlflexibleservers.aio.PostgreSQLManagementClient`'s + :attr:`administrators_microsoft_entra` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: PostgreSQLManagementClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async + async def get( + self, resource_group_name: str, server_name: str, object_id: str, **kwargs: Any + ) -> _models.AdministratorMicrosoftEntra: + """Gets information about a server administrator associated to a Microsoft Entra principal. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param object_id: Object identifier of the Microsoft Entra principal. Required. + :type object_id: str + :return: AdministratorMicrosoftEntra. The AdministratorMicrosoftEntra is compatible with + MutableMapping + :rtype: ~azure.mgmt.postgresqlflexibleservers.models.AdministratorMicrosoftEntra + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.AdministratorMicrosoftEntra] = kwargs.pop("cls", None) + + _request = build_administrators_microsoft_entra_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + object_id=object_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() + else: + deserialized = _deserialize(_models.AdministratorMicrosoftEntra, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + async def _create_or_update_initial( + self, + resource_group_name: str, + server_name: str, + object_id: str, + parameters: Union[_models.AdministratorMicrosoftEntraAdd, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_administrators_microsoft_entra_create_or_update_request( + resource_group_name=resource_group_name, + server_name=server_name, + object_id=object_id, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + object_id: str, + parameters: _models.AdministratorMicrosoftEntraAdd, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.AdministratorMicrosoftEntra]: + """Creates a new server administrator associated to a Microsoft Entra principal. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param object_id: Object identifier of the Microsoft Entra principal. Required. + :type object_id: str + :param parameters: Required parameters for adding a server administrator associated to a + Microsoft Entra principal. Required. + :type parameters: ~azure.mgmt.postgresqlflexibleservers.models.AdministratorMicrosoftEntraAdd + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns AdministratorMicrosoftEntra. The + AdministratorMicrosoftEntra is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.postgresqlflexibleservers.models.AdministratorMicrosoftEntra] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + object_id: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.AdministratorMicrosoftEntra]: + """Creates a new server administrator associated to a Microsoft Entra principal. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param object_id: Object identifier of the Microsoft Entra principal. Required. + :type object_id: str + :param parameters: Required parameters for adding a server administrator associated to a + Microsoft Entra principal. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns AdministratorMicrosoftEntra. The + AdministratorMicrosoftEntra is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.postgresqlflexibleservers.models.AdministratorMicrosoftEntra] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + object_id: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.AdministratorMicrosoftEntra]: + """Creates a new server administrator associated to a Microsoft Entra principal. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param object_id: Object identifier of the Microsoft Entra principal. Required. + :type object_id: str + :param parameters: Required parameters for adding a server administrator associated to a + Microsoft Entra principal. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns AdministratorMicrosoftEntra. The + AdministratorMicrosoftEntra is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.postgresqlflexibleservers.models.AdministratorMicrosoftEntra] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + object_id: str, + parameters: Union[_models.AdministratorMicrosoftEntraAdd, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.AdministratorMicrosoftEntra]: + """Creates a new server administrator associated to a Microsoft Entra principal. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param object_id: Object identifier of the Microsoft Entra principal. Required. + :type object_id: str + :param parameters: Required parameters for adding a server administrator associated to a + Microsoft Entra principal. Is one of the following types: AdministratorMicrosoftEntraAdd, JSON, + IO[bytes] Required. + :type parameters: ~azure.mgmt.postgresqlflexibleservers.models.AdministratorMicrosoftEntraAdd + or JSON or IO[bytes] + :return: An instance of AsyncLROPoller that returns AdministratorMicrosoftEntra. The + AdministratorMicrosoftEntra is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.postgresqlflexibleservers.models.AdministratorMicrosoftEntra] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.AdministratorMicrosoftEntra] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._create_or_update_initial( + resource_group_name=resource_group_name, + server_name=server_name, + object_id=object_id, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response_headers = {} + response = pipeline_response.http_response + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = _deserialize(_models.AdministratorMicrosoftEntra, response.json()) + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.AdministratorMicrosoftEntra].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.AdministratorMicrosoftEntra]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + async def _delete_initial( + self, resource_group_name: str, server_name: str, object_id: str, **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_administrators_microsoft_entra_delete_request( + resource_group_name=resource_group_name, + server_name=server_name, + object_id=object_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [202, 204]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def begin_delete( + self, resource_group_name: str, server_name: str, object_id: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Deletes an existing server administrator associated to a Microsoft Entra principal. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param object_id: Object identifier of the Microsoft Entra principal. Required. + :type object_id: str + :return: An instance of AsyncLROPoller that returns None + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._delete_initial( + resource_group_name=resource_group_name, + server_name=server_name, + object_id=object_id, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + def list_by_server( + self, resource_group_name: str, server_name: str, **kwargs: Any + ) -> AsyncItemPaged["_models.AdministratorMicrosoftEntra"]: + """List all server administrators associated to a Microsoft Entra principal. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :return: An iterator like instance of AdministratorMicrosoftEntra + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.postgresqlflexibleservers.models.AdministratorMicrosoftEntra] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.AdministratorMicrosoftEntra]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_administrators_microsoft_entra_list_by_server_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize(List[_models.AdministratorMicrosoftEntra], deserialized.get("value", [])) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class CapabilitiesByServerOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.postgresqlflexibleservers.aio.PostgreSQLManagementClient`'s + :attr:`capabilities_by_server` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: PostgreSQLManagementClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list(self, resource_group_name: str, server_name: str, **kwargs: Any) -> AsyncItemPaged["_models.Capability"]: + """Lists the capabilities available for a given server. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :return: An iterator like instance of Capability + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.postgresqlflexibleservers.models.Capability] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.Capability]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_capabilities_by_server_list_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize(List[_models.Capability], deserialized.get("value", [])) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class CapturedLogsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.postgresqlflexibleservers.aio.PostgreSQLManagementClient`'s + :attr:`captured_logs` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: PostgreSQLManagementClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list_by_server( + self, resource_group_name: str, server_name: str, **kwargs: Any + ) -> AsyncItemPaged["_models.CapturedLog"]: + """Lists all captured logs for download in a server. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :return: An iterator like instance of CapturedLog + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.postgresqlflexibleservers.models.CapturedLog] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.CapturedLog]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_captured_logs_list_by_server_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize(List[_models.CapturedLog], deserialized.get("value", [])) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class BackupsLongTermRetentionOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.postgresqlflexibleservers.aio.PostgreSQLManagementClient`'s + :attr:`backups_long_term_retention` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: PostgreSQLManagementClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @overload + async def check_prerequisites( + self, + resource_group_name: str, + server_name: str, + parameters: _models.LtrPreBackupRequest, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.LtrPreBackupResponse: + """Performs all checks required for a long term retention backup operation to succeed. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param parameters: Request body for operation. Required. + :type parameters: ~azure.mgmt.postgresqlflexibleservers.models.LtrPreBackupRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: LtrPreBackupResponse. The LtrPreBackupResponse is compatible with MutableMapping + :rtype: ~azure.mgmt.postgresqlflexibleservers.models.LtrPreBackupResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def check_prerequisites( + self, + resource_group_name: str, + server_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.LtrPreBackupResponse: + """Performs all checks required for a long term retention backup operation to succeed. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param parameters: Request body for operation. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: LtrPreBackupResponse. The LtrPreBackupResponse is compatible with MutableMapping + :rtype: ~azure.mgmt.postgresqlflexibleservers.models.LtrPreBackupResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def check_prerequisites( + self, + resource_group_name: str, + server_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.LtrPreBackupResponse: + """Performs all checks required for a long term retention backup operation to succeed. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param parameters: Request body for operation. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: LtrPreBackupResponse. The LtrPreBackupResponse is compatible with MutableMapping + :rtype: ~azure.mgmt.postgresqlflexibleservers.models.LtrPreBackupResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def check_prerequisites( + self, + resource_group_name: str, + server_name: str, + parameters: Union[_models.LtrPreBackupRequest, JSON, IO[bytes]], + **kwargs: Any + ) -> _models.LtrPreBackupResponse: + """Performs all checks required for a long term retention backup operation to succeed. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param parameters: Request body for operation. Is one of the following types: + LtrPreBackupRequest, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.postgresqlflexibleservers.models.LtrPreBackupRequest or JSON or + IO[bytes] + :return: LtrPreBackupResponse. The LtrPreBackupResponse is compatible with MutableMapping + :rtype: ~azure.mgmt.postgresqlflexibleservers.models.LtrPreBackupResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.LtrPreBackupResponse] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_backups_long_term_retention_check_prerequisites_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["x-ms-request-id"] = self._deserialize("str", response.headers.get("x-ms-request-id")) + + if _stream: + deserialized = response.iter_bytes() + else: + deserialized = _deserialize(_models.LtrPreBackupResponse, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + async def _start_initial( + self, + resource_group_name: str, + server_name: str, + parameters: Union[_models.BackupsLongTermRetentionRequest, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_backups_long_term_retention_start_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 200: + response_headers["x-ms-request-id"] = self._deserialize("str", response.headers.get("x-ms-request-id")) + + if response.status_code == 202: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + response_headers["x-ms-request-id"] = self._deserialize("str", response.headers.get("x-ms-request-id")) + + deserialized = response.iter_bytes() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_start( + self, + resource_group_name: str, + server_name: str, + parameters: _models.BackupsLongTermRetentionRequest, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.BackupsLongTermRetentionResponse]: + """Initiates a long term retention backup. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param parameters: Request body for operation. Required. + :type parameters: ~azure.mgmt.postgresqlflexibleservers.models.BackupsLongTermRetentionRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns BackupsLongTermRetentionResponse. The + BackupsLongTermRetentionResponse is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.postgresqlflexibleservers.models.BackupsLongTermRetentionResponse] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_start( + self, + resource_group_name: str, + server_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.BackupsLongTermRetentionResponse]: + """Initiates a long term retention backup. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param parameters: Request body for operation. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns BackupsLongTermRetentionResponse. The + BackupsLongTermRetentionResponse is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.postgresqlflexibleservers.models.BackupsLongTermRetentionResponse] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_start( + self, + resource_group_name: str, + server_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.BackupsLongTermRetentionResponse]: + """Initiates a long term retention backup. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param parameters: Request body for operation. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns BackupsLongTermRetentionResponse. The + BackupsLongTermRetentionResponse is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.postgresqlflexibleservers.models.BackupsLongTermRetentionResponse] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_start( + self, + resource_group_name: str, + server_name: str, + parameters: Union[_models.BackupsLongTermRetentionRequest, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.BackupsLongTermRetentionResponse]: + """Initiates a long term retention backup. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param parameters: Request body for operation. Is one of the following types: + BackupsLongTermRetentionRequest, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.postgresqlflexibleservers.models.BackupsLongTermRetentionRequest + or JSON or IO[bytes] + :return: An instance of AsyncLROPoller that returns BackupsLongTermRetentionResponse. The + BackupsLongTermRetentionResponse is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.postgresqlflexibleservers.models.BackupsLongTermRetentionResponse] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.BackupsLongTermRetentionResponse] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._start_initial( + resource_group_name=resource_group_name, + server_name=server_name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response_headers = {} + response = pipeline_response.http_response + response_headers["x-ms-request-id"] = self._deserialize("str", response.headers.get("x-ms-request-id")) + + deserialized = _deserialize(_models.BackupsLongTermRetentionResponse, response.json()) + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.BackupsLongTermRetentionResponse].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.BackupsLongTermRetentionResponse]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + @distributed_trace_async + async def get( + self, resource_group_name: str, server_name: str, backup_name: str, **kwargs: Any + ) -> _models.BackupsLongTermRetentionOperation: + """Gets the results of a long retention backup operation for a server. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param backup_name: The name of the backup. Required. + :type backup_name: str + :return: BackupsLongTermRetentionOperation. The BackupsLongTermRetentionOperation is compatible + with MutableMapping + :rtype: ~azure.mgmt.postgresqlflexibleservers.models.BackupsLongTermRetentionOperation + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.BackupsLongTermRetentionOperation] = kwargs.pop("cls", None) + + _request = build_backups_long_term_retention_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + backup_name=backup_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() + else: + deserialized = _deserialize(_models.BackupsLongTermRetentionOperation, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list_by_server( + self, resource_group_name: str, server_name: str, **kwargs: Any + ) -> AsyncItemPaged["_models.BackupsLongTermRetentionOperation"]: + """Lists the results of the long term retention backup operations for a server. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :return: An iterator like instance of BackupsLongTermRetentionOperation + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.postgresqlflexibleservers.models.BackupsLongTermRetentionOperation] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.BackupsLongTermRetentionOperation]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_backups_long_term_retention_list_by_server_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize(List[_models.BackupsLongTermRetentionOperation], deserialized.get("value", [])) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class ReplicasOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.postgresqlflexibleservers.aio.PostgreSQLManagementClient`'s + :attr:`replicas` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: PostgreSQLManagementClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list_by_server( + self, resource_group_name: str, server_name: str, **kwargs: Any + ) -> AsyncItemPaged["_models.Server"]: + """Lists all read replicas of a server. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :return: An iterator like instance of Server + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.postgresqlflexibleservers.models.Server] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.Server]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_replicas_list_by_server_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize(List[_models.Server], deserialized.get("value", [])) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class AdvancedThreatProtectionSettingsOperations: # pylint: disable=name-too-long + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.postgresqlflexibleservers.aio.PostgreSQLManagementClient`'s + :attr:`advanced_threat_protection_settings` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: PostgreSQLManagementClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async + async def get( + self, + resource_group_name: str, + server_name: str, + threat_protection_name: Union[str, _models.ThreatProtectionName], + **kwargs: Any + ) -> _models.AdvancedThreatProtectionSettingsModel: + """Gets state of advanced threat protection settings for a server. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param threat_protection_name: Name of the advanced threat protection settings. "Default" + Required. + :type threat_protection_name: str or + ~azure.mgmt.postgresqlflexibleservers.models.ThreatProtectionName + :return: AdvancedThreatProtectionSettingsModel. The AdvancedThreatProtectionSettingsModel is + compatible with MutableMapping + :rtype: ~azure.mgmt.postgresqlflexibleservers.models.AdvancedThreatProtectionSettingsModel + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.AdvancedThreatProtectionSettingsModel] = kwargs.pop("cls", None) + + _request = build_advanced_threat_protection_settings_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + threat_protection_name=threat_protection_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() + else: + deserialized = _deserialize(_models.AdvancedThreatProtectionSettingsModel, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list_by_server( + self, resource_group_name: str, server_name: str, **kwargs: Any + ) -> AsyncItemPaged["_models.AdvancedThreatProtectionSettingsModel"]: + """Lists state of advanced threat protection settings for a server. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :return: An iterator like instance of AdvancedThreatProtectionSettingsModel + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.postgresqlflexibleservers.models.AdvancedThreatProtectionSettingsModel] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.AdvancedThreatProtectionSettingsModel]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_advanced_threat_protection_settings_list_by_server_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.AdvancedThreatProtectionSettingsModel], deserialized.get("value", []) + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class ServerThreatProtectionSettingsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.postgresqlflexibleservers.aio.PostgreSQLManagementClient`'s + :attr:`server_threat_protection_settings` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: PostgreSQLManagementClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + async def _create_or_update_initial( + self, + resource_group_name: str, + server_name: str, + threat_protection_name: Union[str, _models.ThreatProtectionName], + parameters: Union[_models.AdvancedThreatProtectionSettingsModel, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_server_threat_protection_settings_create_or_update_request( + resource_group_name=resource_group_name, + server_name=server_name, + threat_protection_name=threat_protection_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + threat_protection_name: Union[str, _models.ThreatProtectionName], + parameters: _models.AdvancedThreatProtectionSettingsModel, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.AdvancedThreatProtectionSettingsModel]: + """Creates or updates a server's Advanced Threat Protection settings. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param threat_protection_name: Name of the advanced threat protection settings. "Default" + Required. + :type threat_protection_name: str or + ~azure.mgmt.postgresqlflexibleservers.models.ThreatProtectionName + :param parameters: The Advanced Threat Protection state for the server. Required. + :type parameters: + ~azure.mgmt.postgresqlflexibleservers.models.AdvancedThreatProtectionSettingsModel + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns AdvancedThreatProtectionSettingsModel. The + AdvancedThreatProtectionSettingsModel is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.postgresqlflexibleservers.models.AdvancedThreatProtectionSettingsModel] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + threat_protection_name: Union[str, _models.ThreatProtectionName], + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.AdvancedThreatProtectionSettingsModel]: + """Creates or updates a server's Advanced Threat Protection settings. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param threat_protection_name: Name of the advanced threat protection settings. "Default" + Required. + :type threat_protection_name: str or + ~azure.mgmt.postgresqlflexibleservers.models.ThreatProtectionName + :param parameters: The Advanced Threat Protection state for the server. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns AdvancedThreatProtectionSettingsModel. The + AdvancedThreatProtectionSettingsModel is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.postgresqlflexibleservers.models.AdvancedThreatProtectionSettingsModel] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + threat_protection_name: Union[str, _models.ThreatProtectionName], + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.AdvancedThreatProtectionSettingsModel]: + """Creates or updates a server's Advanced Threat Protection settings. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param threat_protection_name: Name of the advanced threat protection settings. "Default" + Required. + :type threat_protection_name: str or + ~azure.mgmt.postgresqlflexibleservers.models.ThreatProtectionName + :param parameters: The Advanced Threat Protection state for the server. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns AdvancedThreatProtectionSettingsModel. The + AdvancedThreatProtectionSettingsModel is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.postgresqlflexibleservers.models.AdvancedThreatProtectionSettingsModel] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + threat_protection_name: Union[str, _models.ThreatProtectionName], + parameters: Union[_models.AdvancedThreatProtectionSettingsModel, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.AdvancedThreatProtectionSettingsModel]: + """Creates or updates a server's Advanced Threat Protection settings. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param threat_protection_name: Name of the advanced threat protection settings. "Default" + Required. + :type threat_protection_name: str or + ~azure.mgmt.postgresqlflexibleservers.models.ThreatProtectionName + :param parameters: The Advanced Threat Protection state for the server. Is one of the following + types: AdvancedThreatProtectionSettingsModel, JSON, IO[bytes] Required. + :type parameters: + ~azure.mgmt.postgresqlflexibleservers.models.AdvancedThreatProtectionSettingsModel or JSON or + IO[bytes] + :return: An instance of AsyncLROPoller that returns AdvancedThreatProtectionSettingsModel. The + AdvancedThreatProtectionSettingsModel is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.postgresqlflexibleservers.models.AdvancedThreatProtectionSettingsModel] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.AdvancedThreatProtectionSettingsModel] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._create_or_update_initial( + resource_group_name=resource_group_name, + server_name=server_name, + threat_protection_name=threat_protection_name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response_headers = {} + response = pipeline_response.http_response + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = _deserialize(_models.AdvancedThreatProtectionSettingsModel, response.json()) + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.AdvancedThreatProtectionSettingsModel].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.AdvancedThreatProtectionSettingsModel]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + +class BackupsAutomaticAndOnDemandOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.postgresqlflexibleservers.aio.PostgreSQLManagementClient`'s + :attr:`backups_automatic_and_on_demand` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: PostgreSQLManagementClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async + async def get( + self, resource_group_name: str, server_name: str, backup_name: str, **kwargs: Any + ) -> _models.BackupAutomaticAndOnDemand: + """Gets information of an on demand backup, given its name. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param backup_name: Name of the backup. Required. + :type backup_name: str + :return: BackupAutomaticAndOnDemand. The BackupAutomaticAndOnDemand is compatible with + MutableMapping + :rtype: ~azure.mgmt.postgresqlflexibleservers.models.BackupAutomaticAndOnDemand + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.BackupAutomaticAndOnDemand] = kwargs.pop("cls", None) + + _request = build_backups_automatic_and_on_demand_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + backup_name=backup_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() + else: + deserialized = _deserialize(_models.BackupAutomaticAndOnDemand, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + async def _create_initial( + self, resource_group_name: str, server_name: str, backup_name: str, **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_backups_automatic_and_on_demand_create_request( + resource_group_name=resource_group_name, + server_name=server_name, + backup_name=backup_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def begin_create( + self, resource_group_name: str, server_name: str, backup_name: str, **kwargs: Any + ) -> AsyncLROPoller[_models.BackupAutomaticAndOnDemand]: + """Creates an on demand backup of a server. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param backup_name: Name of the backup. Required. + :type backup_name: str + :return: An instance of AsyncLROPoller that returns BackupAutomaticAndOnDemand. The + BackupAutomaticAndOnDemand is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.postgresqlflexibleservers.models.BackupAutomaticAndOnDemand] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.BackupAutomaticAndOnDemand] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._create_initial( + resource_group_name=resource_group_name, + server_name=server_name, + backup_name=backup_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response_headers = {} + response = pipeline_response.http_response + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = _deserialize(_models.BackupAutomaticAndOnDemand, response.json()) + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.BackupAutomaticAndOnDemand].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.BackupAutomaticAndOnDemand]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + async def _delete_initial( + self, resource_group_name: str, server_name: str, backup_name: str, **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_backups_automatic_and_on_demand_delete_request( + resource_group_name=resource_group_name, + server_name=server_name, + backup_name=backup_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [202, 204]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def begin_delete( + self, resource_group_name: str, server_name: str, backup_name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Deletes a specific backup, given its name. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param backup_name: Name of the backup. Required. + :type backup_name: str + :return: An instance of AsyncLROPoller that returns None + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._delete_initial( + resource_group_name=resource_group_name, + server_name=server_name, + backup_name=backup_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + def list_by_server( + self, resource_group_name: str, server_name: str, **kwargs: Any + ) -> AsyncItemPaged["_models.BackupAutomaticAndOnDemand"]: + """Lists all available backups of a server. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :return: An iterator like instance of BackupAutomaticAndOnDemand + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.postgresqlflexibleservers.models.BackupAutomaticAndOnDemand] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.BackupAutomaticAndOnDemand]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_backups_automatic_and_on_demand_list_by_server_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize(List[_models.BackupAutomaticAndOnDemand], deserialized.get("value", [])) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class TuningOptionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.postgresqlflexibleservers.aio.PostgreSQLManagementClient`'s + :attr:`tuning_options` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: PostgreSQLManagementClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async + async def get( + self, + resource_group_name: str, + server_name: str, + tuning_option: Union[str, _models.TuningOptionParameterEnum], + **kwargs: Any + ) -> _models.TuningOptions: + """Gets the tuning options of a server. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param tuning_option: The name of the tuning option. Known values are: "index" and "table". + Required. + :type tuning_option: str or + ~azure.mgmt.postgresqlflexibleservers.models.TuningOptionParameterEnum + :return: TuningOptions. The TuningOptions is compatible with MutableMapping + :rtype: ~azure.mgmt.postgresqlflexibleservers.models.TuningOptions + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.TuningOptions] = kwargs.pop("cls", None) + + _request = build_tuning_options_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + tuning_option=tuning_option, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() + else: + deserialized = _deserialize(_models.TuningOptions, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list_by_server( + self, resource_group_name: str, server_name: str, **kwargs: Any + ) -> AsyncItemPaged["_models.TuningOptions"]: + """Lists the tuning options of a server. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :return: An iterator like instance of TuningOptions + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.postgresqlflexibleservers.models.TuningOptions] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.TuningOptions]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_tuning_options_list_by_server_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize(List[_models.TuningOptions], deserialized.get("value", [])) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace + def list_recommendations( + self, + resource_group_name: str, + server_name: str, + tuning_option: Union[str, _models.TuningOptionParameterEnum], + *, + recommendation_type: Optional[Union[str, _models.RecommendationTypeParameterEnum]] = None, + **kwargs: Any + ) -> AsyncItemPaged["_models.ObjectRecommendation"]: + """Lists available object recommendations. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param tuning_option: The name of the tuning option. Known values are: "index" and "table". + Required. + :type tuning_option: str or + ~azure.mgmt.postgresqlflexibleservers.models.TuningOptionParameterEnum + :keyword recommendation_type: Recommendations list filter. Retrieves recommendations based on + type. Known values are: "CreateIndex", "DropIndex", "ReIndex", "AnalyzeTable", and + "VacuumTable". Default value is None. + :paramtype recommendation_type: str or + ~azure.mgmt.postgresqlflexibleservers.models.RecommendationTypeParameterEnum + :return: An iterator like instance of ObjectRecommendation + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.postgresqlflexibleservers.models.ObjectRecommendation] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.ObjectRecommendation]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_tuning_options_list_recommendations_request( + resource_group_name=resource_group_name, + server_name=server_name, + tuning_option=tuning_option, + subscription_id=self._config.subscription_id, + recommendation_type=recommendation_type, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize(List[_models.ObjectRecommendation], deserialized.get("value", [])) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class CapabilitiesByLocationOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.postgresqlflexibleservers.aio.PostgreSQLManagementClient`'s + :attr:`capabilities_by_location` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: PostgreSQLManagementClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list(self, location_name: str, **kwargs: Any) -> AsyncItemPaged["_models.Capability"]: + """Lists the capabilities available in a given location for a specific subscription. + + :param location_name: The name of the location. Required. + :type location_name: str + :return: An iterator like instance of Capability + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.postgresqlflexibleservers.models.Capability] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.Capability]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_capabilities_by_location_list_request( + location_name=location_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize(List[_models.Capability], deserialized.get("value", [])) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class NameAvailabilityOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.postgresqlflexibleservers.aio.PostgreSQLManagementClient`'s + :attr:`name_availability` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: PostgreSQLManagementClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @overload + async def check_globally( + self, parameters: _models.CheckNameAvailabilityRequest, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.NameAvailabilityModel: + """Checks the validity and availability of the given name, to assign it to a new server or to use + it as the base name of a new pair of virtual endpoints. + + :param parameters: The request body. Required. + :type parameters: ~azure.mgmt.postgresqlflexibleservers.models.CheckNameAvailabilityRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: NameAvailabilityModel. The NameAvailabilityModel is compatible with MutableMapping + :rtype: ~azure.mgmt.postgresqlflexibleservers.models.NameAvailabilityModel + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def check_globally( + self, parameters: JSON, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.NameAvailabilityModel: + """Checks the validity and availability of the given name, to assign it to a new server or to use + it as the base name of a new pair of virtual endpoints. + + :param parameters: The request body. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: NameAvailabilityModel. The NameAvailabilityModel is compatible with MutableMapping + :rtype: ~azure.mgmt.postgresqlflexibleservers.models.NameAvailabilityModel + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def check_globally( + self, parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any + ) -> _models.NameAvailabilityModel: + """Checks the validity and availability of the given name, to assign it to a new server or to use + it as the base name of a new pair of virtual endpoints. + + :param parameters: The request body. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: NameAvailabilityModel. The NameAvailabilityModel is compatible with MutableMapping + :rtype: ~azure.mgmt.postgresqlflexibleservers.models.NameAvailabilityModel + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def check_globally( + self, parameters: Union[_models.CheckNameAvailabilityRequest, JSON, IO[bytes]], **kwargs: Any + ) -> _models.NameAvailabilityModel: + """Checks the validity and availability of the given name, to assign it to a new server or to use + it as the base name of a new pair of virtual endpoints. + + :param parameters: The request body. Is one of the following types: + CheckNameAvailabilityRequest, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.postgresqlflexibleservers.models.CheckNameAvailabilityRequest or + JSON or IO[bytes] + :return: NameAvailabilityModel. The NameAvailabilityModel is compatible with MutableMapping + :rtype: ~azure.mgmt.postgresqlflexibleservers.models.NameAvailabilityModel + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.NameAvailabilityModel] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_name_availability_check_globally_request( + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() + else: + deserialized = _deserialize(_models.NameAvailabilityModel, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + async def check_with_location( + self, + location_name: str, + parameters: _models.CheckNameAvailabilityRequest, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.NameAvailabilityModel: + """Check the availability of name for resource. + + :param location_name: The name of the location. Required. + :type location_name: str + :param parameters: The request body. Required. + :type parameters: ~azure.mgmt.postgresqlflexibleservers.models.CheckNameAvailabilityRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: NameAvailabilityModel. The NameAvailabilityModel is compatible with MutableMapping + :rtype: ~azure.mgmt.postgresqlflexibleservers.models.NameAvailabilityModel + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def check_with_location( + self, location_name: str, parameters: JSON, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.NameAvailabilityModel: + """Check the availability of name for resource. + + :param location_name: The name of the location. Required. + :type location_name: str + :param parameters: The request body. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: NameAvailabilityModel. The NameAvailabilityModel is compatible with MutableMapping + :rtype: ~azure.mgmt.postgresqlflexibleservers.models.NameAvailabilityModel + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def check_with_location( + self, location_name: str, parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any + ) -> _models.NameAvailabilityModel: + """Check the availability of name for resource. + + :param location_name: The name of the location. Required. + :type location_name: str + :param parameters: The request body. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: NameAvailabilityModel. The NameAvailabilityModel is compatible with MutableMapping + :rtype: ~azure.mgmt.postgresqlflexibleservers.models.NameAvailabilityModel + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def check_with_location( + self, + location_name: str, + parameters: Union[_models.CheckNameAvailabilityRequest, JSON, IO[bytes]], + **kwargs: Any + ) -> _models.NameAvailabilityModel: + """Check the availability of name for resource. + + :param location_name: The name of the location. Required. + :type location_name: str + :param parameters: The request body. Is one of the following types: + CheckNameAvailabilityRequest, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.postgresqlflexibleservers.models.CheckNameAvailabilityRequest or + JSON or IO[bytes] + :return: NameAvailabilityModel. The NameAvailabilityModel is compatible with MutableMapping + :rtype: ~azure.mgmt.postgresqlflexibleservers.models.NameAvailabilityModel + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.NameAvailabilityModel] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_name_availability_check_with_location_request( + location_name=location_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() + else: + deserialized = _deserialize(_models.NameAvailabilityModel, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + +class PrivateDnsZoneSuffixOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.postgresqlflexibleservers.aio.PostgreSQLManagementClient`'s + :attr:`private_dns_zone_suffix` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: PostgreSQLManagementClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async + async def get(self, **kwargs: Any) -> str: + """Gets the private DNS zone suffix. + + :return: str + :rtype: str + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[str] = kwargs.pop("cls", None) + + _request = build_private_dns_zone_suffix_get_request( + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() + else: + deserialized = _deserialize(str, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + +class QuotaUsagesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.postgresqlflexibleservers.aio.PostgreSQLManagementClient`'s + :attr:`quota_usages` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: PostgreSQLManagementClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list(self, location_name: str, **kwargs: Any) -> AsyncItemPaged["_models.QuotaUsage"]: + """Get quota usages at specified location in a given subscription. + + :param location_name: The name of the location. Required. + :type location_name: str + :return: An iterator like instance of QuotaUsage + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.postgresqlflexibleservers.models.QuotaUsage] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.QuotaUsage]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_quota_usages_list_request( + location_name=location_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize(List[_models.QuotaUsage], deserialized.get("value", [])) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class VirtualNetworkSubnetUsageOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.postgresqlflexibleservers.aio.PostgreSQLManagementClient`'s + :attr:`virtual_network_subnet_usage` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: PostgreSQLManagementClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @overload + async def list( + self, + location_name: str, + parameters: _models.VirtualNetworkSubnetUsageParameter, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.VirtualNetworkSubnetUsageModel: + """Lists the virtual network subnet usage for a given virtual network. + + :param location_name: The name of the location. Required. + :type location_name: str + :param parameters: The request body. Required. + :type parameters: + ~azure.mgmt.postgresqlflexibleservers.models.VirtualNetworkSubnetUsageParameter + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: VirtualNetworkSubnetUsageModel. The VirtualNetworkSubnetUsageModel is compatible with + MutableMapping + :rtype: ~azure.mgmt.postgresqlflexibleservers.models.VirtualNetworkSubnetUsageModel + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def list( + self, location_name: str, parameters: JSON, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.VirtualNetworkSubnetUsageModel: + """Lists the virtual network subnet usage for a given virtual network. + + :param location_name: The name of the location. Required. + :type location_name: str + :param parameters: The request body. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: VirtualNetworkSubnetUsageModel. The VirtualNetworkSubnetUsageModel is compatible with + MutableMapping + :rtype: ~azure.mgmt.postgresqlflexibleservers.models.VirtualNetworkSubnetUsageModel + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def list( + self, location_name: str, parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any + ) -> _models.VirtualNetworkSubnetUsageModel: + """Lists the virtual network subnet usage for a given virtual network. + + :param location_name: The name of the location. Required. + :type location_name: str + :param parameters: The request body. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: VirtualNetworkSubnetUsageModel. The VirtualNetworkSubnetUsageModel is compatible with + MutableMapping + :rtype: ~azure.mgmt.postgresqlflexibleservers.models.VirtualNetworkSubnetUsageModel + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def list( + self, + location_name: str, + parameters: Union[_models.VirtualNetworkSubnetUsageParameter, JSON, IO[bytes]], + **kwargs: Any + ) -> _models.VirtualNetworkSubnetUsageModel: + """Lists the virtual network subnet usage for a given virtual network. + + :param location_name: The name of the location. Required. + :type location_name: str + :param parameters: The request body. Is one of the following types: + VirtualNetworkSubnetUsageParameter, JSON, IO[bytes] Required. + :type parameters: + ~azure.mgmt.postgresqlflexibleservers.models.VirtualNetworkSubnetUsageParameter or JSON or + IO[bytes] + :return: VirtualNetworkSubnetUsageModel. The VirtualNetworkSubnetUsageModel is compatible with + MutableMapping + :rtype: ~azure.mgmt.postgresqlflexibleservers.models.VirtualNetworkSubnetUsageModel + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.VirtualNetworkSubnetUsageModel] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_virtual_network_subnet_usage_list_request( + location_name=location_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() + else: + deserialized = _deserialize(_models.VirtualNetworkSubnetUsageModel, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore diff --git a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/azure/mgmt/postgresqlflexibleservers/aio/operations/_patch.py b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/azure/mgmt/postgresqlflexibleservers/aio/operations/_patch.py index f7dd32510333..87676c65a8f0 100644 --- a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/azure/mgmt/postgresqlflexibleservers/aio/operations/_patch.py +++ b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/azure/mgmt/postgresqlflexibleservers/aio/operations/_patch.py @@ -1,14 +1,15 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------- """Customize generated code here. Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize """ -from typing import List -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +__all__: list[str] = [] # Add all objects you want publicly available to users at this package level def patch_sdk(): diff --git a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/azure/mgmt/postgresqlflexibleservers/aio/operations/_private_dns_zone_suffix_operations.py b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/azure/mgmt/postgresqlflexibleservers/aio/operations/_private_dns_zone_suffix_operations.py deleted file mode 100644 index a606efdc16e7..000000000000 --- a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/azure/mgmt/postgresqlflexibleservers/aio/operations/_private_dns_zone_suffix_operations.py +++ /dev/null @@ -1,106 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from collections.abc import MutableMapping -from typing import Any, Callable, Optional, TypeVar - -from azure.core import AsyncPipelineClient -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.rest import AsyncHttpResponse, HttpRequest -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._utils.serialization import Deserializer, Serializer -from ...operations._private_dns_zone_suffix_operations import build_get_request -from .._configuration import PostgreSQLManagementClientConfiguration - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] -List = list - - -class PrivateDnsZoneSuffixOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.postgresqlflexibleservers.aio.PostgreSQLManagementClient`'s - :attr:`private_dns_zone_suffix` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: PostgreSQLManagementClientConfiguration = ( - input_args.pop(0) if input_args else kwargs.pop("config") - ) - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace_async - async def get(self, **kwargs: Any) -> str: - """Gets the private DNS zone suffix. - - :return: str or the result of cls(response) - :rtype: str - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[str] = kwargs.pop("cls", None) - - _request = build_get_request( - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize( - _models.ErrorResponse, - pipeline_response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("str", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/azure/mgmt/postgresqlflexibleservers/aio/operations/_private_endpoint_connections_operations.py b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/azure/mgmt/postgresqlflexibleservers/aio/operations/_private_endpoint_connections_operations.py deleted file mode 100644 index 1c0a88807e28..000000000000 --- a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/azure/mgmt/postgresqlflexibleservers/aio/operations/_private_endpoint_connections_operations.py +++ /dev/null @@ -1,565 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from collections.abc import MutableMapping -from io import IOBase -from typing import Any, AsyncIterator, Callable, IO, Optional, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core import AsyncPipelineClient -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import AsyncHttpResponse, HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling - -from ... import models as _models -from ..._utils.serialization import Deserializer, Serializer -from ...operations._private_endpoint_connections_operations import ( - build_delete_request, - build_get_request, - build_list_by_server_request, - build_update_request, -) -from .._configuration import PostgreSQLManagementClientConfiguration - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] -List = list - - -class PrivateEndpointConnectionsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.postgresqlflexibleservers.aio.PostgreSQLManagementClient`'s - :attr:`private_endpoint_connections` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: PostgreSQLManagementClientConfiguration = ( - input_args.pop(0) if input_args else kwargs.pop("config") - ) - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace_async - async def get( - self, resource_group_name: str, server_name: str, private_endpoint_connection_name: str, **kwargs: Any - ) -> _models.PrivateEndpointConnection: - """Gets a private endpoint connection. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param private_endpoint_connection_name: The name of the private endpoint connection. Required. - :type private_endpoint_connection_name: str - :return: PrivateEndpointConnection or the result of cls(response) - :rtype: ~azure.mgmt.postgresqlflexibleservers.models.PrivateEndpointConnection - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - server_name=server_name, - private_endpoint_connection_name=private_endpoint_connection_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize( - _models.ErrorResponse, - pipeline_response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - async def _update_initial( - self, - resource_group_name: str, - server_name: str, - private_endpoint_connection_name: str, - parameters: Union[_models.PrivateEndpointConnection, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "PrivateEndpointConnection") - - _request = build_update_request( - resource_group_name=resource_group_name, - server_name=server_name, - private_endpoint_connection_name=private_endpoint_connection_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize( - _models.ErrorResponse, - pipeline_response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - response_headers = {} - if response.status_code == 202: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @overload - async def begin_update( - self, - resource_group_name: str, - server_name: str, - private_endpoint_connection_name: str, - parameters: _models.PrivateEndpointConnection, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.PrivateEndpointConnection]: - """Approves or rejects a private endpoint connection. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param private_endpoint_connection_name: The name of the private endpoint connection. Required. - :type private_endpoint_connection_name: str - :param parameters: Parameters required to update a private endpoint connection. Required. - :type parameters: ~azure.mgmt.postgresqlflexibleservers.models.PrivateEndpointConnection - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either PrivateEndpointConnection or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.postgresqlflexibleservers.models.PrivateEndpointConnection] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_update( - self, - resource_group_name: str, - server_name: str, - private_endpoint_connection_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.PrivateEndpointConnection]: - """Approves or rejects a private endpoint connection. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param private_endpoint_connection_name: The name of the private endpoint connection. Required. - :type private_endpoint_connection_name: str - :param parameters: Parameters required to update a private endpoint connection. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either PrivateEndpointConnection or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.postgresqlflexibleservers.models.PrivateEndpointConnection] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_update( - self, - resource_group_name: str, - server_name: str, - private_endpoint_connection_name: str, - parameters: Union[_models.PrivateEndpointConnection, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.PrivateEndpointConnection]: - """Approves or rejects a private endpoint connection. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param private_endpoint_connection_name: The name of the private endpoint connection. Required. - :type private_endpoint_connection_name: str - :param parameters: Parameters required to update a private endpoint connection. Is either a - PrivateEndpointConnection type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.postgresqlflexibleservers.models.PrivateEndpointConnection or - IO[bytes] - :return: An instance of AsyncLROPoller that returns either PrivateEndpointConnection or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.postgresqlflexibleservers.models.PrivateEndpointConnection] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._update_initial( - resource_group_name=resource_group_name, - server_name=server_name, - private_endpoint_connection_name=private_endpoint_connection_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - if polling is True: - polling_method: AsyncPollingMethod = cast( - AsyncPollingMethod, - AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[_models.PrivateEndpointConnection].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.PrivateEndpointConnection]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _delete_initial( - self, resource_group_name: str, server_name: str, private_endpoint_connection_name: str, **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_delete_request( - resource_group_name=resource_group_name, - server_name=server_name, - private_endpoint_connection_name=private_endpoint_connection_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [202, 204]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize( - _models.ErrorResponse, - pipeline_response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - response_headers = {} - if response.status_code == 202: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def begin_delete( - self, resource_group_name: str, server_name: str, private_endpoint_connection_name: str, **kwargs: Any - ) -> AsyncLROPoller[None]: - """Deletes a private endpoint connection. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param private_endpoint_connection_name: The name of the private endpoint connection. Required. - :type private_endpoint_connection_name: str - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._delete_initial( - resource_group_name=resource_group_name, - server_name=server_name, - private_endpoint_connection_name=private_endpoint_connection_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: AsyncPollingMethod = cast( - AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - @distributed_trace - def list_by_server( - self, resource_group_name: str, server_name: str, **kwargs: Any - ) -> AsyncItemPaged["_models.PrivateEndpointConnection"]: - """Lists all private endpoint connections on a server. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :return: An iterator like instance of either PrivateEndpointConnection or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.postgresqlflexibleservers.models.PrivateEndpointConnection] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.PrivateEndpointConnectionList] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_by_server_request( - resource_group_name=resource_group_name, - server_name=server_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("PrivateEndpointConnectionList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize( - _models.ErrorResponse, - pipeline_response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) diff --git a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/azure/mgmt/postgresqlflexibleservers/aio/operations/_private_link_resources_operations.py b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/azure/mgmt/postgresqlflexibleservers/aio/operations/_private_link_resources_operations.py deleted file mode 100644 index 68f09b54ab05..000000000000 --- a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/azure/mgmt/postgresqlflexibleservers/aio/operations/_private_link_resources_operations.py +++ /dev/null @@ -1,210 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from collections.abc import MutableMapping -from typing import Any, Callable, Optional, TypeVar -import urllib.parse - -from azure.core import AsyncPipelineClient -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.rest import AsyncHttpResponse, HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._utils.serialization import Deserializer, Serializer -from ...operations._private_link_resources_operations import build_get_request, build_list_by_server_request -from .._configuration import PostgreSQLManagementClientConfiguration - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] -List = list - - -class PrivateLinkResourcesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.postgresqlflexibleservers.aio.PostgreSQLManagementClient`'s - :attr:`private_link_resources` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: PostgreSQLManagementClientConfiguration = ( - input_args.pop(0) if input_args else kwargs.pop("config") - ) - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def list_by_server( - self, resource_group_name: str, server_name: str, **kwargs: Any - ) -> AsyncItemPaged["_models.PrivateLinkResource"]: - """Gets the private link resources for PostgreSQL server. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :return: An iterator like instance of either PrivateLinkResource or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.postgresqlflexibleservers.models.PrivateLinkResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.PrivateLinkResourceList] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_by_server_request( - resource_group_name=resource_group_name, - server_name=server_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("PrivateLinkResourceList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize( - _models.ErrorResponse, - pipeline_response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace_async - async def get( - self, resource_group_name: str, server_name: str, group_name: str, **kwargs: Any - ) -> _models.PrivateLinkResource: - """Gets a private link resource for PostgreSQL server. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param group_name: The name of the private link resource. Required. - :type group_name: str - :return: PrivateLinkResource or the result of cls(response) - :rtype: ~azure.mgmt.postgresqlflexibleservers.models.PrivateLinkResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.PrivateLinkResource] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - server_name=server_name, - group_name=group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize( - _models.ErrorResponse, - pipeline_response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("PrivateLinkResource", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/azure/mgmt/postgresqlflexibleservers/aio/operations/_quota_usages_operations.py b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/azure/mgmt/postgresqlflexibleservers/aio/operations/_quota_usages_operations.py deleted file mode 100644 index eb225e680f39..000000000000 --- a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/azure/mgmt/postgresqlflexibleservers/aio/operations/_quota_usages_operations.py +++ /dev/null @@ -1,139 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from collections.abc import MutableMapping -from typing import Any, Callable, Optional, TypeVar -import urllib.parse - -from azure.core import AsyncPipelineClient -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.rest import AsyncHttpResponse, HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._utils.serialization import Deserializer, Serializer -from ...operations._quota_usages_operations import build_list_request -from .._configuration import PostgreSQLManagementClientConfiguration - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] -List = list - - -class QuotaUsagesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.postgresqlflexibleservers.aio.PostgreSQLManagementClient`'s - :attr:`quota_usages` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: PostgreSQLManagementClientConfiguration = ( - input_args.pop(0) if input_args else kwargs.pop("config") - ) - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def list(self, location_name: str, **kwargs: Any) -> AsyncItemPaged["_models.QuotaUsage"]: - """Get quota usages at specified location in a given subscription. - - :param location_name: The name of the location. Required. - :type location_name: str - :return: An iterator like instance of either QuotaUsage or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.postgresqlflexibleservers.models.QuotaUsage] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.QuotaUsageList] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_request( - location_name=location_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("QuotaUsageList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize( - _models.ErrorResponse, - pipeline_response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) diff --git a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/azure/mgmt/postgresqlflexibleservers/aio/operations/_replicas_operations.py b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/azure/mgmt/postgresqlflexibleservers/aio/operations/_replicas_operations.py deleted file mode 100644 index 9e12f3cb7a2c..000000000000 --- a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/azure/mgmt/postgresqlflexibleservers/aio/operations/_replicas_operations.py +++ /dev/null @@ -1,145 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from collections.abc import MutableMapping -from typing import Any, Callable, Optional, TypeVar -import urllib.parse - -from azure.core import AsyncPipelineClient -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.rest import AsyncHttpResponse, HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._utils.serialization import Deserializer, Serializer -from ...operations._replicas_operations import build_list_by_server_request -from .._configuration import PostgreSQLManagementClientConfiguration - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] -List = list - - -class ReplicasOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.postgresqlflexibleservers.aio.PostgreSQLManagementClient`'s - :attr:`replicas` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: PostgreSQLManagementClientConfiguration = ( - input_args.pop(0) if input_args else kwargs.pop("config") - ) - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def list_by_server( - self, resource_group_name: str, server_name: str, **kwargs: Any - ) -> AsyncItemPaged["_models.Server"]: - """Lists all read replicas of a server. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :return: An iterator like instance of either Server or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.postgresqlflexibleservers.models.Server] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.ServerList] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_by_server_request( - resource_group_name=resource_group_name, - server_name=server_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("ServerList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize( - _models.ErrorResponse, - pipeline_response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) diff --git a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/azure/mgmt/postgresqlflexibleservers/aio/operations/_server_threat_protection_settings_operations.py b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/azure/mgmt/postgresqlflexibleservers/aio/operations/_server_threat_protection_settings_operations.py deleted file mode 100644 index b7bc8bc57525..000000000000 --- a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/azure/mgmt/postgresqlflexibleservers/aio/operations/_server_threat_protection_settings_operations.py +++ /dev/null @@ -1,290 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from collections.abc import MutableMapping -from io import IOBase -from typing import Any, AsyncIterator, Callable, IO, Optional, TypeVar, Union, cast, overload - -from azure.core import AsyncPipelineClient -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import AsyncHttpResponse, HttpRequest -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling - -from ... import models as _models -from ..._utils.serialization import Deserializer, Serializer -from ...operations._server_threat_protection_settings_operations import build_create_or_update_request -from .._configuration import PostgreSQLManagementClientConfiguration - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] -List = list - - -class ServerThreatProtectionSettingsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.postgresqlflexibleservers.aio.PostgreSQLManagementClient`'s - :attr:`server_threat_protection_settings` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: PostgreSQLManagementClientConfiguration = ( - input_args.pop(0) if input_args else kwargs.pop("config") - ) - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - async def _create_or_update_initial( - self, - resource_group_name: str, - server_name: str, - threat_protection_name: Union[str, _models.ThreatProtectionName], - parameters: Union[_models.AdvancedThreatProtectionSettingsModel, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "AdvancedThreatProtectionSettingsModel") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - server_name=server_name, - threat_protection_name=threat_protection_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize( - _models.ErrorResponse, - pipeline_response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - response_headers = {} - if response.status_code == 202: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - server_name: str, - threat_protection_name: Union[str, _models.ThreatProtectionName], - parameters: _models.AdvancedThreatProtectionSettingsModel, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.AdvancedThreatProtectionSettingsModel]: - """Creates or updates a server's Advanced Threat Protection settings. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param threat_protection_name: Name of the advanced threat protection settings. "Default" - Required. - :type threat_protection_name: str or - ~azure.mgmt.postgresqlflexibleservers.models.ThreatProtectionName - :param parameters: The Advanced Threat Protection state for the server. Required. - :type parameters: - ~azure.mgmt.postgresqlflexibleservers.models.AdvancedThreatProtectionSettingsModel - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either - AdvancedThreatProtectionSettingsModel or the result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.postgresqlflexibleservers.models.AdvancedThreatProtectionSettingsModel] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - server_name: str, - threat_protection_name: Union[str, _models.ThreatProtectionName], - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.AdvancedThreatProtectionSettingsModel]: - """Creates or updates a server's Advanced Threat Protection settings. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param threat_protection_name: Name of the advanced threat protection settings. "Default" - Required. - :type threat_protection_name: str or - ~azure.mgmt.postgresqlflexibleservers.models.ThreatProtectionName - :param parameters: The Advanced Threat Protection state for the server. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either - AdvancedThreatProtectionSettingsModel or the result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.postgresqlflexibleservers.models.AdvancedThreatProtectionSettingsModel] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_create_or_update( - self, - resource_group_name: str, - server_name: str, - threat_protection_name: Union[str, _models.ThreatProtectionName], - parameters: Union[_models.AdvancedThreatProtectionSettingsModel, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.AdvancedThreatProtectionSettingsModel]: - """Creates or updates a server's Advanced Threat Protection settings. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param threat_protection_name: Name of the advanced threat protection settings. "Default" - Required. - :type threat_protection_name: str or - ~azure.mgmt.postgresqlflexibleservers.models.ThreatProtectionName - :param parameters: The Advanced Threat Protection state for the server. Is either a - AdvancedThreatProtectionSettingsModel type or a IO[bytes] type. Required. - :type parameters: - ~azure.mgmt.postgresqlflexibleservers.models.AdvancedThreatProtectionSettingsModel or IO[bytes] - :return: An instance of AsyncLROPoller that returns either - AdvancedThreatProtectionSettingsModel or the result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.postgresqlflexibleservers.models.AdvancedThreatProtectionSettingsModel] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.AdvancedThreatProtectionSettingsModel] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._create_or_update_initial( - resource_group_name=resource_group_name, - server_name=server_name, - threat_protection_name=threat_protection_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("AdvancedThreatProtectionSettingsModel", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - if polling is True: - polling_method: AsyncPollingMethod = cast( - AsyncPollingMethod, - AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[_models.AdvancedThreatProtectionSettingsModel].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.AdvancedThreatProtectionSettingsModel]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) diff --git a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/azure/mgmt/postgresqlflexibleservers/aio/operations/_servers_operations.py b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/azure/mgmt/postgresqlflexibleservers/aio/operations/_servers_operations.py deleted file mode 100644 index b70f08a8db43..000000000000 --- a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/azure/mgmt/postgresqlflexibleservers/aio/operations/_servers_operations.py +++ /dev/null @@ -1,1246 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from collections.abc import MutableMapping -from io import IOBase -from typing import Any, AsyncIterator, Callable, IO, Optional, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core import AsyncPipelineClient -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import AsyncHttpResponse, HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling - -from ... import models as _models -from ..._utils.serialization import Deserializer, Serializer -from ...operations._servers_operations import ( - build_create_or_update_request, - build_delete_request, - build_get_request, - build_list_by_resource_group_request, - build_list_by_subscription_request, - build_restart_request, - build_start_request, - build_stop_request, - build_update_request, -) -from .._configuration import PostgreSQLManagementClientConfiguration - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] -List = list - - -class ServersOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.postgresqlflexibleservers.aio.PostgreSQLManagementClient`'s - :attr:`servers` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: PostgreSQLManagementClientConfiguration = ( - input_args.pop(0) if input_args else kwargs.pop("config") - ) - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - async def _create_or_update_initial( - self, resource_group_name: str, server_name: str, parameters: Union[_models.Server, IO[bytes]], **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "Server") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - server_name=server_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize( - _models.ErrorResponse, - pipeline_response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - response_headers = {} - if response.status_code == 202: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - server_name: str, - parameters: _models.Server, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.Server]: - """Creates a new server. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param parameters: Parameters required to create a new server or to update an existing server. - Required. - :type parameters: ~azure.mgmt.postgresqlflexibleservers.models.Server - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either Server or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.postgresqlflexibleservers.models.Server] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - server_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.Server]: - """Creates a new server. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param parameters: Parameters required to create a new server or to update an existing server. - Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either Server or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.postgresqlflexibleservers.models.Server] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_create_or_update( - self, resource_group_name: str, server_name: str, parameters: Union[_models.Server, IO[bytes]], **kwargs: Any - ) -> AsyncLROPoller[_models.Server]: - """Creates a new server. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param parameters: Parameters required to create a new server or to update an existing server. - Is either a Server type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.postgresqlflexibleservers.models.Server or IO[bytes] - :return: An instance of AsyncLROPoller that returns either Server or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.postgresqlflexibleservers.models.Server] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.Server] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._create_or_update_initial( - resource_group_name=resource_group_name, - server_name=server_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Server", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - if polling is True: - polling_method: AsyncPollingMethod = cast( - AsyncPollingMethod, - AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[_models.Server].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.Server]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _update_initial( - self, - resource_group_name: str, - server_name: str, - parameters: Union[_models.ServerForPatch, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "ServerForPatch") - - _request = build_update_request( - resource_group_name=resource_group_name, - server_name=server_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize( - _models.ErrorResponse, - pipeline_response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - response_headers = {} - if response.status_code == 202: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @overload - async def begin_update( - self, - resource_group_name: str, - server_name: str, - parameters: _models.ServerForPatch, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.Server]: - """Updates an existing server. The request body can contain one or multiple of the properties - present in the normal server definition. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param parameters: Parameters required to update a server. Required. - :type parameters: ~azure.mgmt.postgresqlflexibleservers.models.ServerForPatch - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either Server or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.postgresqlflexibleservers.models.Server] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_update( - self, - resource_group_name: str, - server_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.Server]: - """Updates an existing server. The request body can contain one or multiple of the properties - present in the normal server definition. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param parameters: Parameters required to update a server. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either Server or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.postgresqlflexibleservers.models.Server] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_update( - self, - resource_group_name: str, - server_name: str, - parameters: Union[_models.ServerForPatch, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.Server]: - """Updates an existing server. The request body can contain one or multiple of the properties - present in the normal server definition. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param parameters: Parameters required to update a server. Is either a ServerForPatch type or a - IO[bytes] type. Required. - :type parameters: ~azure.mgmt.postgresqlflexibleservers.models.ServerForPatch or IO[bytes] - :return: An instance of AsyncLROPoller that returns either Server or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.postgresqlflexibleservers.models.Server] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.Server] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._update_initial( - resource_group_name=resource_group_name, - server_name=server_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Server", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - if polling is True: - polling_method: AsyncPollingMethod = cast( - AsyncPollingMethod, - AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[_models.Server].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.Server]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _delete_initial(self, resource_group_name: str, server_name: str, **kwargs: Any) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_delete_request( - resource_group_name=resource_group_name, - server_name=server_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [202, 204]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize( - _models.ErrorResponse, - pipeline_response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - response_headers = {} - if response.status_code == 202: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def begin_delete(self, resource_group_name: str, server_name: str, **kwargs: Any) -> AsyncLROPoller[None]: - """Deletes or drops an existing server. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._delete_initial( - resource_group_name=resource_group_name, - server_name=server_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: AsyncPollingMethod = cast( - AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - @distributed_trace_async - async def get(self, resource_group_name: str, server_name: str, **kwargs: Any) -> _models.Server: - """Gets information about an existing server. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :return: Server or the result of cls(response) - :rtype: ~azure.mgmt.postgresqlflexibleservers.models.Server - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.Server] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - server_name=server_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize( - _models.ErrorResponse, - pipeline_response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("Server", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> AsyncItemPaged["_models.Server"]: - """Lists all servers in a resource group. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :return: An iterator like instance of either Server or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.postgresqlflexibleservers.models.Server] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.ServerList] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("ServerList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize( - _models.ErrorResponse, - pipeline_response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace - def list_by_subscription(self, **kwargs: Any) -> AsyncItemPaged["_models.Server"]: - """Lists all servers in a subscription. - - :return: An iterator like instance of either Server or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.postgresqlflexibleservers.models.Server] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.ServerList] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_by_subscription_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("ServerList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize( - _models.ErrorResponse, - pipeline_response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - async def _restart_initial( - self, - resource_group_name: str, - server_name: str, - parameters: Optional[Union[_models.RestartParameter, IO[bytes]]] = None, - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - content_type = content_type if parameters else None - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" if parameters else None - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - if parameters is not None: - _json = self._serialize.body(parameters, "RestartParameter") - else: - _json = None - - _request = build_restart_request( - resource_group_name=resource_group_name, - server_name=server_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [202]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize( - _models.ErrorResponse, - pipeline_response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - response_headers = {} - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @overload - async def begin_restart( - self, - resource_group_name: str, - server_name: str, - parameters: Optional[_models.RestartParameter] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[None]: - """Restarts PostgreSQL database engine in a server. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param parameters: Parameters to restart a server. Default value is None. - :type parameters: ~azure.mgmt.postgresqlflexibleservers.models.RestartParameter - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_restart( - self, - resource_group_name: str, - server_name: str, - parameters: Optional[IO[bytes]] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[None]: - """Restarts PostgreSQL database engine in a server. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param parameters: Parameters to restart a server. Default value is None. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_restart( - self, - resource_group_name: str, - server_name: str, - parameters: Optional[Union[_models.RestartParameter, IO[bytes]]] = None, - **kwargs: Any - ) -> AsyncLROPoller[None]: - """Restarts PostgreSQL database engine in a server. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param parameters: Parameters to restart a server. Is either a RestartParameter type or a - IO[bytes] type. Default value is None. - :type parameters: ~azure.mgmt.postgresqlflexibleservers.models.RestartParameter or IO[bytes] - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - content_type = content_type if parameters else None - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._restart_initial( - resource_group_name=resource_group_name, - server_name=server_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: AsyncPollingMethod = cast( - AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - async def _start_initial(self, resource_group_name: str, server_name: str, **kwargs: Any) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_start_request( - resource_group_name=resource_group_name, - server_name=server_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [202]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize( - _models.ErrorResponse, - pipeline_response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - response_headers = {} - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def begin_start(self, resource_group_name: str, server_name: str, **kwargs: Any) -> AsyncLROPoller[None]: - """Starts a stopped server. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._start_initial( - resource_group_name=resource_group_name, - server_name=server_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: AsyncPollingMethod = cast( - AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - async def _stop_initial(self, resource_group_name: str, server_name: str, **kwargs: Any) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_stop_request( - resource_group_name=resource_group_name, - server_name=server_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [202]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize( - _models.ErrorResponse, - pipeline_response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - response_headers = {} - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def begin_stop(self, resource_group_name: str, server_name: str, **kwargs: Any) -> AsyncLROPoller[None]: - """Stops a server. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._stop_initial( - resource_group_name=resource_group_name, - server_name=server_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: AsyncPollingMethod = cast( - AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/azure/mgmt/postgresqlflexibleservers/aio/operations/_tuning_options_operations.py b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/azure/mgmt/postgresqlflexibleservers/aio/operations/_tuning_options_operations.py deleted file mode 100644 index 519ecd34c582..000000000000 --- a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/azure/mgmt/postgresqlflexibleservers/aio/operations/_tuning_options_operations.py +++ /dev/null @@ -1,325 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from collections.abc import MutableMapping -from typing import Any, Callable, Optional, TypeVar, Union -import urllib.parse - -from azure.core import AsyncPipelineClient -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.rest import AsyncHttpResponse, HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._utils.serialization import Deserializer, Serializer -from ...operations._tuning_options_operations import ( - build_get_request, - build_list_by_server_request, - build_list_recommendations_request, -) -from .._configuration import PostgreSQLManagementClientConfiguration - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] -List = list - - -class TuningOptionsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.postgresqlflexibleservers.aio.PostgreSQLManagementClient`'s - :attr:`tuning_options` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: PostgreSQLManagementClientConfiguration = ( - input_args.pop(0) if input_args else kwargs.pop("config") - ) - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace_async - async def get( - self, - resource_group_name: str, - server_name: str, - tuning_option: Union[str, _models.TuningOptionParameterEnum], - **kwargs: Any - ) -> _models.TuningOptions: - """Gets the tuning options of a server. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param tuning_option: The name of the tuning option. Known values are: "index" and "table". - Required. - :type tuning_option: str or - ~azure.mgmt.postgresqlflexibleservers.models.TuningOptionParameterEnum - :return: TuningOptions or the result of cls(response) - :rtype: ~azure.mgmt.postgresqlflexibleservers.models.TuningOptions - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.TuningOptions] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - server_name=server_name, - tuning_option=tuning_option, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize( - _models.ErrorResponse, - pipeline_response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("TuningOptions", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def list_recommendations( - self, - resource_group_name: str, - server_name: str, - tuning_option: Union[str, _models.TuningOptionParameterEnum], - recommendation_type: Optional[Union[str, _models.RecommendationTypeParameterEnum]] = None, - **kwargs: Any - ) -> AsyncItemPaged["_models.ObjectRecommendation"]: - """Lists available object recommendations. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param tuning_option: The name of the tuning option. Known values are: "index" and "table". - Required. - :type tuning_option: str or - ~azure.mgmt.postgresqlflexibleservers.models.TuningOptionParameterEnum - :param recommendation_type: Recommendations list filter. Retrieves recommendations based on - type. Known values are: "CreateIndex", "DropIndex", "ReIndex", and "AnalyzeTable". Default - value is None. - :type recommendation_type: str or - ~azure.mgmt.postgresqlflexibleservers.models.RecommendationTypeParameterEnum - :return: An iterator like instance of either ObjectRecommendation or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.postgresqlflexibleservers.models.ObjectRecommendation] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.ObjectRecommendationList] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_recommendations_request( - resource_group_name=resource_group_name, - server_name=server_name, - tuning_option=tuning_option, - subscription_id=self._config.subscription_id, - recommendation_type=recommendation_type, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("ObjectRecommendationList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize( - _models.ErrorResponse, - pipeline_response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace - def list_by_server( - self, resource_group_name: str, server_name: str, **kwargs: Any - ) -> AsyncItemPaged["_models.TuningOptions"]: - """Lists the tuning options of a server. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :return: An iterator like instance of either TuningOptions or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.postgresqlflexibleservers.models.TuningOptions] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.TuningOptionsList] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_by_server_request( - resource_group_name=resource_group_name, - server_name=server_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("TuningOptionsList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize( - _models.ErrorResponse, - pipeline_response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) diff --git a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/azure/mgmt/postgresqlflexibleservers/aio/operations/_virtual_endpoints_operations.py b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/azure/mgmt/postgresqlflexibleservers/aio/operations/_virtual_endpoints_operations.py deleted file mode 100644 index ba00e463fbc4..000000000000 --- a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/azure/mgmt/postgresqlflexibleservers/aio/operations/_virtual_endpoints_operations.py +++ /dev/null @@ -1,788 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from collections.abc import MutableMapping -from io import IOBase -from typing import Any, AsyncIterator, Callable, IO, Optional, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core import AsyncPipelineClient -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import AsyncHttpResponse, HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling - -from ... import models as _models -from ..._utils.serialization import Deserializer, Serializer -from ...operations._virtual_endpoints_operations import ( - build_create_request, - build_delete_request, - build_get_request, - build_list_by_server_request, - build_update_request, -) -from .._configuration import PostgreSQLManagementClientConfiguration - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] -List = list - - -class VirtualEndpointsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.postgresqlflexibleservers.aio.PostgreSQLManagementClient`'s - :attr:`virtual_endpoints` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: PostgreSQLManagementClientConfiguration = ( - input_args.pop(0) if input_args else kwargs.pop("config") - ) - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - async def _create_initial( - self, - resource_group_name: str, - server_name: str, - virtual_endpoint_name: str, - parameters: Union[_models.VirtualEndpoint, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "VirtualEndpoint") - - _request = build_create_request( - resource_group_name=resource_group_name, - server_name=server_name, - virtual_endpoint_name=virtual_endpoint_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize( - _models.ErrorResponse, - pipeline_response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - response_headers = {} - if response.status_code == 202: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @overload - async def begin_create( - self, - resource_group_name: str, - server_name: str, - virtual_endpoint_name: str, - parameters: _models.VirtualEndpoint, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.VirtualEndpoint]: - """Creates a pair of virtual endpoints for a server. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param virtual_endpoint_name: Base name of the virtual endpoints. Required. - :type virtual_endpoint_name: str - :param parameters: Parameters required to create or update a pair of virtual endpoints. - Required. - :type parameters: ~azure.mgmt.postgresqlflexibleservers.models.VirtualEndpoint - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either VirtualEndpoint or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.postgresqlflexibleservers.models.VirtualEndpoint] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_create( - self, - resource_group_name: str, - server_name: str, - virtual_endpoint_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.VirtualEndpoint]: - """Creates a pair of virtual endpoints for a server. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param virtual_endpoint_name: Base name of the virtual endpoints. Required. - :type virtual_endpoint_name: str - :param parameters: Parameters required to create or update a pair of virtual endpoints. - Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either VirtualEndpoint or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.postgresqlflexibleservers.models.VirtualEndpoint] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_create( - self, - resource_group_name: str, - server_name: str, - virtual_endpoint_name: str, - parameters: Union[_models.VirtualEndpoint, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.VirtualEndpoint]: - """Creates a pair of virtual endpoints for a server. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param virtual_endpoint_name: Base name of the virtual endpoints. Required. - :type virtual_endpoint_name: str - :param parameters: Parameters required to create or update a pair of virtual endpoints. Is - either a VirtualEndpoint type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.postgresqlflexibleservers.models.VirtualEndpoint or IO[bytes] - :return: An instance of AsyncLROPoller that returns either VirtualEndpoint or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.postgresqlflexibleservers.models.VirtualEndpoint] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.VirtualEndpoint] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._create_initial( - resource_group_name=resource_group_name, - server_name=server_name, - virtual_endpoint_name=virtual_endpoint_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("VirtualEndpoint", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - if polling is True: - polling_method: AsyncPollingMethod = cast( - AsyncPollingMethod, - AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[_models.VirtualEndpoint].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.VirtualEndpoint]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _update_initial( - self, - resource_group_name: str, - server_name: str, - virtual_endpoint_name: str, - parameters: Union[_models.VirtualEndpointResourceForPatch, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "VirtualEndpointResourceForPatch") - - _request = build_update_request( - resource_group_name=resource_group_name, - server_name=server_name, - virtual_endpoint_name=virtual_endpoint_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize( - _models.ErrorResponse, - pipeline_response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - response_headers = {} - if response.status_code == 202: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @overload - async def begin_update( - self, - resource_group_name: str, - server_name: str, - virtual_endpoint_name: str, - parameters: _models.VirtualEndpointResourceForPatch, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.VirtualEndpoint]: - """Updates a pair of virtual endpoints for a server. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param virtual_endpoint_name: Base name of the virtual endpoints. Required. - :type virtual_endpoint_name: str - :param parameters: Parameters required to update a pair of virtual endpoints. Required. - :type parameters: ~azure.mgmt.postgresqlflexibleservers.models.VirtualEndpointResourceForPatch - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either VirtualEndpoint or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.postgresqlflexibleservers.models.VirtualEndpoint] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_update( - self, - resource_group_name: str, - server_name: str, - virtual_endpoint_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.VirtualEndpoint]: - """Updates a pair of virtual endpoints for a server. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param virtual_endpoint_name: Base name of the virtual endpoints. Required. - :type virtual_endpoint_name: str - :param parameters: Parameters required to update a pair of virtual endpoints. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either VirtualEndpoint or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.postgresqlflexibleservers.models.VirtualEndpoint] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_update( - self, - resource_group_name: str, - server_name: str, - virtual_endpoint_name: str, - parameters: Union[_models.VirtualEndpointResourceForPatch, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.VirtualEndpoint]: - """Updates a pair of virtual endpoints for a server. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param virtual_endpoint_name: Base name of the virtual endpoints. Required. - :type virtual_endpoint_name: str - :param parameters: Parameters required to update a pair of virtual endpoints. Is either a - VirtualEndpointResourceForPatch type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.postgresqlflexibleservers.models.VirtualEndpointResourceForPatch - or IO[bytes] - :return: An instance of AsyncLROPoller that returns either VirtualEndpoint or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.postgresqlflexibleservers.models.VirtualEndpoint] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.VirtualEndpoint] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._update_initial( - resource_group_name=resource_group_name, - server_name=server_name, - virtual_endpoint_name=virtual_endpoint_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("VirtualEndpoint", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - if polling is True: - polling_method: AsyncPollingMethod = cast( - AsyncPollingMethod, - AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[_models.VirtualEndpoint].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.VirtualEndpoint]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _delete_initial( - self, resource_group_name: str, server_name: str, virtual_endpoint_name: str, **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_delete_request( - resource_group_name=resource_group_name, - server_name=server_name, - virtual_endpoint_name=virtual_endpoint_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [202, 204]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize( - _models.ErrorResponse, - pipeline_response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - response_headers = {} - if response.status_code == 202: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def begin_delete( - self, resource_group_name: str, server_name: str, virtual_endpoint_name: str, **kwargs: Any - ) -> AsyncLROPoller[None]: - """Deletes a pair of virtual endpoints. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param virtual_endpoint_name: Base name of the virtual endpoints. Required. - :type virtual_endpoint_name: str - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._delete_initial( - resource_group_name=resource_group_name, - server_name=server_name, - virtual_endpoint_name=virtual_endpoint_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: AsyncPollingMethod = cast( - AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - @distributed_trace_async - async def get( - self, resource_group_name: str, server_name: str, virtual_endpoint_name: str, **kwargs: Any - ) -> _models.VirtualEndpoint: - """Gets information about a pair of virtual endpoints. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param virtual_endpoint_name: Base name of the virtual endpoints. Required. - :type virtual_endpoint_name: str - :return: VirtualEndpoint or the result of cls(response) - :rtype: ~azure.mgmt.postgresqlflexibleservers.models.VirtualEndpoint - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.VirtualEndpoint] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - server_name=server_name, - virtual_endpoint_name=virtual_endpoint_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize( - _models.ErrorResponse, - pipeline_response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("VirtualEndpoint", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def list_by_server( - self, resource_group_name: str, server_name: str, **kwargs: Any - ) -> AsyncItemPaged["_models.VirtualEndpoint"]: - """Lists pair of virtual endpoints associated to a server. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :return: An iterator like instance of either VirtualEndpoint or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.postgresqlflexibleservers.models.VirtualEndpoint] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.VirtualEndpointsList] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_by_server_request( - resource_group_name=resource_group_name, - server_name=server_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("VirtualEndpointsList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize( - _models.ErrorResponse, - pipeline_response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) diff --git a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/azure/mgmt/postgresqlflexibleservers/aio/operations/_virtual_network_subnet_usage_operations.py b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/azure/mgmt/postgresqlflexibleservers/aio/operations/_virtual_network_subnet_usage_operations.py deleted file mode 100644 index 67952052b850..000000000000 --- a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/azure/mgmt/postgresqlflexibleservers/aio/operations/_virtual_network_subnet_usage_operations.py +++ /dev/null @@ -1,174 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from collections.abc import MutableMapping -from io import IOBase -from typing import Any, Callable, IO, Optional, TypeVar, Union, overload - -from azure.core import AsyncPipelineClient -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.rest import AsyncHttpResponse, HttpRequest -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._utils.serialization import Deserializer, Serializer -from ...operations._virtual_network_subnet_usage_operations import build_list_request -from .._configuration import PostgreSQLManagementClientConfiguration - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] -List = list - - -class VirtualNetworkSubnetUsageOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.postgresqlflexibleservers.aio.PostgreSQLManagementClient`'s - :attr:`virtual_network_subnet_usage` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: PostgreSQLManagementClientConfiguration = ( - input_args.pop(0) if input_args else kwargs.pop("config") - ) - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @overload - async def list( - self, - location_name: str, - parameters: _models.VirtualNetworkSubnetUsageParameter, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.VirtualNetworkSubnetUsageModel: - """Lists the virtual network subnet usage for a given virtual network. - - :param location_name: The name of the location. Required. - :type location_name: str - :param parameters: The required parameters for creating or updating a server. Required. - :type parameters: - ~azure.mgmt.postgresqlflexibleservers.models.VirtualNetworkSubnetUsageParameter - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: VirtualNetworkSubnetUsageModel or the result of cls(response) - :rtype: ~azure.mgmt.postgresqlflexibleservers.models.VirtualNetworkSubnetUsageModel - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def list( - self, location_name: str, parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> _models.VirtualNetworkSubnetUsageModel: - """Lists the virtual network subnet usage for a given virtual network. - - :param location_name: The name of the location. Required. - :type location_name: str - :param parameters: The required parameters for creating or updating a server. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: VirtualNetworkSubnetUsageModel or the result of cls(response) - :rtype: ~azure.mgmt.postgresqlflexibleservers.models.VirtualNetworkSubnetUsageModel - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def list( - self, - location_name: str, - parameters: Union[_models.VirtualNetworkSubnetUsageParameter, IO[bytes]], - **kwargs: Any - ) -> _models.VirtualNetworkSubnetUsageModel: - """Lists the virtual network subnet usage for a given virtual network. - - :param location_name: The name of the location. Required. - :type location_name: str - :param parameters: The required parameters for creating or updating a server. Is either a - VirtualNetworkSubnetUsageParameter type or a IO[bytes] type. Required. - :type parameters: - ~azure.mgmt.postgresqlflexibleservers.models.VirtualNetworkSubnetUsageParameter or IO[bytes] - :return: VirtualNetworkSubnetUsageModel or the result of cls(response) - :rtype: ~azure.mgmt.postgresqlflexibleservers.models.VirtualNetworkSubnetUsageModel - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.VirtualNetworkSubnetUsageModel] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "VirtualNetworkSubnetUsageParameter") - - _request = build_list_request( - location_name=location_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize( - _models.ErrorResponse, - pipeline_response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("VirtualNetworkSubnetUsageModel", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/azure/mgmt/postgresqlflexibleservers/models/__init__.py b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/azure/mgmt/postgresqlflexibleservers/models/__init__.py index be8bdb6bb2ff..a892dcffa709 100644 --- a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/azure/mgmt/postgresqlflexibleservers/models/__init__.py +++ b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/azure/mgmt/postgresqlflexibleservers/models/__init__.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- # pylint: disable=wrong-import-position @@ -13,19 +13,20 @@ from ._patch import * # pylint: disable=unused-wildcard-import -from ._models_py3 import ( # type: ignore +from ._models import ( # type: ignore AdminCredentials, AdminCredentialsForPatch, AdministratorMicrosoftEntra, AdministratorMicrosoftEntraAdd, - AdministratorMicrosoftEntraList, - AdvancedThreatProtectionSettingsList, + AdministratorMicrosoftEntraProperties, + AdministratorMicrosoftEntraPropertiesForAdd, AdvancedThreatProtectionSettingsModel, + AdvancedThreatProtectionSettingsProperties, AuthConfig, AuthConfigForPatch, Backup, BackupAutomaticAndOnDemand, - BackupAutomaticAndOnDemandList, + BackupAutomaticAndOnDemandProperties, BackupForPatch, BackupRequestBase, BackupSettings, @@ -33,21 +34,21 @@ BackupsLongTermRetentionOperation, BackupsLongTermRetentionRequest, BackupsLongTermRetentionResponse, + BackupsLongTermRetentionResponseProperties, Capability, CapabilityBase, - CapabilityList, CapturedLog, - CapturedLogList, + CapturedLogProperties, CheckNameAvailabilityRequest, CheckNameAvailabilityResponse, Cluster, Configuration, ConfigurationForUpdate, - ConfigurationList, + ConfigurationProperties, DataEncryption, Database, - DatabaseList, DatabaseMigrationState, + DatabaseProperties, DbLevelValidationStatus, DbServerMetadata, DelegatedSubnetUsage, @@ -56,18 +57,22 @@ ErrorResponse, FastProvisioningEditionCapability, FirewallRule, - FirewallRuleList, + FirewallRuleProperties, HighAvailability, HighAvailabilityForPatch, ImpactRecord, + LogSpecification, + LtrBackupOperationResponseProperties, LtrPreBackupRequest, LtrPreBackupResponse, - LtrServerBackupOperationList, MaintenanceWindow, MaintenanceWindowForPatch, + MetricSpecification, + MigrateNetworkStatus, Migration, - MigrationList, MigrationNameAvailability, + MigrationProperties, + MigrationPropertiesForPatch, MigrationResourceForPatch, MigrationSecretParameters, MigrationSecretParametersForPatch, @@ -78,31 +83,32 @@ Network, ObjectRecommendation, ObjectRecommendationDetails, - ObjectRecommendationList, + ObjectRecommendationProperties, ObjectRecommendationPropertiesAnalyzedWorkload, ObjectRecommendationPropertiesImplementationDetails, Operation, OperationDisplay, - OperationList, + OperationProperties, PrivateEndpoint, PrivateEndpointConnection, - PrivateEndpointConnectionList, + PrivateEndpointConnectionProperties, PrivateLinkResource, - PrivateLinkResourceList, + PrivateLinkResourceProperties, PrivateLinkServiceConnectionState, ProxyResource, QuotaUsage, - QuotaUsageList, Replica, Resource, RestartParameter, Server, ServerEditionCapability, ServerForPatch, - ServerList, + ServerProperties, + ServerPropertiesForPatch, ServerSku, ServerSkuCapability, ServerVersionCapability, + ServiceSpecification, Sku, SkuForPatch, Storage, @@ -113,7 +119,7 @@ SystemData, TrackedResource, TuningOptions, - TuningOptionsList, + TuningOptionsProperties, UserAssignedIdentity, UserIdentity, ValidationDetails, @@ -121,12 +127,12 @@ ValidationSummaryItem, VirtualEndpoint, VirtualEndpointResourceForPatch, - VirtualEndpointsList, + VirtualEndpointResourceProperties, VirtualNetworkSubnetUsageModel, VirtualNetworkSubnetUsageParameter, ) -from ._postgre_sql_management_client_enums import ( # type: ignore +from ._enums import ( # type: ignore AzureManagedDiskPerformanceTier, BackupType, Cancel, @@ -152,17 +158,18 @@ MicrosoftEntraAuth, MigrateRolesAndPermissions, MigrationDatabaseState, - MigrationDetailsLevel, MigrationListFilter, MigrationMode, MigrationNameAvailabilityReason, MigrationOption, MigrationState, MigrationSubstate, + NetworkMigrationState, OnlineStorageResizeSupport, OperationOrigin, OverwriteDatabasesOnTargetServer, PasswordBasedAuth, + PostgreSqlFlexibleServerHighAvailabilityMode, PostgresMajorVersion, PrincipalType, PrivateEndpointConnectionProvisioningState, @@ -200,14 +207,15 @@ "AdminCredentialsForPatch", "AdministratorMicrosoftEntra", "AdministratorMicrosoftEntraAdd", - "AdministratorMicrosoftEntraList", - "AdvancedThreatProtectionSettingsList", + "AdministratorMicrosoftEntraProperties", + "AdministratorMicrosoftEntraPropertiesForAdd", "AdvancedThreatProtectionSettingsModel", + "AdvancedThreatProtectionSettingsProperties", "AuthConfig", "AuthConfigForPatch", "Backup", "BackupAutomaticAndOnDemand", - "BackupAutomaticAndOnDemandList", + "BackupAutomaticAndOnDemandProperties", "BackupForPatch", "BackupRequestBase", "BackupSettings", @@ -215,21 +223,21 @@ "BackupsLongTermRetentionOperation", "BackupsLongTermRetentionRequest", "BackupsLongTermRetentionResponse", + "BackupsLongTermRetentionResponseProperties", "Capability", "CapabilityBase", - "CapabilityList", "CapturedLog", - "CapturedLogList", + "CapturedLogProperties", "CheckNameAvailabilityRequest", "CheckNameAvailabilityResponse", "Cluster", "Configuration", "ConfigurationForUpdate", - "ConfigurationList", + "ConfigurationProperties", "DataEncryption", "Database", - "DatabaseList", "DatabaseMigrationState", + "DatabaseProperties", "DbLevelValidationStatus", "DbServerMetadata", "DelegatedSubnetUsage", @@ -238,18 +246,22 @@ "ErrorResponse", "FastProvisioningEditionCapability", "FirewallRule", - "FirewallRuleList", + "FirewallRuleProperties", "HighAvailability", "HighAvailabilityForPatch", "ImpactRecord", + "LogSpecification", + "LtrBackupOperationResponseProperties", "LtrPreBackupRequest", "LtrPreBackupResponse", - "LtrServerBackupOperationList", "MaintenanceWindow", "MaintenanceWindowForPatch", + "MetricSpecification", + "MigrateNetworkStatus", "Migration", - "MigrationList", "MigrationNameAvailability", + "MigrationProperties", + "MigrationPropertiesForPatch", "MigrationResourceForPatch", "MigrationSecretParameters", "MigrationSecretParametersForPatch", @@ -260,31 +272,32 @@ "Network", "ObjectRecommendation", "ObjectRecommendationDetails", - "ObjectRecommendationList", + "ObjectRecommendationProperties", "ObjectRecommendationPropertiesAnalyzedWorkload", "ObjectRecommendationPropertiesImplementationDetails", "Operation", "OperationDisplay", - "OperationList", + "OperationProperties", "PrivateEndpoint", "PrivateEndpointConnection", - "PrivateEndpointConnectionList", + "PrivateEndpointConnectionProperties", "PrivateLinkResource", - "PrivateLinkResourceList", + "PrivateLinkResourceProperties", "PrivateLinkServiceConnectionState", "ProxyResource", "QuotaUsage", - "QuotaUsageList", "Replica", "Resource", "RestartParameter", "Server", "ServerEditionCapability", "ServerForPatch", - "ServerList", + "ServerProperties", + "ServerPropertiesForPatch", "ServerSku", "ServerSkuCapability", "ServerVersionCapability", + "ServiceSpecification", "Sku", "SkuForPatch", "Storage", @@ -295,7 +308,7 @@ "SystemData", "TrackedResource", "TuningOptions", - "TuningOptionsList", + "TuningOptionsProperties", "UserAssignedIdentity", "UserIdentity", "ValidationDetails", @@ -303,7 +316,7 @@ "ValidationSummaryItem", "VirtualEndpoint", "VirtualEndpointResourceForPatch", - "VirtualEndpointsList", + "VirtualEndpointResourceProperties", "VirtualNetworkSubnetUsageModel", "VirtualNetworkSubnetUsageParameter", "AzureManagedDiskPerformanceTier", @@ -331,17 +344,18 @@ "MicrosoftEntraAuth", "MigrateRolesAndPermissions", "MigrationDatabaseState", - "MigrationDetailsLevel", "MigrationListFilter", "MigrationMode", "MigrationNameAvailabilityReason", "MigrationOption", "MigrationState", "MigrationSubstate", + "NetworkMigrationState", "OnlineStorageResizeSupport", "OperationOrigin", "OverwriteDatabasesOnTargetServer", "PasswordBasedAuth", + "PostgreSqlFlexibleServerHighAvailabilityMode", "PostgresMajorVersion", "PrincipalType", "PrivateEndpointConnectionProvisioningState", diff --git a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/azure/mgmt/postgresqlflexibleservers/models/_postgre_sql_management_client_enums.py b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/azure/mgmt/postgresqlflexibleservers/models/_enums.py similarity index 55% rename from sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/azure/mgmt/postgresqlflexibleservers/models/_postgre_sql_management_client_enums.py rename to sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/azure/mgmt/postgresqlflexibleservers/models/_enums.py index 215777676a1c..0a81f1f0ec54 100644 --- a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/azure/mgmt/postgresqlflexibleservers/models/_postgre_sql_management_client_enums.py +++ b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/azure/mgmt/postgresqlflexibleservers/models/_enums.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -14,144 +14,140 @@ class AzureManagedDiskPerformanceTier(str, Enum, metaclass=CaseInsensitiveEnumMe """Storage tier of a server.""" P1 = "P1" - """Entry-level SSD for minimal IOPS, ideal for light development or testing workloads.""" + """P1.""" P2 = "P2" - """Slightly higher IOPS for small-scale applications needing consistent low latency.""" + """P2.""" P3 = "P3" - """Balanced performance for basic production workloads with moderate throughput.""" + """P3.""" P4 = "P4" - """Enhanced IOPS for growing apps with predictable performance needs.""" + """P4.""" P6 = "P6" - """Mid-tier SSD for steady workloads requiring reliable throughput and latency.""" + """P6.""" P10 = "P10" - """Popular choice for general-purpose production workloads with scalable performance.""" + """P10.""" P15 = "P15" - """High IOPS tier for demanding apps with frequent read/write operations.""" + """P15.""" P20 = "P20" - """Entry point for high-performance Solid State Disks (SSDs), suitable for small-scale - I/O-intensive workloads.""" + """P20.""" P30 = "P30" - """Balanced tier for moderate throughput and latency-sensitive applications.""" + """P30.""" P40 = "P40" - """Enhanced performance for growing production workloads with consistent IOPS demands.""" + """P40.""" P50 = "P50" - """Optimized for enterprise-grade applications needing sustained high throughput.""" + """P50.""" P60 = "P60" - """High-capacity tier for large databases and analytics workloads with elevated IOPS.""" + """P60.""" P70 = "P70" - """Designed for mission-critical systems requiring ultra-low latency and high concurrency.""" + """P70.""" P80 = "P80" - """Top-tier SSD for maximum IOPS and throughput, ideal for the most demanding workloads.""" + """P80.""" class BackupType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Type of backup.""" FULL = "Full" - """A full backup taken automatically by the service. These backups are retained for a period of - time as defined by the backup retention policy, and they cannot be deleted by the customer.""" + """FULL.""" CUSTOMER_ON_DEMAND = "Customer On-Demand" - """A full backup triggered by the customer. These backups are retained for a period of time as - defined by the backup retention policy, and they can also be deleted by the customer.""" + """CUSTOMER_ON_DEMAND.""" class Cancel(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Indicates if cancel must be triggered for the entire migration.""" TRUE = "True" - """Cancel must be triggered for the entire migration.""" + """TRUE.""" FALSE = "False" - """Cancel must not be triggered for the entire migration.""" + """FALSE.""" class CapabilityStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The status of the capability.""" VISIBLE = "Visible" + """VISIBLE.""" AVAILABLE = "Available" + """AVAILABLE.""" DEFAULT = "Default" + """DEFAULT.""" DISABLED = "Disabled" + """DISABLED.""" class CheckNameAvailabilityReason(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The reason why the given name is not available.""" + """Possible reasons for a name not being available.""" INVALID = "Invalid" + """Name is invalid.""" ALREADY_EXISTS = "AlreadyExists" + """Name already exists.""" class ConfigurationDataType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Data type of the configuration (also known as server parameter).""" BOOLEAN = "Boolean" - """A boolean value.""" + """BOOLEAN.""" NUMERIC = "Numeric" - """A numeric value.""" + """NUMERIC.""" INTEGER = "Integer" - """An integer value.""" + """INTEGER.""" ENUMERATION = "Enumeration" - """An enumeration value.""" + """ENUMERATION.""" STRING = "String" - """A string value.""" + """STRING.""" SET = "Set" - """A set of values.""" + """SET.""" class CreatedByType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The type of identity that created the resource.""" + """The kind of entity that created the resource.""" USER = "User" + """The entity was created by a user.""" APPLICATION = "Application" + """The entity was created by an application.""" MANAGED_IDENTITY = "ManagedIdentity" + """The entity was created by a managed identity.""" KEY = "Key" + """The entity was created by a key.""" class CreateMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Creation mode of a new server.""" DEFAULT = "Default" - """If the operation is triggered on a non-existing server, it's equivalent to 'Create'. If the - operation is triggered on an existing server, it's equivalent to 'Update'.""" + """DEFAULT.""" CREATE = "Create" - """Operation creates a new server.""" + """CREATE.""" UPDATE = "Update" - """Operation updates an existing server.""" + """UPDATE.""" POINT_IN_TIME_RESTORE = "PointInTimeRestore" - """Operation restores an existing backup of an existing server. This operation creates a new - server, and then restores on it the backup of an existing server at a specific point in time.""" + """POINT_IN_TIME_RESTORE.""" GEO_RESTORE = "GeoRestore" - """Operation restores an existing backup of an existing server, on the paired region of the - existing server. This operation creates a new server on the paired region of the existing - server, and then restores on it the backup of an existing server at a specific point in time, - in a different region. This operation is only supported on existing servers that were created - with geographically redundant backups enabled.""" + """GEO_RESTORE.""" REPLICA = "Replica" - """Operation creates a replica of an existing server. This operation creates a new server, - restores a base backup of the existing server (referred to as primary), and configures physical - replication to asynchronously stream all changes which are recorded in the transaction log of - the primary.""" + """REPLICA.""" REVIVE_DROPPED = "ReviveDropped" - """Operation creates a new server, initialized with the backup of a server that was recently - deleted.""" + """REVIVE_DROPPED.""" class CreateModeForPatch(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Update mode of an existing server.""" DEFAULT = "Default" - """It's equivalent to 'Update'.""" + """DEFAULT.""" UPDATE = "Update" - """Operation updates an existing server.""" + """UPDATE.""" class DataEncryptionType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Data encryption type used by a server.""" SYSTEM_MANAGED = "SystemManaged" - """Encryption managed by Azure using platform managed keys for simplicity and compliance.""" + """SYSTEM_MANAGED.""" AZURE_KEY_VAULT = "AzureKeyVault" - """Encryption using customer managed keys stored in Azure Key Vault for enhanced control and - security.""" + """AZURE_KEY_VAULT.""" class EncryptionKeyStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): @@ -160,40 +156,35 @@ class EncryptionKeyStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): """ VALID = "Valid" - """Key is valid and can be used for encryption.""" + """VALID.""" INVALID = "Invalid" - """Key is invalid and cannot be used for encryption. Possible causes include key deletion, - permission changes, key being disabled, key type not supported, or current date being outside - of validity period associated to the key.""" + """INVALID.""" class ExecutionStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Service-set extensible enum indicating the status of operation.""" RUNNING = "Running" - """The operation is currently running.""" + """RUNNING.""" CANCELLED = "Cancelled" - """The operation was cancelled.""" + """CANCELLED.""" FAILED = "Failed" - """The operation failed.""" + """FAILED.""" SUCCEEDED = "Succeeded" - """The operation succeeded.""" + """SUCCEEDED.""" class FailoverMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Failover mode.""" PLANNED_FAILOVER = "PlannedFailover" - """Triggers a failover from primary to standby without killing the primary database process first. - This is a graceful failover that attempts to preserve data consistency.""" + """PLANNED_FAILOVER.""" FORCED_FAILOVER = "ForcedFailover" - """Kills the primary database process first, then triggers the failover. This is more aggressive - and used when the primary is unresponsive or in an unhealthy state.""" + """FORCED_FAILOVER.""" PLANNED_SWITCHOVER = "PlannedSwitchover" - """Similar to 'PlannedFailover' but prefers a switch over operation where roles are swapped - between primary and standby.""" + """PLANNED_SWITCHOVER.""" FORCED_SWITCHOVER = "ForcedSwitchover" - """Kills the primary database process and then triggers a switch over with role swapping.""" + """FORCED_SWITCHOVER.""" class FastProvisioningSupport(str, Enum, metaclass=CaseInsensitiveEnumMeta): @@ -203,27 +194,27 @@ class FastProvisioningSupport(str, Enum, metaclass=CaseInsensitiveEnumMeta): """ ENABLED = "Enabled" - """Fast provisioning is supported.""" + """ENABLED.""" DISABLED = "Disabled" - """Fast provisioning is not supported.""" + """DISABLED.""" class FeatureStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Status of the feature. Indicates if the feature is enabled or not.""" ENABLED = "Enabled" - """Feature is enabled.""" + """ENABLED.""" DISABLED = "Disabled" - """Feature is disabled.""" + """DISABLED.""" class GeographicallyRedundantBackup(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Indicates if the server is configured to create geographically redundant backups.""" ENABLED = "Enabled" - """Server is configured to create geographically redundant backups.""" + """ENABLED.""" DISABLED = "Disabled" - """Server is not configured to create geographically redundant backups.""" + """DISABLED.""" class GeographicallyRedundantBackupSupport(str, Enum, metaclass=CaseInsensitiveEnumMeta): @@ -234,20 +225,18 @@ class GeographicallyRedundantBackupSupport(str, Enum, metaclass=CaseInsensitiveE """ ENABLED = "Enabled" - """Geographically redundant backups are supported.""" + """ENABLED.""" DISABLED = "Disabled" - """Geographically redundant backups are not supported.""" + """DISABLED.""" class HighAvailabilityMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Modes of high availability supported for this compute.""" ZONE_REDUNDANT = "ZoneRedundant" - """High availability is enabled for the server, with standby server in a different availability - zone than that of the primary.""" + """ZONE_REDUNDANT.""" SAME_ZONE = "SameZone" - """High availability is enabled for the server, with standby server in the same availability zone - as the primary.""" + """SAME_ZONE.""" class HighAvailabilityState(str, Enum, metaclass=CaseInsensitiveEnumMeta): @@ -256,30 +245,30 @@ class HighAvailabilityState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """ NOT_ENABLED = "NotEnabled" - """High availability is not enabled for the server.""" + """NOT_ENABLED.""" CREATING_STANDBY = "CreatingStandby" - """Standby server is being created.""" + """CREATING_STANDBY.""" REPLICATING_DATA = "ReplicatingData" - """Data is being replicated to the standby server.""" + """REPLICATING_DATA.""" FAILING_OVER = "FailingOver" - """Failover operation to the standby server is in progress.""" + """FAILING_OVER.""" HEALTHY = "Healthy" - """Standby server is healthy and ready to take over in case of a failover.""" + """HEALTHY.""" REMOVING_STANDBY = "RemovingStandby" - """Standby server is being removed.""" + """REMOVING_STANDBY.""" class IdentityType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Types of identities associated with a server.""" NONE = "None" - """No managed identity is assigned to the server.""" + """NONE.""" USER_ASSIGNED = "UserAssigned" - """One or more managed identities provided by the user are assigned to the server.""" + """USER_ASSIGNED.""" SYSTEM_ASSIGNED = "SystemAssigned" - """Azure automatically creates and manages the identity associated to the lifecycle of the server.""" + """SYSTEM_ASSIGNED.""" SYSTEM_ASSIGNED_USER_ASSIGNED = "SystemAssigned,UserAssigned" - """Both system-assigned and user-assigned identities are assigned to the server.""" + """SYSTEM_ASSIGNED_USER_ASSIGNED.""" class LocationRestricted(str, Enum, metaclass=CaseInsensitiveEnumMeta): @@ -289,150 +278,156 @@ class LocationRestricted(str, Enum, metaclass=CaseInsensitiveEnumMeta): """ ENABLED = "Enabled" - """Location is restricted.""" + """ENABLED.""" DISABLED = "Disabled" - """Location is not restricted.""" + """DISABLED.""" class LogicalReplicationOnSourceServer(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Indicates whether to setup logical replication on source server, if needed.""" TRUE = "True" - """Logical replication will be set up on the source server.""" + """TRUE.""" FALSE = "False" - """Logical replication will not be set up on the source server.""" + """FALSE.""" class MicrosoftEntraAuth(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Indicates if the server supports Microsoft Entra authentication.""" ENABLED = "Enabled" - """Server supports Microsoft Entra authentication.""" + """ENABLED.""" DISABLED = "Disabled" - """Server doesn't support Microsoft Entra authentication.""" + """DISABLED.""" class MigrateRolesAndPermissions(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Indicates if roles and permissions must be migrated.""" TRUE = "True" - """Roles and permissions will be migrated.""" + """TRUE.""" FALSE = "False" - """Roles and permissions will not be migrated.""" + """FALSE.""" class MigrationDatabaseState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Migration state of a database.""" IN_PROGRESS = "InProgress" - """Migration is in progress for the database.""" + """IN_PROGRESS.""" WAITING_FOR_CUTOVER_TRIGGER = "WaitingForCutoverTrigger" - """Migration is waiting for cutover trigger for the database.""" + """WAITING_FOR_CUTOVER_TRIGGER.""" FAILED = "Failed" - """Migration has failed for the database.""" + """FAILED.""" CANCELED = "Canceled" - """Migration has been canceled for the database.""" + """CANCELED.""" SUCCEEDED = "Succeeded" - """Migration has succeeded for the database.""" + """SUCCEEDED.""" CANCELING = "Canceling" - """Migration is canceling for the database.""" - - -class MigrationDetailsLevel(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Level of details of a migration.""" - - DEFAULT = "Default" - """Default level of details.""" - SUMMARY = "Summary" - """Summary level of details.""" - FULL = "Full" - """Full level of details.""" + """CANCELING.""" class MigrationListFilter(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """MigrationListFilter.""" + """Type of MigrationListFilter.""" ACTIVE = "Active" - """Only active (in-progress) migrations.""" + """ACTIVE.""" ALL = "All" - """All migrations.""" + """ALL.""" class MigrationMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Mode used to perform the migration: Online or Offline.""" OFFLINE = "Offline" - """Offline migration mode.""" + """OFFLINE.""" ONLINE = "Online" - """Online migration mode.""" + """ONLINE.""" class MigrationNameAvailabilityReason(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Migration name availability reason.""" INVALID = "Invalid" - """Migration name is invalid.""" + """INVALID.""" ALREADY_EXISTS = "AlreadyExists" - """Migration name already exists.""" + """ALREADY_EXISTS.""" class MigrationOption(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Supported option for a migration.""" VALIDATE = "Validate" - """Validate the migration without performing it.""" + """VALIDATE.""" MIGRATE = "Migrate" - """Perform the migration.""" + """MIGRATE.""" VALIDATE_AND_MIGRATE = "ValidateAndMigrate" - """Validate and perform the migration.""" + """VALIDATE_AND_MIGRATE.""" class MigrationState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """State of migration.""" IN_PROGRESS = "InProgress" - """Migration is in progress.""" + """IN_PROGRESS.""" WAITING_FOR_USER_ACTION = "WaitingForUserAction" - """Migration is waiting for user action.""" + """WAITING_FOR_USER_ACTION.""" CANCELED = "Canceled" - """Migration has been canceled.""" + """CANCELED.""" FAILED = "Failed" - """Migration has failed.""" + """FAILED.""" SUCCEEDED = "Succeeded" - """Migration has succeeded.""" + """SUCCEEDED.""" VALIDATION_FAILED = "ValidationFailed" - """Validation for migration has failed.""" + """VALIDATION_FAILED.""" CLEANING_UP = "CleaningUp" - """Migration is cleaning up resources.""" + """CLEANING_UP.""" class MigrationSubstate(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Substate of migration.""" PERFORMING_PRE_REQUISITE_STEPS = "PerformingPreRequisiteSteps" - """Performing pre-requisite steps for migration.""" + """PERFORMING_PRE_REQUISITE_STEPS.""" WAITING_FOR_LOGICAL_REPLICATION_SETUP_REQUEST_ON_SOURCE_DB = "WaitingForLogicalReplicationSetupRequestOnSourceDB" - """Waiting for logical replication setup request on source database.""" + """WAITING_FOR_LOGICAL_REPLICATION_SETUP_REQUEST_ON_SOURCE_DB.""" WAITING_FOR_DBS_TO_MIGRATE_SPECIFICATION = "WaitingForDBsToMigrateSpecification" - """Waiting for databases to migrate specification.""" + """WAITING_FOR_DBS_TO_MIGRATE_SPECIFICATION.""" WAITING_FOR_TARGET_DB_OVERWRITE_CONFIRMATION = "WaitingForTargetDBOverwriteConfirmation" - """Waiting for target database overwrite confirmation.""" + """WAITING_FOR_TARGET_DB_OVERWRITE_CONFIRMATION.""" WAITING_FOR_DATA_MIGRATION_SCHEDULING = "WaitingForDataMigrationScheduling" - """Waiting for data migration scheduling.""" + """WAITING_FOR_DATA_MIGRATION_SCHEDULING.""" WAITING_FOR_DATA_MIGRATION_WINDOW = "WaitingForDataMigrationWindow" - """Waiting for data migration window.""" + """WAITING_FOR_DATA_MIGRATION_WINDOW.""" MIGRATING_DATA = "MigratingData" - """Migrating data.""" + """MIGRATING_DATA.""" WAITING_FOR_CUTOVER_TRIGGER = "WaitingForCutoverTrigger" - """Waiting for cutover trigger.""" + """WAITING_FOR_CUTOVER_TRIGGER.""" COMPLETING_MIGRATION = "CompletingMigration" - """Completing migration.""" + """COMPLETING_MIGRATION.""" COMPLETED = "Completed" - """Migration completed.""" + """COMPLETED.""" CANCELING_REQUESTED_DB_MIGRATIONS = "CancelingRequestedDBMigrations" - """Canceling requested database migrations.""" + """CANCELING_REQUESTED_DB_MIGRATIONS.""" VALIDATION_IN_PROGRESS = "ValidationInProgress" - """Validation in progress.""" + """VALIDATION_IN_PROGRESS.""" + + +class NetworkMigrationState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The state of the network migration operation.""" + + PENDING = "Pending" + """The network migration is pending.""" + IN_PROGRESS = "InProgress" + """The network migration is in progress.""" + SUCCEEDED = "Succeeded" + """The network migration succeeded.""" + FAILED = "Failed" + """The network migration failed.""" + CANCEL_IN_PROGRESS = "CancelInProgress" + """The network migration cancellation is in progress.""" + CANCELLED = "Cancelled" + """The network migration was cancelled.""" class OnlineStorageResizeSupport(str, Enum, metaclass=CaseInsensitiveEnumMeta): @@ -444,21 +439,20 @@ class OnlineStorageResizeSupport(str, Enum, metaclass=CaseInsensitiveEnumMeta): """ ENABLED = "Enabled" - """Resizing the storage without interrupting the operation of the database engine is supported.""" + """ENABLED.""" DISABLED = "Disabled" - """Resizing the storage without interrupting the operation of the database engine is not - supported.""" + """DISABLED.""" class OperationOrigin(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Intended executor of the operation.""" NOT_SPECIFIED = "NotSpecified" - """The origin is not specified.""" + """NOT_SPECIFIED.""" USER = "user" - """The operation is initiated by a user.""" + """USER.""" SYSTEM = "system" - """The operation is initiated by the system.""" + """SYSTEM.""" class OverwriteDatabasesOnTargetServer(str, Enum, metaclass=CaseInsensitiveEnumMeta): @@ -468,39 +462,52 @@ class OverwriteDatabasesOnTargetServer(str, Enum, metaclass=CaseInsensitiveEnumM """ TRUE = "True" - """Databases on the target server can be overwritten when already present.""" + """TRUE.""" FALSE = "False" - """Databases on the target server cannot be overwritten when already present.""" + """FALSE.""" class PasswordBasedAuth(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Indicates if the server supports password based authentication.""" ENABLED = "Enabled" - """Server supports password based authentication.""" + """ENABLED.""" DISABLED = "Disabled" - """Server doesn't support password based authentication.""" + """DISABLED.""" class PostgresMajorVersion(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Major version of PostgreSQL database engine.""" EIGHTEEN = "18" - """PostgreSQL 18.""" + """EIGHTEEN.""" SEVENTEEN = "17" - """PostgreSQL 17.""" + """SEVENTEEN.""" SIXTEEN = "16" - """PostgreSQL 16.""" + """SIXTEEN.""" FIFTEEN = "15" - """PostgreSQL 15.""" + """FIFTEEN.""" FOURTEEN = "14" - """PostgreSQL 14.""" + """FOURTEEN.""" THIRTEEN = "13" - """PostgreSQL 13.""" + """THIRTEEN.""" TWELVE = "12" - """PostgreSQL 12.""" + """TWELVE.""" ELEVEN = "11" - """PostgreSQL 11.""" + """ELEVEN.""" + + +class PostgreSqlFlexibleServerHighAvailabilityMode( # pylint: disable=name-too-long + str, Enum, metaclass=CaseInsensitiveEnumMeta +): + """Modes of high availability supported for this compute.""" + + DISABLED = "Disabled" + """DISABLED.""" + ZONE_REDUNDANT = "ZoneRedundant" + """ZONE_REDUNDANT.""" + SAME_ZONE = "SameZone" + """SAME_ZONE.""" class PrincipalType(str, Enum, metaclass=CaseInsensitiveEnumMeta): @@ -513,24 +520,33 @@ class PrincipalType(str, Enum, metaclass=CaseInsensitiveEnumMeta): GROUP = "Group" """A Microsoft Entra group.""" SERVICE_PRINCIPAL = "ServicePrincipal" - """A Microsoft Entra service principal, typically representing an application or service identity""" + """A Microsoft Entra service principal, typically representing an application or service identity.""" -class PrivateEndpointConnectionProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): +class PrivateEndpointConnectionProvisioningState( # pylint: disable=name-too-long + str, Enum, metaclass=CaseInsensitiveEnumMeta +): """The current provisioning state.""" SUCCEEDED = "Succeeded" + """Connection has been provisioned.""" CREATING = "Creating" + """Connection is being created.""" DELETING = "Deleting" + """Connection is being deleted.""" FAILED = "Failed" + """Connection provisioning has failed.""" class PrivateEndpointServiceConnectionStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The private endpoint connection status.""" PENDING = "Pending" + """Connection waiting for approval or rejection.""" APPROVED = "Approved" + """Connection approved.""" REJECTED = "Rejected" + """Connection Rejected.""" class ReadReplicaPromoteMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): @@ -563,32 +579,43 @@ class RecommendationTypeEnum(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Type for this recommendation.""" CREATE_INDEX = "CreateIndex" + """CREATE_INDEX.""" DROP_INDEX = "DropIndex" + """DROP_INDEX.""" RE_INDEX = "ReIndex" + """RE_INDEX.""" ANALYZE_TABLE = "AnalyzeTable" + """ANALYZE_TABLE.""" + VACUUM_TABLE = "VacuumTable" + """VACUUM_TABLE.""" class RecommendationTypeParameterEnum(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """RecommendationTypeParameterEnum.""" + """Recommendations list filter. Retrieves recommendations based on type.""" CREATE_INDEX = "CreateIndex" + """CREATE_INDEX.""" DROP_INDEX = "DropIndex" + """DROP_INDEX.""" RE_INDEX = "ReIndex" + """RE_INDEX.""" ANALYZE_TABLE = "AnalyzeTable" + """ANALYZE_TABLE.""" + VACUUM_TABLE = "VacuumTable" + """VACUUM_TABLE.""" class ReplicationRole(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Role of the server in a replication set.""" NONE = "None" - """No replication role assigned; the server operates independently.""" + """NONE.""" PRIMARY = "Primary" - """Acts as the source server for replication to one or more replicas.""" + """PRIMARY.""" ASYNC_REPLICA = "AsyncReplica" - """Receives data asynchronously from a primary server within the same region.""" + """ASYNC_REPLICA.""" GEO_ASYNC_REPLICA = "GeoAsyncReplica" - """Receives data asynchronously from a primary server in a different region for geographical - redundancy.""" + """GEO_ASYNC_REPLICA.""" class ReplicationState(str, Enum, metaclass=CaseInsensitiveEnumMeta): @@ -598,78 +625,65 @@ class ReplicationState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """ ACTIVE = "Active" - """Read replica is fully synchronized and actively replicating data from the primary server.""" + """The read replica server is fully synchronized and actively replicating data from the primary + server.""" CATCHUP = "Catchup" - """Read replica is behind the primary server and is currently catching up with pending changes.""" + """The read replica server is behind the primary server and is currently catching up with pending + changes.""" PROVISIONING = "Provisioning" - """Read replica is being created and is in process of getting initialized.""" + """The read replica server is being created and is in process of getting initialized.""" UPDATING = "Updating" - """Read replica is undergoing some changes it can be changing compute size of promoting it to - primary server.""" + """The read replica server is undergoing some changes it can be changing compute size of promoting + it to primary server.""" BROKEN = "Broken" """Replication has failed or been interrupted.""" RECONFIGURING = "Reconfiguring" - """Read replica is being reconfigured, possibly due to changes in source or settings.""" + """The read replica server is being reconfigured, possibly due to changes in source or settings.""" class ServerPublicNetworkAccessState(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Indicates if public network access is enabled or not. This is only supported for servers that - are not integrated into a virtual network which is owned and provided by customer when server - is deployed. - """ + """Indicates if public network access is enabled or not.""" ENABLED = "Enabled" - """Public network access is enabled. This allows the server to be accessed from the public - internet, provided the necessary firewall rule that allows incoming traffic originating from - the connecting client is in place. This is compatible with the use of private endpoints to - connect to this server.""" + """ENABLED.""" DISABLED = "Disabled" - """Public network access is disabled. This means the server cannot be accessed from the public - internet, but only via private endpoints.""" + """DISABLED.""" class ServerState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Possible states of a server.""" READY = "Ready" - """Server is healthy and not undergoing any operations at the management or control plane level. - This doesn't mean that the server is fully operational at the data plane level.""" + """READY.""" DROPPING = "Dropping" - """Server is being deleted.""" + """DROPPING.""" DISABLED = "Disabled" - """Server is disabled. Typical reasons include: the subscription on which the server is deployed - is explicitly disabled or canceled by the administrator, the spending limit has been reached, - or the bill is past due. May also happen when the server is being moved to another resource - group or subscription.""" + """DISABLED.""" STARTING = "Starting" - """PostgreSQL database engine is being restarted.""" + """STARTING.""" STOPPING = "Stopping" - """Compute resources associated with the server are being stopped and deallocated. If the server - has high availability enabled, the compute resources of the standby server are also stopped and - deallocated.""" + """STOPPING.""" STOPPED = "Stopped" - """Compute resources associated with the server are being stopped and deallocated.""" + """STOPPED.""" UPDATING = "Updating" - """Server is undergoing some changes which may or may not impact the availability of the - PostgreSQL database engine. For example, the compute resources of the server are being scaled - up or down, which may cause temporary unavailability of the database engine. Or, for example, a - firewall rule is being added or removed, which doesn't cause any unavailability of the database - engine.""" + """UPDATING.""" RESTARTING = "Restarting" - """PostgreSQL database engine is being restarted.""" + """RESTARTING.""" INACCESSIBLE = "Inaccessible" - """Server isn't accessible, because the key provided to encrypt and decrypt the data is in invalid - state.""" + """INACCESSIBLE.""" PROVISIONING = "Provisioning" - """Server is in the process of being created.""" + """PROVISIONING.""" class SkuTier(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Tier of the compute assigned to a server.""" BURSTABLE = "Burstable" + """BURSTABLE.""" GENERAL_PURPOSE = "GeneralPurpose" + """GENERAL_PURPOSE.""" MEMORY_OPTIMIZED = "MemoryOptimized" + """MEMORY_OPTIMIZED.""" class SourceType(str, Enum, metaclass=CaseInsensitiveEnumMeta): @@ -681,53 +695,53 @@ class SourceType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """ ON_PREMISES = "OnPremises" - """On-premises PostgreSQL server.""" + """ON_PREMISES.""" AWS = "AWS" - """Amazon Web Services PostgreSQL server.""" + """AWS.""" GCP = "GCP" - """Google Cloud Platform PostgreSQL server.""" + """GCP.""" AZURE_VM = "AzureVM" - """Azure Virtual Machine PostgreSQL server.""" + """AZURE_VM.""" POSTGRE_SQL_SINGLE_SERVER = "PostgreSQLSingleServer" - """Azure Database for PostgreSQL single server.""" + """POSTGRE_SQL_SINGLE_SERVER.""" AWS_RDS = "AWS_RDS" - """Amazon RDS for PostgreSQL.""" + """AWS_RDS.""" AWS_AURORA = "AWS_AURORA" - """Amazon Aurora for PostgreSQL.""" + """AWS_AURORA.""" AWS_EC2 = "AWS_EC2" - """Amazon EC2 for PostgreSQL.""" + """AWS_EC2.""" GCP_CLOUD_SQL = "GCP_CloudSQL" - """Google Cloud SQL for PostgreSQL.""" + """GCP_CLOUD_SQL.""" GCP_ALLOY_DB = "GCP_AlloyDB" - """Google Cloud AlloyDB for PostgreSQL.""" + """GCP_ALLOY_DB.""" GCP_COMPUTE = "GCP_Compute" - """Google Compute Engine for PostgreSQL.""" + """GCP_COMPUTE.""" EDB = "EDB" - """EnterpriseDB PostgreSQL server.""" + """EDB.""" EDB_ORACLE_SERVER = "EDB_Oracle_Server" - """EnterpriseDB Oracle Server.""" + """EDB_ORACLE_SERVER.""" EDB_POSTGRE_SQL = "EDB_PostgreSQL" - """EnterpriseDB PostgreSQL server.""" + """EDB_POSTGRE_SQL.""" POSTGRE_SQL_FLEXIBLE_SERVER = "PostgreSQLFlexibleServer" - """Azure Database for PostgreSQL flexible server.""" + """POSTGRE_SQL_FLEXIBLE_SERVER.""" POSTGRE_SQL_COSMOS_DB = "PostgreSQLCosmosDB" - """.NET Cosmos DB for PostgreSQL""" + """POSTGRE_SQL_COSMOS_DB.""" HUAWEI_RDS = "Huawei_RDS" - """Huawei RDS for PostgreSQL""" + """HUAWEI_RDS.""" HUAWEI_COMPUTE = "Huawei_Compute" - """Huawei Compute for PostgreSQL""" + """HUAWEI_COMPUTE.""" HEROKU_POSTGRE_SQL = "Heroku_PostgreSQL" - """Heroku PostgreSQL""" + """HEROKU_POSTGRE_SQL.""" CRUNCHY_POSTGRE_SQL = "Crunchy_PostgreSQL" - """Crunchy PostgreSQL""" + """CRUNCHY_POSTGRE_SQL.""" APSARA_DB_RDS = "ApsaraDB_RDS" - """ApsaraDB RDS for PostgreSQL""" + """APSARA_DB_RDS.""" DIGITAL_OCEAN_DROPLETS = "Digital_Ocean_Droplets" - """Digital Ocean Droplets for PostgreSQL""" + """DIGITAL_OCEAN_DROPLETS.""" DIGITAL_OCEAN_POSTGRE_SQL = "Digital_Ocean_PostgreSQL" - """Digital Ocean PostgreSQL""" + """DIGITAL_OCEAN_POSTGRE_SQL.""" SUPABASE_POSTGRE_SQL = "Supabase_PostgreSQL" - """Supabase PostgreSQL""" + """SUPABASE_POSTGRE_SQL.""" class SslMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): @@ -736,24 +750,22 @@ class SslMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): """ PREFER = "Prefer" - """Prefer SSL connection. If the server does not support SSL, the connection will be established - without SSL.""" + """PREFER.""" REQUIRE = "Require" - """Require SSL connection. If the server does not support SSL, the connection will fail.""" + """REQUIRE.""" VERIFY_CA = "VerifyCA" - """Require SSL connection and verify the server certificate against the CA certificate.""" + """VERIFY_CA.""" VERIFY_FULL = "VerifyFull" - """Require SSL connection, verify the server certificate against the CA certificate, and verify - that the server hostname matches the certificate.""" + """VERIFY_FULL.""" class StartDataMigration(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Indicates if data migration must start right away.""" TRUE = "True" - """Data migration must start right away.""" + """TRUE.""" FALSE = "False" - """Data migration must not start right away.""" + """FALSE.""" class StorageAutoGrow(str, Enum, metaclass=CaseInsensitiveEnumMeta): @@ -762,10 +774,9 @@ class StorageAutoGrow(str, Enum, metaclass=CaseInsensitiveEnumMeta): """ ENABLED = "Enabled" - """Server should automatically grow storage size when available space is nearing zero and - conditions allow for automatically growing storage size.""" + """ENABLED.""" DISABLED = "Disabled" - """Server should not automatically grow storage size when available space is nearing zero.""" + """DISABLED.""" class StorageAutoGrowthSupport(str, Enum, metaclass=CaseInsensitiveEnumMeta): @@ -775,9 +786,9 @@ class StorageAutoGrowthSupport(str, Enum, metaclass=CaseInsensitiveEnumMeta): """ ENABLED = "Enabled" - """Storage autogrow is supported.""" + """ENABLED.""" DISABLED = "Disabled" - """Storage autogrow is not supported.""" + """DISABLED.""" class StorageType(str, Enum, metaclass=CaseInsensitiveEnumMeta): @@ -786,21 +797,18 @@ class StorageType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """ PREMIUM_LRS = "Premium_LRS" - """Standard Solid State Disk (SSD) backed storage offering consistent performance for general - purpose workloads.""" + """PREMIUM_LRS.""" PREMIUM_V2_LRS = "PremiumV2_LRS" - """Next generation Solid State Disk (SSD) storage with improved scalability and performance for - demanding enterprise workloads.""" + """PREMIUM_V2_LRS.""" ULTRA_SSD_LRS = "UltraSSD_LRS" - """High-end Solid State Disk (SSD) storage designed for extreme IOPS and latency-sensitive - applications.""" + """ULTRA_SSD_LRS.""" class ThreatProtectionName(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """ThreatProtectionName.""" + """Type of ThreatProtectionName.""" DEFAULT = "Default" - """Default advanced threat protection settings.""" + """DEFAULT.""" class ThreatProtectionState(str, Enum, metaclass=CaseInsensitiveEnumMeta): @@ -809,46 +817,48 @@ class ThreatProtectionState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """ ENABLED = "Enabled" - """Advanced threat protection is enabled.""" + """ENABLED.""" DISABLED = "Disabled" - """Advanced threat protection is disabled.""" + """DISABLED.""" class TriggerCutover(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Indicates if cutover must be triggered for the entire migration.""" TRUE = "True" - """Cutover must be triggered for the entire migration.""" + """TRUE.""" FALSE = "False" - """Cutover must not be triggered for the entire migration.""" + """FALSE.""" class TuningOptionParameterEnum(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """TuningOptionParameterEnum.""" + """The name of the tuning option.""" INDEX = "index" + """INDEX.""" TABLE = "table" + """TABLE.""" class ValidationState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Validation status for migration.""" FAILED = "Failed" - """Validation has failed.""" + """FAILED.""" SUCCEEDED = "Succeeded" - """Validation has succeeded.""" + """SUCCEEDED.""" WARNING = "Warning" - """Validation has succeeded with warnings.""" + """WARNING.""" class VirtualEndpointType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Type of endpoint for the virtual endpoints.""" READ_WRITE = "ReadWrite" - """Read-write endpoint.""" + """READ_WRITE.""" -class ZoneRedundantHighAvailabilityAndGeographicallyRedundantBackupSupport( +class ZoneRedundantHighAvailabilityAndGeographicallyRedundantBackupSupport( # pylint: disable=name-too-long str, Enum, metaclass=CaseInsensitiveEnumMeta ): """Indicates if high availability with zone redundancy is supported in conjunction with @@ -860,11 +870,9 @@ class ZoneRedundantHighAvailabilityAndGeographicallyRedundantBackupSupport( """ ENABLED = "Enabled" - """High availability with zone redundancy is supported in conjunction with geographically - redundant backups.""" + """ENABLED.""" DISABLED = "Disabled" - """High availability with zone redundancy is not supported in conjunction with geographically - redundant backups.""" + """DISABLED.""" class ZoneRedundantHighAvailabilitySupport(str, Enum, metaclass=CaseInsensitiveEnumMeta): @@ -875,6 +883,6 @@ class ZoneRedundantHighAvailabilitySupport(str, Enum, metaclass=CaseInsensitiveE """ ENABLED = "Enabled" - """High availability with zone redundancy is supported.""" + """ENABLED.""" DISABLED = "Disabled" - """High availability with zone redundancy is not supported.""" + """DISABLED.""" diff --git a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/azure/mgmt/postgresqlflexibleservers/models/_models.py b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/azure/mgmt/postgresqlflexibleservers/models/_models.py new file mode 100644 index 000000000000..aa8006bcd39a --- /dev/null +++ b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/azure/mgmt/postgresqlflexibleservers/models/_models.py @@ -0,0 +1,6193 @@ +# pylint: disable=line-too-long,useless-suppression,too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +# pylint: disable=useless-super-delegation + +import datetime +from typing import Any, Mapping, Optional, TYPE_CHECKING, Union, overload + +from .._utils.model_base import Model as _Model, rest_field + +if TYPE_CHECKING: + from .. import models as _models + + +class AdminCredentials(_Model): + """Credentials of administrator users for source and target servers. + + :ivar source_server_password: Password for the user of the source server. Required. + :vartype source_server_password: str + :ivar target_server_password: Password for the user of the target server. Required. + :vartype target_server_password: str + """ + + source_server_password: str = rest_field(name="sourceServerPassword", visibility=["create", "update"]) + """Password for the user of the source server. Required.""" + target_server_password: str = rest_field(name="targetServerPassword", visibility=["create", "update"]) + """Password for the user of the target server. Required.""" + + @overload + def __init__( + self, + *, + source_server_password: str, + target_server_password: str, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class AdminCredentialsForPatch(_Model): + """Credentials of administrator users for source and target servers. + + :ivar source_server_password: Password for the user of the source server. + :vartype source_server_password: str + :ivar target_server_password: Password for the user of the target server. + :vartype target_server_password: str + """ + + source_server_password: Optional[str] = rest_field(name="sourceServerPassword", visibility=["update"]) + """Password for the user of the source server.""" + target_server_password: Optional[str] = rest_field(name="targetServerPassword", visibility=["update"]) + """Password for the user of the target server.""" + + @overload + def __init__( + self, + *, + source_server_password: Optional[str] = None, + target_server_password: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class Resource(_Model): + """Resource. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.postgresqlflexibleservers.models.SystemData + """ + + id: Optional[str] = rest_field(visibility=["read"]) + """Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}.""" + name: Optional[str] = rest_field(visibility=["read"]) + """The name of the resource.""" + type: Optional[str] = rest_field(visibility=["read"]) + """The type of the resource. E.g. \"Microsoft.Compute/virtualMachines\" or + \"Microsoft.Storage/storageAccounts\".""" + system_data: Optional["_models.SystemData"] = rest_field(name="systemData", visibility=["read"]) + """Azure Resource Manager metadata containing createdBy and modifiedBy information.""" + + +class ProxyResource(Resource): + """Proxy Resource. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.postgresqlflexibleservers.models.SystemData + """ + + +class AdministratorMicrosoftEntra(ProxyResource): + """Server administrator associated to a Microsoft Entra principal. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.postgresqlflexibleservers.models.SystemData + :ivar properties: Properties of a server administrator associated to a Microsoft Entra + principal. Required. + :vartype properties: + ~azure.mgmt.postgresqlflexibleservers.models.AdministratorMicrosoftEntraProperties + """ + + properties: "_models.AdministratorMicrosoftEntraProperties" = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Properties of a server administrator associated to a Microsoft Entra principal. Required.""" + + __flattened_items = ["principal_type", "principal_name", "object_id", "tenant_id"] + + @overload + def __init__( + self, + *, + properties: "_models.AdministratorMicrosoftEntraProperties", + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class AdministratorMicrosoftEntraAdd(_Model): + """Server administrator associated to a Microsoft Entra principal. + + :ivar properties: Properties of the server administrator associated to a Microsoft Entra + principal. + :vartype properties: + ~azure.mgmt.postgresqlflexibleservers.models.AdministratorMicrosoftEntraPropertiesForAdd + """ + + properties: Optional["_models.AdministratorMicrosoftEntraPropertiesForAdd"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Properties of the server administrator associated to a Microsoft Entra principal.""" + + __flattened_items = ["principal_type", "principal_name", "tenant_id"] + + @overload + def __init__( + self, + *, + properties: Optional["_models.AdministratorMicrosoftEntraPropertiesForAdd"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class AdministratorMicrosoftEntraProperties(_Model): + """Properties of a server administrator associated to a Microsoft Entra principal. + + :ivar principal_type: Type of Microsoft Entra principal to which the server administrator is + associated. Known values are: "Unknown", "User", "Group", and "ServicePrincipal". + :vartype principal_type: str or ~azure.mgmt.postgresqlflexibleservers.models.PrincipalType + :ivar principal_name: Name of the Microsoft Entra principal. + :vartype principal_name: str + :ivar object_id: Object identifier of the Microsoft Entra principal. + :vartype object_id: str + :ivar tenant_id: Identifier of the tenant in which the Microsoft Entra principal exists. + :vartype tenant_id: str + """ + + principal_type: Optional[Union[str, "_models.PrincipalType"]] = rest_field( + name="principalType", visibility=["read", "create", "update"] + ) + """Type of Microsoft Entra principal to which the server administrator is associated. Known values + are: \"Unknown\", \"User\", \"Group\", and \"ServicePrincipal\".""" + principal_name: Optional[str] = rest_field(name="principalName", visibility=["read", "create", "update"]) + """Name of the Microsoft Entra principal.""" + object_id: Optional[str] = rest_field(name="objectId", visibility=["read", "create", "update"]) + """Object identifier of the Microsoft Entra principal.""" + tenant_id: Optional[str] = rest_field(name="tenantId", visibility=["read", "create", "update"]) + """Identifier of the tenant in which the Microsoft Entra principal exists.""" + + @overload + def __init__( + self, + *, + principal_type: Optional[Union[str, "_models.PrincipalType"]] = None, + principal_name: Optional[str] = None, + object_id: Optional[str] = None, + tenant_id: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class AdministratorMicrosoftEntraPropertiesForAdd(_Model): # pylint: disable=name-too-long + """Properties of a server administrator associated to a Microsoft Entra principal. + + :ivar principal_type: Type of Microsoft Entra principal to which the server administrator is + associated. Known values are: "Unknown", "User", "Group", and "ServicePrincipal". + :vartype principal_type: str or ~azure.mgmt.postgresqlflexibleservers.models.PrincipalType + :ivar principal_name: Name of the Microsoft Entra principal. + :vartype principal_name: str + :ivar tenant_id: Identifier of the tenant in which the Microsoft Entra principal exists. + :vartype tenant_id: str + """ + + principal_type: Optional[Union[str, "_models.PrincipalType"]] = rest_field( + name="principalType", visibility=["read", "create", "update"] + ) + """Type of Microsoft Entra principal to which the server administrator is associated. Known values + are: \"Unknown\", \"User\", \"Group\", and \"ServicePrincipal\".""" + principal_name: Optional[str] = rest_field(name="principalName", visibility=["read", "create", "update"]) + """Name of the Microsoft Entra principal.""" + tenant_id: Optional[str] = rest_field(name="tenantId", visibility=["create", "update"]) + """Identifier of the tenant in which the Microsoft Entra principal exists.""" + + @overload + def __init__( + self, + *, + principal_type: Optional[Union[str, "_models.PrincipalType"]] = None, + principal_name: Optional[str] = None, + tenant_id: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class AdvancedThreatProtectionSettingsModel(ProxyResource): + """Advanced threat protection settings of the server. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.postgresqlflexibleservers.models.SystemData + :ivar properties: Advanced threat protection properties. + :vartype properties: + ~azure.mgmt.postgresqlflexibleservers.models.AdvancedThreatProtectionSettingsProperties + """ + + properties: Optional["_models.AdvancedThreatProtectionSettingsProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Advanced threat protection properties.""" + + __flattened_items = ["state", "creation_time"] + + @overload + def __init__( + self, + *, + properties: Optional["_models.AdvancedThreatProtectionSettingsProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class AdvancedThreatProtectionSettingsProperties(_Model): # pylint: disable=name-too-long + """Properties of advanced threat protection state for a server. + + :ivar state: Specifies the state of the advanced threat protection, whether it is enabled, + disabled, or a state has not been applied yet on the server. Required. Known values are: + "Enabled" and "Disabled". + :vartype state: str or ~azure.mgmt.postgresqlflexibleservers.models.ThreatProtectionState + :ivar creation_time: Specifies the creation time (UTC) of the policy. + :vartype creation_time: ~datetime.datetime + """ + + state: Union[str, "_models.ThreatProtectionState"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Specifies the state of the advanced threat protection, whether it is enabled, disabled, or a + state has not been applied yet on the server. Required. Known values are: \"Enabled\" and + \"Disabled\".""" + creation_time: Optional[datetime.datetime] = rest_field(name="creationTime", visibility=["read"], format="rfc3339") + """Specifies the creation time (UTC) of the policy.""" + + @overload + def __init__( + self, + *, + state: Union[str, "_models.ThreatProtectionState"], + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class AuthConfig(_Model): + """Authentication configuration properties of a server. + + :ivar active_directory_auth: Indicates if the server supports Microsoft Entra authentication. + Known values are: "Enabled" and "Disabled". + :vartype active_directory_auth: str or + ~azure.mgmt.postgresqlflexibleservers.models.MicrosoftEntraAuth + :ivar password_auth: Indicates if the server supports password based authentication. Known + values are: "Enabled" and "Disabled". + :vartype password_auth: str or ~azure.mgmt.postgresqlflexibleservers.models.PasswordBasedAuth + :ivar tenant_id: Identifier of the tenant of the delegated resource. + :vartype tenant_id: str + """ + + active_directory_auth: Optional[Union[str, "_models.MicrosoftEntraAuth"]] = rest_field( + name="activeDirectoryAuth", visibility=["read", "create", "update", "delete", "query"] + ) + """Indicates if the server supports Microsoft Entra authentication. Known values are: \"Enabled\" + and \"Disabled\".""" + password_auth: Optional[Union[str, "_models.PasswordBasedAuth"]] = rest_field( + name="passwordAuth", visibility=["read", "create", "update", "delete", "query"] + ) + """Indicates if the server supports password based authentication. Known values are: \"Enabled\" + and \"Disabled\".""" + tenant_id: Optional[str] = rest_field(name="tenantId", visibility=["read", "create", "update", "delete", "query"]) + """Identifier of the tenant of the delegated resource.""" + + @overload + def __init__( + self, + *, + active_directory_auth: Optional[Union[str, "_models.MicrosoftEntraAuth"]] = None, + password_auth: Optional[Union[str, "_models.PasswordBasedAuth"]] = None, + tenant_id: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class AuthConfigForPatch(_Model): + """Authentication configuration properties of a server. + + :ivar active_directory_auth: Indicates if the server supports Microsoft Entra authentication. + Known values are: "Enabled" and "Disabled". + :vartype active_directory_auth: str or + ~azure.mgmt.postgresqlflexibleservers.models.MicrosoftEntraAuth + :ivar password_auth: Indicates if the server supports password based authentication. Known + values are: "Enabled" and "Disabled". + :vartype password_auth: str or ~azure.mgmt.postgresqlflexibleservers.models.PasswordBasedAuth + :ivar tenant_id: Identifier of the tenant of the delegated resource. + :vartype tenant_id: str + """ + + active_directory_auth: Optional[Union[str, "_models.MicrosoftEntraAuth"]] = rest_field( + name="activeDirectoryAuth", visibility=["read", "create", "update", "delete", "query"] + ) + """Indicates if the server supports Microsoft Entra authentication. Known values are: \"Enabled\" + and \"Disabled\".""" + password_auth: Optional[Union[str, "_models.PasswordBasedAuth"]] = rest_field( + name="passwordAuth", visibility=["read", "create", "update", "delete", "query"] + ) + """Indicates if the server supports password based authentication. Known values are: \"Enabled\" + and \"Disabled\".""" + tenant_id: Optional[str] = rest_field(name="tenantId", visibility=["read", "create", "update", "delete", "query"]) + """Identifier of the tenant of the delegated resource.""" + + @overload + def __init__( + self, + *, + active_directory_auth: Optional[Union[str, "_models.MicrosoftEntraAuth"]] = None, + password_auth: Optional[Union[str, "_models.PasswordBasedAuth"]] = None, + tenant_id: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class Backup(_Model): + """Backup properties of a server. + + :ivar backup_retention_days: Backup retention days for the server. + :vartype backup_retention_days: int + :ivar geo_redundant_backup: Indicates if the server is configured to create geographically + redundant backups. Known values are: "Enabled" and "Disabled". + :vartype geo_redundant_backup: str or + ~azure.mgmt.postgresqlflexibleservers.models.GeographicallyRedundantBackup + :ivar earliest_restore_date: Earliest restore point time (ISO8601 format) for a server. + :vartype earliest_restore_date: ~datetime.datetime + """ + + backup_retention_days: Optional[int] = rest_field( + name="backupRetentionDays", visibility=["read", "create", "update", "delete", "query"] + ) + """Backup retention days for the server.""" + geo_redundant_backup: Optional[Union[str, "_models.GeographicallyRedundantBackup"]] = rest_field( + name="geoRedundantBackup", visibility=["read", "create"] + ) + """Indicates if the server is configured to create geographically redundant backups. Known values + are: \"Enabled\" and \"Disabled\".""" + earliest_restore_date: Optional[datetime.datetime] = rest_field( + name="earliestRestoreDate", visibility=["read"], format="rfc3339" + ) + """Earliest restore point time (ISO8601 format) for a server.""" + + @overload + def __init__( + self, + *, + backup_retention_days: Optional[int] = None, + geo_redundant_backup: Optional[Union[str, "_models.GeographicallyRedundantBackup"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class BackupAutomaticAndOnDemand(ProxyResource): + """Properties of a backup. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.postgresqlflexibleservers.models.SystemData + :ivar properties: Properties of a backup. + :vartype properties: + ~azure.mgmt.postgresqlflexibleservers.models.BackupAutomaticAndOnDemandProperties + """ + + properties: Optional["_models.BackupAutomaticAndOnDemandProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Properties of a backup.""" + + __flattened_items = ["backup_type", "completed_time", "source"] + + @overload + def __init__( + self, + *, + properties: Optional["_models.BackupAutomaticAndOnDemandProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class BackupAutomaticAndOnDemandProperties(_Model): + """Properties of a backup. + + :ivar backup_type: Type of backup. Known values are: "Full" and "Customer On-Demand". + :vartype backup_type: str or ~azure.mgmt.postgresqlflexibleservers.models.BackupType + :ivar completed_time: Time(ISO8601 format) at which the backup was completed. + :vartype completed_time: ~datetime.datetime + :ivar source: Source of the backup. + :vartype source: str + """ + + backup_type: Optional[Union[str, "_models.BackupType"]] = rest_field( + name="backupType", visibility=["read", "create", "update", "delete", "query"] + ) + """Type of backup. Known values are: \"Full\" and \"Customer On-Demand\".""" + completed_time: Optional[datetime.datetime] = rest_field( + name="completedTime", visibility=["read", "create", "update", "delete", "query"], format="rfc3339" + ) + """Time(ISO8601 format) at which the backup was completed.""" + source: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Source of the backup.""" + + @overload + def __init__( + self, + *, + backup_type: Optional[Union[str, "_models.BackupType"]] = None, + completed_time: Optional[datetime.datetime] = None, + source: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class BackupForPatch(_Model): + """Backup properties of a server. + + :ivar backup_retention_days: Backup retention days for the server. + :vartype backup_retention_days: int + :ivar geo_redundant_backup: Indicates if the server is configured to create geographically + redundant backups. Known values are: "Enabled" and "Disabled". + :vartype geo_redundant_backup: str or + ~azure.mgmt.postgresqlflexibleservers.models.GeographicallyRedundantBackup + :ivar earliest_restore_date: Earliest restore point time (ISO8601 format) for a server. + :vartype earliest_restore_date: ~datetime.datetime + """ + + backup_retention_days: Optional[int] = rest_field( + name="backupRetentionDays", visibility=["read", "create", "update", "delete", "query"] + ) + """Backup retention days for the server.""" + geo_redundant_backup: Optional[Union[str, "_models.GeographicallyRedundantBackup"]] = rest_field( + name="geoRedundantBackup", visibility=["read"] + ) + """Indicates if the server is configured to create geographically redundant backups. Known values + are: \"Enabled\" and \"Disabled\".""" + earliest_restore_date: Optional[datetime.datetime] = rest_field( + name="earliestRestoreDate", visibility=["read"], format="rfc3339" + ) + """Earliest restore point time (ISO8601 format) for a server.""" + + @overload + def __init__( + self, + *, + backup_retention_days: Optional[int] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class BackupRequestBase(_Model): + """BackupRequestBase is the base for all backup request. + + :ivar backup_settings: Backup Settings. Required. + :vartype backup_settings: ~azure.mgmt.postgresqlflexibleservers.models.BackupSettings + """ + + backup_settings: "_models.BackupSettings" = rest_field( + name="backupSettings", visibility=["read", "create", "update", "delete", "query"] + ) + """Backup Settings. Required.""" + + @overload + def __init__( + self, + *, + backup_settings: "_models.BackupSettings", + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class BackupSettings(_Model): + """The settings for the long term backup. + + :ivar backup_name: Backup Name for the current backup. Required. + :vartype backup_name: str + """ + + backup_name: str = rest_field(name="backupName", visibility=["read", "create", "update", "delete", "query"]) + """Backup Name for the current backup. Required.""" + + @overload + def __init__( + self, + *, + backup_name: str, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class BackupsLongTermRetentionOperation(ProxyResource): + """Response for the LTR backup Operation API call. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.postgresqlflexibleservers.models.SystemData + :ivar properties: Long Term Retention Backup Operation Resource Properties. + :vartype properties: + ~azure.mgmt.postgresqlflexibleservers.models.LtrBackupOperationResponseProperties + """ + + properties: Optional["_models.LtrBackupOperationResponseProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Long Term Retention Backup Operation Resource Properties.""" + + __flattened_items = [ + "datasource_size_in_bytes", + "data_transferred_in_bytes", + "backup_name", + "backup_metadata", + "status", + "start_time", + "end_time", + "percent_complete", + "error_code", + "error_message", + ] + + @overload + def __init__( + self, + *, + properties: Optional["_models.LtrBackupOperationResponseProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class BackupsLongTermRetentionRequest(BackupRequestBase): + """The request that is made for a long term retention backup. + + :ivar backup_settings: Backup Settings. Required. + :vartype backup_settings: ~azure.mgmt.postgresqlflexibleservers.models.BackupSettings + :ivar target_details: Backup store detail for target server. Required. + :vartype target_details: ~azure.mgmt.postgresqlflexibleservers.models.BackupStoreDetails + """ + + target_details: "_models.BackupStoreDetails" = rest_field( + name="targetDetails", visibility=["read", "create", "update", "delete", "query"] + ) + """Backup store detail for target server. Required.""" + + @overload + def __init__( + self, + *, + backup_settings: "_models.BackupSettings", + target_details: "_models.BackupStoreDetails", + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class BackupsLongTermRetentionResponse(_Model): + """Response for the LTR backup API call. + + :ivar properties: Long Term Retention Backup Operation Resource Properties. + :vartype properties: + ~azure.mgmt.postgresqlflexibleservers.models.LtrBackupOperationResponseProperties + """ + + properties: Optional["_models.LtrBackupOperationResponseProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Long Term Retention Backup Operation Resource Properties.""" + + __flattened_items = [ + "datasource_size_in_bytes", + "data_transferred_in_bytes", + "backup_name", + "backup_metadata", + "status", + "start_time", + "end_time", + "percent_complete", + "error_code", + "error_message", + ] + + @overload + def __init__( + self, + *, + properties: Optional["_models.LtrBackupOperationResponseProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class BackupsLongTermRetentionResponseProperties(_Model): # pylint: disable=name-too-long + """Response for the pre-backup request. + + :ivar number_of_containers: Number of storage containers the plugin will use during backup. + More than one containers may be used for size limitations, parallelism, or redundancy etc. + Required. + :vartype number_of_containers: int + """ + + number_of_containers: int = rest_field( + name="numberOfContainers", visibility=["read", "create", "update", "delete", "query"] + ) + """Number of storage containers the plugin will use during backup. More than one containers may be + used for size limitations, parallelism, or redundancy etc. Required.""" + + @overload + def __init__( + self, + *, + number_of_containers: int, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class BackupStoreDetails(_Model): + """Details about the target where the backup content will be stored. + + :ivar sas_uri_list: List of SAS uri of storage containers where backup data is to be + streamed/copied. Required. + :vartype sas_uri_list: list[str] + """ + + sas_uri_list: list[str] = rest_field(name="sasUriList", visibility=["read", "create", "update", "delete", "query"]) + """List of SAS uri of storage containers where backup data is to be streamed/copied. Required.""" + + @overload + def __init__( + self, + *, + sas_uri_list: list[str], + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class CapabilityBase(_Model): + """Base object for representing capability. + + :ivar status: The status of the capability. Known values are: "Visible", "Available", + "Default", and "Disabled". + :vartype status: str or ~azure.mgmt.postgresqlflexibleservers.models.CapabilityStatus + :ivar reason: The reason for the capability not being available. + :vartype reason: str + """ + + status: Optional[Union[str, "_models.CapabilityStatus"]] = rest_field(visibility=["read"]) + """The status of the capability. Known values are: \"Visible\", \"Available\", \"Default\", and + \"Disabled\".""" + reason: Optional[str] = rest_field(visibility=["read"]) + """The reason for the capability not being available.""" + + +class Capability(CapabilityBase): + """Capability for the Azure Database for PostgreSQL flexible server. + + :ivar status: The status of the capability. Known values are: "Visible", "Available", + "Default", and "Disabled". + :vartype status: str or ~azure.mgmt.postgresqlflexibleservers.models.CapabilityStatus + :ivar reason: The reason for the capability not being available. + :vartype reason: str + :ivar name: Name of flexible servers capabilities. + :vartype name: str + :ivar supported_server_editions: List of supported compute tiers. + :vartype supported_server_editions: + list[~azure.mgmt.postgresqlflexibleservers.models.ServerEditionCapability] + :ivar supported_server_versions: List of supported major versions of PostgreSQL database + engine. + :vartype supported_server_versions: + list[~azure.mgmt.postgresqlflexibleservers.models.ServerVersionCapability] + :ivar supported_features: Features supported. + :vartype supported_features: + list[~azure.mgmt.postgresqlflexibleservers.models.SupportedFeature] + :ivar fast_provisioning_supported: Indicates if fast provisioning is supported. 'Enabled' means + fast provisioning is supported. 'Disabled' stands for fast provisioning is not supported. Will + be deprecated in the future. Look to Supported Features for 'FastProvisioning'. Known values + are: "Enabled" and "Disabled". + :vartype fast_provisioning_supported: str or + ~azure.mgmt.postgresqlflexibleservers.models.FastProvisioningSupport + :ivar supported_fast_provisioning_editions: List of compute tiers supporting fast provisioning. + :vartype supported_fast_provisioning_editions: + list[~azure.mgmt.postgresqlflexibleservers.models.FastProvisioningEditionCapability] + :ivar geo_backup_supported: Indicates if geographically redundant backups are supported in this + location. 'Enabled' means geographically redundant backups are supported. 'Disabled' stands for + geographically redundant backup is not supported. Will be deprecated in the future. Look to + Supported Features for 'GeoBackup'. Known values are: "Enabled" and "Disabled". + :vartype geo_backup_supported: str or + ~azure.mgmt.postgresqlflexibleservers.models.GeographicallyRedundantBackupSupport + :ivar zone_redundant_ha_supported: Indicates if high availability with zone redundancy is + supported in this location. 'Enabled' means high availability with zone redundancy is + supported. 'Disabled' stands for high availability with zone redundancy is not supported. Will + be deprecated in the future. Look to Supported Features for 'ZoneRedundantHa'. Known values + are: "Enabled" and "Disabled". + :vartype zone_redundant_ha_supported: str or + ~azure.mgmt.postgresqlflexibleservers.models.ZoneRedundantHighAvailabilitySupport + :ivar zone_redundant_ha_and_geo_backup_supported: Indicates if high availability with zone + redundancy is supported in conjunction with geographically redundant backups in this location. + 'Enabled' means high availability with zone redundancy is supported in conjunction with + geographically redundant backups is supported. 'Disabled' stands for high availability with + zone redundancy is supported in conjunction with geographically redundant backups is not + supported. Will be deprecated in the future. Look to Supported Features for + 'ZoneRedundantHaAndGeoBackup'. Known values are: "Enabled" and "Disabled". + :vartype zone_redundant_ha_and_geo_backup_supported: str or + ~azure.mgmt.postgresqlflexibleservers.models.ZoneRedundantHighAvailabilityAndGeographicallyRedundantBackupSupport + :ivar storage_auto_growth_supported: Indicates if storage autogrow is supported in this + location. 'Enabled' means storage autogrow is supported. 'Disabled' stands for storage autogrow + is not supported. Will be deprecated in the future. Look to Supported Features for + 'StorageAutoGrowth'. Known values are: "Enabled" and "Disabled". + :vartype storage_auto_growth_supported: str or + ~azure.mgmt.postgresqlflexibleservers.models.StorageAutoGrowthSupport + :ivar online_resize_supported: Indicates if resizing the storage, without interrupting the + operation of the database engine, is supported in this location for the given subscription. + 'Enabled' means resizing the storage without interrupting the operation of the database engine + is supported. 'Disabled' means resizing the storage without interrupting the operation of the + database engine is not supported. Will be deprecated in the future. Look to Supported Features + for 'OnlineResize'. Known values are: "Enabled" and "Disabled". + :vartype online_resize_supported: str or + ~azure.mgmt.postgresqlflexibleservers.models.OnlineStorageResizeSupport + :ivar restricted: Indicates if this location is restricted. 'Enabled' means location is + restricted. 'Disabled' stands for location is not restricted. Will be deprecated in the future. + Look to Supported Features for 'Restricted'. Known values are: "Enabled" and "Disabled". + :vartype restricted: str or ~azure.mgmt.postgresqlflexibleservers.models.LocationRestricted + """ + + name: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Name of flexible servers capabilities.""" + supported_server_editions: Optional[list["_models.ServerEditionCapability"]] = rest_field( + name="supportedServerEditions", visibility=["read"] + ) + """List of supported compute tiers.""" + supported_server_versions: Optional[list["_models.ServerVersionCapability"]] = rest_field( + name="supportedServerVersions", visibility=["read"] + ) + """List of supported major versions of PostgreSQL database engine.""" + supported_features: Optional[list["_models.SupportedFeature"]] = rest_field( + name="supportedFeatures", visibility=["read"] + ) + """Features supported.""" + fast_provisioning_supported: Optional[Union[str, "_models.FastProvisioningSupport"]] = rest_field( + name="fastProvisioningSupported", visibility=["read"] + ) + """Indicates if fast provisioning is supported. 'Enabled' means fast provisioning is supported. + 'Disabled' stands for fast provisioning is not supported. Will be deprecated in the future. + Look to Supported Features for 'FastProvisioning'. Known values are: \"Enabled\" and + \"Disabled\".""" + supported_fast_provisioning_editions: Optional[list["_models.FastProvisioningEditionCapability"]] = rest_field( + name="supportedFastProvisioningEditions", visibility=["read"] + ) + """List of compute tiers supporting fast provisioning.""" + geo_backup_supported: Optional[Union[str, "_models.GeographicallyRedundantBackupSupport"]] = rest_field( + name="geoBackupSupported", visibility=["read"] + ) + """Indicates if geographically redundant backups are supported in this location. 'Enabled' means + geographically redundant backups are supported. 'Disabled' stands for geographically redundant + backup is not supported. Will be deprecated in the future. Look to Supported Features for + 'GeoBackup'. Known values are: \"Enabled\" and \"Disabled\".""" + zone_redundant_ha_supported: Optional[Union[str, "_models.ZoneRedundantHighAvailabilitySupport"]] = rest_field( + name="zoneRedundantHaSupported", visibility=["read"] + ) + """Indicates if high availability with zone redundancy is supported in this location. 'Enabled' + means high availability with zone redundancy is supported. 'Disabled' stands for high + availability with zone redundancy is not supported. Will be deprecated in the future. Look to + Supported Features for 'ZoneRedundantHa'. Known values are: \"Enabled\" and \"Disabled\".""" + zone_redundant_ha_and_geo_backup_supported: Optional[ + Union[str, "_models.ZoneRedundantHighAvailabilityAndGeographicallyRedundantBackupSupport"] + ] = rest_field(name="zoneRedundantHaAndGeoBackupSupported", visibility=["read"]) + """Indicates if high availability with zone redundancy is supported in conjunction with + geographically redundant backups in this location. 'Enabled' means high availability with zone + redundancy is supported in conjunction with geographically redundant backups is supported. + 'Disabled' stands for high availability with zone redundancy is supported in conjunction with + geographically redundant backups is not supported. Will be deprecated in the future. Look to + Supported Features for 'ZoneRedundantHaAndGeoBackup'. Known values are: \"Enabled\" and + \"Disabled\".""" + storage_auto_growth_supported: Optional[Union[str, "_models.StorageAutoGrowthSupport"]] = rest_field( + name="storageAutoGrowthSupported", visibility=["read"] + ) + """Indicates if storage autogrow is supported in this location. 'Enabled' means storage autogrow + is supported. 'Disabled' stands for storage autogrow is not supported. Will be deprecated in + the future. Look to Supported Features for 'StorageAutoGrowth'. Known values are: \"Enabled\" + and \"Disabled\".""" + online_resize_supported: Optional[Union[str, "_models.OnlineStorageResizeSupport"]] = rest_field( + name="onlineResizeSupported", visibility=["read"] + ) + """Indicates if resizing the storage, without interrupting the operation of the database engine, + is supported in this location for the given subscription. 'Enabled' means resizing the storage + without interrupting the operation of the database engine is supported. 'Disabled' means + resizing the storage without interrupting the operation of the database engine is not + supported. Will be deprecated in the future. Look to Supported Features for 'OnlineResize'. + Known values are: \"Enabled\" and \"Disabled\".""" + restricted: Optional[Union[str, "_models.LocationRestricted"]] = rest_field(visibility=["read"]) + """Indicates if this location is restricted. 'Enabled' means location is restricted. 'Disabled' + stands for location is not restricted. Will be deprecated in the future. Look to Supported + Features for 'Restricted'. Known values are: \"Enabled\" and \"Disabled\".""" + + @overload + def __init__( + self, + *, + name: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class CapturedLog(ProxyResource): + """Log file. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.postgresqlflexibleservers.models.SystemData + :ivar properties: Properties of a log file. + :vartype properties: ~azure.mgmt.postgresqlflexibleservers.models.CapturedLogProperties + """ + + properties: Optional["_models.CapturedLogProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Properties of a log file.""" + + __flattened_items = ["created_time", "last_modified_time", "size_in_kb", "type", "url"] + + @overload + def __init__( + self, + *, + properties: Optional["_models.CapturedLogProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class CapturedLogProperties(_Model): + """Properties of a log file. + + :ivar created_time: Creation timestamp of the log file. + :vartype created_time: ~datetime.datetime + :ivar last_modified_time: Last modified timestamp of the log file. + :vartype last_modified_time: ~datetime.datetime + :ivar size_in_kb: Size (in KB) of the log file. + :vartype size_in_kb: int + :ivar type: Type of log file. Can be 'ServerLogs' or 'UpgradeLogs'. + :vartype type: str + :ivar url: URL to download the log file from. + :vartype url: str + """ + + created_time: Optional[datetime.datetime] = rest_field( + name="createdTime", visibility=["read", "create", "update", "delete", "query"], format="rfc3339" + ) + """Creation timestamp of the log file.""" + last_modified_time: Optional[datetime.datetime] = rest_field( + name="lastModifiedTime", visibility=["read", "create", "update", "delete", "query"], format="rfc3339" + ) + """Last modified timestamp of the log file.""" + size_in_kb: Optional[int] = rest_field(name="sizeInKb", visibility=["read", "create", "update", "delete", "query"]) + """Size (in KB) of the log file.""" + type: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Type of log file. Can be 'ServerLogs' or 'UpgradeLogs'.""" + url: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """URL to download the log file from.""" + + @overload + def __init__( + self, + *, + created_time: Optional[datetime.datetime] = None, + last_modified_time: Optional[datetime.datetime] = None, + size_in_kb: Optional[int] = None, + type: Optional[str] = None, + url: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class CheckNameAvailabilityRequest(_Model): + """The check availability request body. + + :ivar name: The name of the resource for which availability needs to be checked. + :vartype name: str + :ivar type: The resource type. + :vartype type: str + """ + + name: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The name of the resource for which availability needs to be checked.""" + type: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The resource type.""" + + @overload + def __init__( + self, + *, + name: Optional[str] = None, + type: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class CheckNameAvailabilityResponse(_Model): + """The check availability result. + + :ivar name_available: Indicates if the resource name is available. + :vartype name_available: bool + :ivar reason: The reason why the given name is not available. Known values are: "Invalid" and + "AlreadyExists". + :vartype reason: str or + ~azure.mgmt.postgresqlflexibleservers.models.CheckNameAvailabilityReason + :ivar message: Detailed reason why the given name is not available. + :vartype message: str + """ + + name_available: Optional[bool] = rest_field( + name="nameAvailable", visibility=["read", "create", "update", "delete", "query"] + ) + """Indicates if the resource name is available.""" + reason: Optional[Union[str, "_models.CheckNameAvailabilityReason"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The reason why the given name is not available. Known values are: \"Invalid\" and + \"AlreadyExists\".""" + message: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Detailed reason why the given name is not available.""" + + @overload + def __init__( + self, + *, + name_available: Optional[bool] = None, + reason: Optional[Union[str, "_models.CheckNameAvailabilityReason"]] = None, + message: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class Cluster(_Model): + """Cluster properties of a server. + + :ivar cluster_size: Number of nodes assigned to the elastic cluster. + :vartype cluster_size: int + :ivar default_database_name: Default database name for the elastic cluster. + :vartype default_database_name: str + """ + + cluster_size: Optional[int] = rest_field( + name="clusterSize", visibility=["read", "create", "update", "delete", "query"] + ) + """Number of nodes assigned to the elastic cluster.""" + default_database_name: Optional[str] = rest_field( + name="defaultDatabaseName", visibility=["read", "create", "update", "delete", "query"] + ) + """Default database name for the elastic cluster.""" + + @overload + def __init__( + self, + *, + cluster_size: Optional[int] = None, + default_database_name: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class Configuration(ProxyResource): + """Configuration (also known as server parameter). + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.postgresqlflexibleservers.models.SystemData + :ivar properties: Properties of a configuration (also known as server parameter). + :vartype properties: ~azure.mgmt.postgresqlflexibleservers.models.ConfigurationProperties + """ + + properties: Optional["_models.ConfigurationProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Properties of a configuration (also known as server parameter).""" + + __flattened_items = [ + "value", + "description", + "default_value", + "data_type", + "allowed_values", + "source", + "is_dynamic_config", + "is_read_only", + "is_config_pending_restart", + "unit", + "documentation_link", + ] + + @overload + def __init__( + self, + *, + properties: Optional["_models.ConfigurationProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class ConfigurationForUpdate(_Model): + """Configuration (also known as server parameter). + + :ivar properties: Properties of a configuration (also known as server parameter). + :vartype properties: ~azure.mgmt.postgresqlflexibleservers.models.ConfigurationProperties + """ + + properties: Optional["_models.ConfigurationProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Properties of a configuration (also known as server parameter).""" + + __flattened_items = [ + "value", + "description", + "default_value", + "data_type", + "allowed_values", + "source", + "is_dynamic_config", + "is_read_only", + "is_config_pending_restart", + "unit", + "documentation_link", + ] + + @overload + def __init__( + self, + *, + properties: Optional["_models.ConfigurationProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class ConfigurationProperties(_Model): + """Properties of a configuration (also known as server parameter). + + :ivar value: Value of the configuration (also known as server parameter). Required to update + the value assigned to a specific modifiable configuration. + :vartype value: str + :ivar description: Description of the configuration (also known as server parameter). + :vartype description: str + :ivar default_value: Value assigned by default to the configuration (also known as server + parameter). + :vartype default_value: str + :ivar data_type: Data type of the configuration (also known as server parameter). Known values + are: "Boolean", "Numeric", "Integer", "Enumeration", "String", and "Set". + :vartype data_type: str or ~azure.mgmt.postgresqlflexibleservers.models.ConfigurationDataType + :ivar allowed_values: Allowed values of the configuration (also known as server parameter). + :vartype allowed_values: str + :ivar source: Source of the value assigned to the configuration (also known as server + parameter). Required to update the value assigned to a specific modifiable configuration. + :vartype source: str + :ivar is_dynamic_config: Indicates if it's a dynamic (true) or static (false) configuration + (also known as server parameter). Static server parameters require a server restart after + changing the value assigned to them, for the change to take effect. Dynamic server parameters + do not require a server restart after changing the value assigned to them, for the change to + take effect. + :vartype is_dynamic_config: bool + :ivar is_read_only: Indicates if it's a read-only (true) or modifiable (false) configuration + (also known as server parameter). + :vartype is_read_only: bool + :ivar is_config_pending_restart: Indicates if the value assigned to the configuration (also + known as server parameter) is pending a server restart for it to take effect. + :vartype is_config_pending_restart: bool + :ivar unit: Units in which the configuration (also known as server parameter) value is + expressed. + :vartype unit: str + :ivar documentation_link: Link pointing to the documentation of the configuration (also known + as server parameter). + :vartype documentation_link: str + """ + + value: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Value of the configuration (also known as server parameter). Required to update the value + assigned to a specific modifiable configuration.""" + description: Optional[str] = rest_field(visibility=["read"]) + """Description of the configuration (also known as server parameter).""" + default_value: Optional[str] = rest_field(name="defaultValue", visibility=["read"]) + """Value assigned by default to the configuration (also known as server parameter).""" + data_type: Optional[Union[str, "_models.ConfigurationDataType"]] = rest_field(name="dataType", visibility=["read"]) + """Data type of the configuration (also known as server parameter). Known values are: \"Boolean\", + \"Numeric\", \"Integer\", \"Enumeration\", \"String\", and \"Set\".""" + allowed_values: Optional[str] = rest_field(name="allowedValues", visibility=["read"]) + """Allowed values of the configuration (also known as server parameter).""" + source: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Source of the value assigned to the configuration (also known as server parameter). Required to + update the value assigned to a specific modifiable configuration.""" + is_dynamic_config: Optional[bool] = rest_field(name="isDynamicConfig", visibility=["read"]) + """Indicates if it's a dynamic (true) or static (false) configuration (also known as server + parameter). Static server parameters require a server restart after changing the value assigned + to them, for the change to take effect. Dynamic server parameters do not require a server + restart after changing the value assigned to them, for the change to take effect.""" + is_read_only: Optional[bool] = rest_field(name="isReadOnly", visibility=["read"]) + """Indicates if it's a read-only (true) or modifiable (false) configuration (also known as server + parameter).""" + is_config_pending_restart: Optional[bool] = rest_field(name="isConfigPendingRestart", visibility=["read"]) + """Indicates if the value assigned to the configuration (also known as server parameter) is + pending a server restart for it to take effect.""" + unit: Optional[str] = rest_field(visibility=["read"]) + """Units in which the configuration (also known as server parameter) value is expressed.""" + documentation_link: Optional[str] = rest_field(name="documentationLink", visibility=["read"]) + """Link pointing to the documentation of the configuration (also known as server parameter).""" + + @overload + def __init__( + self, + *, + value: Optional[str] = None, + source: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class Database(ProxyResource): + """Represents a database. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.postgresqlflexibleservers.models.SystemData + :ivar properties: Properties of a database. + :vartype properties: ~azure.mgmt.postgresqlflexibleservers.models.DatabaseProperties + """ + + properties: Optional["_models.DatabaseProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Properties of a database.""" + + __flattened_items = ["charset", "collation"] + + @overload + def __init__( + self, + *, + properties: Optional["_models.DatabaseProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class DatabaseMigrationState(_Model): + """Migration state of a database. + + :ivar database_name: Name of database. + :vartype database_name: str + :ivar migration_state: Migration state of a database. Known values are: "InProgress", + "WaitingForCutoverTrigger", "Failed", "Canceled", "Succeeded", and "Canceling". + :vartype migration_state: str or + ~azure.mgmt.postgresqlflexibleservers.models.MigrationDatabaseState + :ivar migration_operation: Migration operation of a database. + :vartype migration_operation: str + :ivar started_on: Start time of a migration state. + :vartype started_on: ~datetime.datetime + :ivar ended_on: End time of a migration state. + :vartype ended_on: ~datetime.datetime + :ivar full_load_queued_tables: Number of tables queued for the migration of a database. + :vartype full_load_queued_tables: int + :ivar full_load_errored_tables: Number of tables encountering errors during the migration of a + database. + :vartype full_load_errored_tables: int + :ivar full_load_loading_tables: Number of tables loading during the migration of a database. + :vartype full_load_loading_tables: int + :ivar full_load_completed_tables: Number of tables loaded during the migration of a database. + :vartype full_load_completed_tables: int + :ivar cdc_update_counter: Change Data Capture update counter. + :vartype cdc_update_counter: int + :ivar cdc_delete_counter: Change Data Capture delete counter. + :vartype cdc_delete_counter: int + :ivar cdc_insert_counter: Change Data Capture insert counter. + :vartype cdc_insert_counter: int + :ivar applied_changes: Change Data Capture applied changes counter. + :vartype applied_changes: int + :ivar incoming_changes: Change Data Capture incoming changes counter. + :vartype incoming_changes: int + :ivar latency: Lag in seconds between source and target during online phase. + :vartype latency: int + :ivar message: Error message, if any, for the migration state. + :vartype message: str + """ + + database_name: Optional[str] = rest_field( + name="databaseName", visibility=["read", "create", "update", "delete", "query"] + ) + """Name of database.""" + migration_state: Optional[Union[str, "_models.MigrationDatabaseState"]] = rest_field( + name="migrationState", visibility=["read", "create", "update", "delete", "query"] + ) + """Migration state of a database. Known values are: \"InProgress\", \"WaitingForCutoverTrigger\", + \"Failed\", \"Canceled\", \"Succeeded\", and \"Canceling\".""" + migration_operation: Optional[str] = rest_field( + name="migrationOperation", visibility=["read", "create", "update", "delete", "query"] + ) + """Migration operation of a database.""" + started_on: Optional[datetime.datetime] = rest_field( + name="startedOn", visibility=["read", "create", "update", "delete", "query"], format="rfc3339" + ) + """Start time of a migration state.""" + ended_on: Optional[datetime.datetime] = rest_field( + name="endedOn", visibility=["read", "create", "update", "delete", "query"], format="rfc3339" + ) + """End time of a migration state.""" + full_load_queued_tables: Optional[int] = rest_field( + name="fullLoadQueuedTables", visibility=["read", "create", "update", "delete", "query"] + ) + """Number of tables queued for the migration of a database.""" + full_load_errored_tables: Optional[int] = rest_field( + name="fullLoadErroredTables", visibility=["read", "create", "update", "delete", "query"] + ) + """Number of tables encountering errors during the migration of a database.""" + full_load_loading_tables: Optional[int] = rest_field( + name="fullLoadLoadingTables", visibility=["read", "create", "update", "delete", "query"] + ) + """Number of tables loading during the migration of a database.""" + full_load_completed_tables: Optional[int] = rest_field( + name="fullLoadCompletedTables", visibility=["read", "create", "update", "delete", "query"] + ) + """Number of tables loaded during the migration of a database.""" + cdc_update_counter: Optional[int] = rest_field( + name="cdcUpdateCounter", visibility=["read", "create", "update", "delete", "query"] + ) + """Change Data Capture update counter.""" + cdc_delete_counter: Optional[int] = rest_field( + name="cdcDeleteCounter", visibility=["read", "create", "update", "delete", "query"] + ) + """Change Data Capture delete counter.""" + cdc_insert_counter: Optional[int] = rest_field( + name="cdcInsertCounter", visibility=["read", "create", "update", "delete", "query"] + ) + """Change Data Capture insert counter.""" + applied_changes: Optional[int] = rest_field( + name="appliedChanges", visibility=["read", "create", "update", "delete", "query"] + ) + """Change Data Capture applied changes counter.""" + incoming_changes: Optional[int] = rest_field( + name="incomingChanges", visibility=["read", "create", "update", "delete", "query"] + ) + """Change Data Capture incoming changes counter.""" + latency: Optional[int] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Lag in seconds between source and target during online phase.""" + message: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Error message, if any, for the migration state.""" + + @overload + def __init__( + self, + *, + database_name: Optional[str] = None, + migration_state: Optional[Union[str, "_models.MigrationDatabaseState"]] = None, + migration_operation: Optional[str] = None, + started_on: Optional[datetime.datetime] = None, + ended_on: Optional[datetime.datetime] = None, + full_load_queued_tables: Optional[int] = None, + full_load_errored_tables: Optional[int] = None, + full_load_loading_tables: Optional[int] = None, + full_load_completed_tables: Optional[int] = None, + cdc_update_counter: Optional[int] = None, + cdc_delete_counter: Optional[int] = None, + cdc_insert_counter: Optional[int] = None, + applied_changes: Optional[int] = None, + incoming_changes: Optional[int] = None, + latency: Optional[int] = None, + message: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class DatabaseProperties(_Model): + """Properties of a database. + + :ivar charset: Character set of the database. + :vartype charset: str + :ivar collation: Collation of the database. + :vartype collation: str + """ + + charset: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Character set of the database.""" + collation: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Collation of the database.""" + + @overload + def __init__( + self, + *, + charset: Optional[str] = None, + collation: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class DataEncryption(_Model): + """Data encryption properties of a server. + + :ivar primary_key_uri: URI of the key in Azure Key Vault used for data encryption of the + primary storage associated to a server. + :vartype primary_key_uri: str + :ivar primary_user_assigned_identity_id: Identifier of the user assigned managed identity used + to access the key in Azure Key Vault for data encryption of the primary storage associated to a + server. + :vartype primary_user_assigned_identity_id: str + :ivar geo_backup_key_uri: Identifier of the user assigned managed identity used to access the + key in Azure Key Vault for data encryption of the geographically redundant storage associated + to a server that is configured to support geographically redundant backups. + :vartype geo_backup_key_uri: str + :ivar geo_backup_user_assigned_identity_id: Identifier of the user assigned managed identity + used to access the key in Azure Key Vault for data encryption of the geographically redundant + storage associated to a server that is configured to support geographically redundant backups. + :vartype geo_backup_user_assigned_identity_id: str + :ivar type: Data encryption type used by a server. Known values are: "SystemManaged" and + "AzureKeyVault". + :vartype type: str or ~azure.mgmt.postgresqlflexibleservers.models.DataEncryptionType + :ivar primary_encryption_key_status: Status of key used by a server configured with data + encryption based on customer managed key, to encrypt the primary storage associated to the + server. Known values are: "Valid" and "Invalid". + :vartype primary_encryption_key_status: str or + ~azure.mgmt.postgresqlflexibleservers.models.EncryptionKeyStatus + :ivar geo_backup_encryption_key_status: Status of key used by a server configured with data + encryption based on customer managed key, to encrypt the geographically redundant storage + associated to the server when it is configured to support geographically redundant backups. + Known values are: "Valid" and "Invalid". + :vartype geo_backup_encryption_key_status: str or + ~azure.mgmt.postgresqlflexibleservers.models.EncryptionKeyStatus + """ + + primary_key_uri: Optional[str] = rest_field( + name="primaryKeyURI", visibility=["read", "create", "update", "delete", "query"] + ) + """URI of the key in Azure Key Vault used for data encryption of the primary storage associated to + a server.""" + primary_user_assigned_identity_id: Optional[str] = rest_field( + name="primaryUserAssignedIdentityId", visibility=["read", "create", "update", "delete", "query"] + ) + """Identifier of the user assigned managed identity used to access the key in Azure Key Vault for + data encryption of the primary storage associated to a server.""" + geo_backup_key_uri: Optional[str] = rest_field( + name="geoBackupKeyURI", visibility=["read", "create", "update", "delete", "query"] + ) + """Identifier of the user assigned managed identity used to access the key in Azure Key Vault for + data encryption of the geographically redundant storage associated to a server that is + configured to support geographically redundant backups.""" + geo_backup_user_assigned_identity_id: Optional[str] = rest_field( + name="geoBackupUserAssignedIdentityId", visibility=["read", "create", "update", "delete", "query"] + ) + """Identifier of the user assigned managed identity used to access the key in Azure Key Vault for + data encryption of the geographically redundant storage associated to a server that is + configured to support geographically redundant backups.""" + type: Optional[Union[str, "_models.DataEncryptionType"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Data encryption type used by a server. Known values are: \"SystemManaged\" and + \"AzureKeyVault\".""" + primary_encryption_key_status: Optional[Union[str, "_models.EncryptionKeyStatus"]] = rest_field( + name="primaryEncryptionKeyStatus", visibility=["read"] + ) + """Status of key used by a server configured with data encryption based on customer managed key, + to encrypt the primary storage associated to the server. Known values are: \"Valid\" and + \"Invalid\".""" + geo_backup_encryption_key_status: Optional[Union[str, "_models.EncryptionKeyStatus"]] = rest_field( + name="geoBackupEncryptionKeyStatus", visibility=["read"] + ) + """Status of key used by a server configured with data encryption based on customer managed key, + to encrypt the geographically redundant storage associated to the server when it is configured + to support geographically redundant backups. Known values are: \"Valid\" and \"Invalid\".""" + + @overload + def __init__( + self, + *, + primary_key_uri: Optional[str] = None, + primary_user_assigned_identity_id: Optional[str] = None, + geo_backup_key_uri: Optional[str] = None, + geo_backup_user_assigned_identity_id: Optional[str] = None, + type: Optional[Union[str, "_models.DataEncryptionType"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class DbLevelValidationStatus(_Model): + """Validation status summary for a database. + + :ivar database_name: Name of database. + :vartype database_name: str + :ivar started_on: Start time of a database level validation. + :vartype started_on: ~datetime.datetime + :ivar ended_on: End time of a database level validation. + :vartype ended_on: ~datetime.datetime + :ivar summary: Summary of database level validations. + :vartype summary: list[~azure.mgmt.postgresqlflexibleservers.models.ValidationSummaryItem] + """ + + database_name: Optional[str] = rest_field( + name="databaseName", visibility=["read", "create", "update", "delete", "query"] + ) + """Name of database.""" + started_on: Optional[datetime.datetime] = rest_field( + name="startedOn", visibility=["read", "create", "update", "delete", "query"], format="rfc3339" + ) + """Start time of a database level validation.""" + ended_on: Optional[datetime.datetime] = rest_field( + name="endedOn", visibility=["read", "create", "update", "delete", "query"], format="rfc3339" + ) + """End time of a database level validation.""" + summary: Optional[list["_models.ValidationSummaryItem"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Summary of database level validations.""" + + @overload + def __init__( + self, + *, + database_name: Optional[str] = None, + started_on: Optional[datetime.datetime] = None, + ended_on: Optional[datetime.datetime] = None, + summary: Optional[list["_models.ValidationSummaryItem"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class DbServerMetadata(_Model): + """Database server metadata. + + :ivar location: Location of database server. + :vartype location: str + :ivar version: Major version of PostgreSQL database engine. + :vartype version: str + :ivar storage_mb: Storage size (in MB) for database server. + :vartype storage_mb: int + :ivar sku: Compute tier and size of the database server. This object is empty for an Azure + Database for PostgreSQL single server. + :vartype sku: ~azure.mgmt.postgresqlflexibleservers.models.ServerSku + """ + + location: Optional[str] = rest_field(visibility=["read"]) + """Location of database server.""" + version: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Major version of PostgreSQL database engine.""" + storage_mb: Optional[int] = rest_field(name="storageMb", visibility=["read", "create", "update", "delete", "query"]) + """Storage size (in MB) for database server.""" + sku: Optional["_models.ServerSku"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Compute tier and size of the database server. This object is empty for an Azure Database for + PostgreSQL single server.""" + + @overload + def __init__( + self, + *, + version: Optional[str] = None, + storage_mb: Optional[int] = None, + sku: Optional["_models.ServerSku"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class DelegatedSubnetUsage(_Model): + """Delegated subnet usage data. + + :ivar subnet_name: Name of the delegated subnet for which IP addresses are in use. + :vartype subnet_name: str + :ivar usage: Number of IP addresses used by the delegated subnet. + :vartype usage: int + """ + + subnet_name: Optional[str] = rest_field(name="subnetName", visibility=["read"]) + """Name of the delegated subnet for which IP addresses are in use.""" + usage: Optional[int] = rest_field(visibility=["read"]) + """Number of IP addresses used by the delegated subnet.""" + + +class ErrorAdditionalInfo(_Model): + """The resource management error additional info. + + :ivar type: The additional info type. + :vartype type: str + :ivar info: The additional info. + :vartype info: any + """ + + type: Optional[str] = rest_field(visibility=["read"]) + """The additional info type.""" + info: Optional[Any] = rest_field(visibility=["read"]) + """The additional info.""" + + +class ErrorDetail(_Model): + """The error detail. + + :ivar code: The error code. + :vartype code: str + :ivar message: The error message. + :vartype message: str + :ivar target: The error target. + :vartype target: str + :ivar details: The error details. + :vartype details: list[~azure.mgmt.postgresqlflexibleservers.models.ErrorDetail] + :ivar additional_info: The error additional info. + :vartype additional_info: + list[~azure.mgmt.postgresqlflexibleservers.models.ErrorAdditionalInfo] + """ + + code: Optional[str] = rest_field(visibility=["read"]) + """The error code.""" + message: Optional[str] = rest_field(visibility=["read"]) + """The error message.""" + target: Optional[str] = rest_field(visibility=["read"]) + """The error target.""" + details: Optional[list["_models.ErrorDetail"]] = rest_field(visibility=["read"]) + """The error details.""" + additional_info: Optional[list["_models.ErrorAdditionalInfo"]] = rest_field( + name="additionalInfo", visibility=["read"] + ) + """The error additional info.""" + + +class ErrorResponse(_Model): + """Error response. + + :ivar error: The error object. + :vartype error: ~azure.mgmt.postgresqlflexibleservers.models.ErrorDetail + """ + + error: Optional["_models.ErrorDetail"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The error object.""" + + @overload + def __init__( + self, + *, + error: Optional["_models.ErrorDetail"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class FastProvisioningEditionCapability(CapabilityBase): + """Capability of a fast provisioning compute tier. + + :ivar status: The status of the capability. Known values are: "Visible", "Available", + "Default", and "Disabled". + :vartype status: str or ~azure.mgmt.postgresqlflexibleservers.models.CapabilityStatus + :ivar reason: The reason for the capability not being available. + :vartype reason: str + :ivar supported_tier: Compute tier supporting fast provisioning. + :vartype supported_tier: str + :ivar supported_sku: Compute name (SKU) supporting fast provisioning. + :vartype supported_sku: str + :ivar supported_storage_gb: Storage size (in GB) supporting fast provisioning. + :vartype supported_storage_gb: int + :ivar supported_server_versions: Major version of PostgreSQL database engine supporting fast + provisioning. + :vartype supported_server_versions: str + :ivar server_count: Count of servers in cache matching this specification. + :vartype server_count: int + """ + + supported_tier: Optional[str] = rest_field(name="supportedTier", visibility=["read"]) + """Compute tier supporting fast provisioning.""" + supported_sku: Optional[str] = rest_field(name="supportedSku", visibility=["read"]) + """Compute name (SKU) supporting fast provisioning.""" + supported_storage_gb: Optional[int] = rest_field(name="supportedStorageGb", visibility=["read"]) + """Storage size (in GB) supporting fast provisioning.""" + supported_server_versions: Optional[str] = rest_field(name="supportedServerVersions", visibility=["read"]) + """Major version of PostgreSQL database engine supporting fast provisioning.""" + server_count: Optional[int] = rest_field(name="serverCount", visibility=["read"]) + """Count of servers in cache matching this specification.""" + + +class FirewallRule(ProxyResource): + """Firewall rule. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.postgresqlflexibleservers.models.SystemData + :ivar properties: Properties of a firewall rule. Required. + :vartype properties: ~azure.mgmt.postgresqlflexibleservers.models.FirewallRuleProperties + """ + + properties: "_models.FirewallRuleProperties" = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Properties of a firewall rule. Required.""" + + __flattened_items = ["start_ip_address", "end_ip_address"] + + @overload + def __init__( + self, + *, + properties: "_models.FirewallRuleProperties", + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class FirewallRuleProperties(_Model): + """Properties of a firewall rule. + + :ivar start_ip_address: IP address defining the start of the range of addresses of a firewall + rule. Must be expressed in IPv4 format. Required. + :vartype start_ip_address: str + :ivar end_ip_address: IP address defining the end of the range of addresses of a firewall rule. + Must be expressed in IPv4 format. Required. + :vartype end_ip_address: str + """ + + start_ip_address: str = rest_field( + name="startIpAddress", visibility=["read", "create", "update", "delete", "query"] + ) + """IP address defining the start of the range of addresses of a firewall rule. Must be expressed + in IPv4 format. Required.""" + end_ip_address: str = rest_field(name="endIpAddress", visibility=["read", "create", "update", "delete", "query"]) + """IP address defining the end of the range of addresses of a firewall rule. Must be expressed in + IPv4 format. Required.""" + + @overload + def __init__( + self, + *, + start_ip_address: str, + end_ip_address: str, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class HighAvailability(_Model): + """High availability properties of a server. + + :ivar mode: High availability mode for a server. Known values are: "Disabled", "ZoneRedundant", + and "SameZone". + :vartype mode: str or + ~azure.mgmt.postgresqlflexibleservers.models.PostgreSqlFlexibleServerHighAvailabilityMode + :ivar state: Possible states of the standby server created when high availability is set to + SameZone or ZoneRedundant. Known values are: "NotEnabled", "CreatingStandby", + "ReplicatingData", "FailingOver", "Healthy", and "RemovingStandby". + :vartype state: str or ~azure.mgmt.postgresqlflexibleservers.models.HighAvailabilityState + :ivar standby_availability_zone: Availability zone associated to the standby server created + when high availability is set to SameZone or ZoneRedundant. + :vartype standby_availability_zone: str + """ + + mode: Optional[Union[str, "_models.PostgreSqlFlexibleServerHighAvailabilityMode"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """High availability mode for a server. Known values are: \"Disabled\", \"ZoneRedundant\", and + \"SameZone\".""" + state: Optional[Union[str, "_models.HighAvailabilityState"]] = rest_field(visibility=["read"]) + """Possible states of the standby server created when high availability is set to SameZone or + ZoneRedundant. Known values are: \"NotEnabled\", \"CreatingStandby\", \"ReplicatingData\", + \"FailingOver\", \"Healthy\", and \"RemovingStandby\".""" + standby_availability_zone: Optional[str] = rest_field( + name="standbyAvailabilityZone", visibility=["read", "create", "update", "delete", "query"] + ) + """Availability zone associated to the standby server created when high availability is set to + SameZone or ZoneRedundant.""" + + @overload + def __init__( + self, + *, + mode: Optional[Union[str, "_models.PostgreSqlFlexibleServerHighAvailabilityMode"]] = None, + standby_availability_zone: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class HighAvailabilityForPatch(_Model): + """High availability properties of a server. + + :ivar mode: High availability mode for a server. Known values are: "Disabled", "ZoneRedundant", + and "SameZone". + :vartype mode: str or + ~azure.mgmt.postgresqlflexibleservers.models.PostgreSqlFlexibleServerHighAvailabilityMode + :ivar state: Possible states of the standby server created when high availability is set to + SameZone or ZoneRedundant. Known values are: "NotEnabled", "CreatingStandby", + "ReplicatingData", "FailingOver", "Healthy", and "RemovingStandby". + :vartype state: str or ~azure.mgmt.postgresqlflexibleservers.models.HighAvailabilityState + :ivar standby_availability_zone: Availability zone associated to the standby server created + when high availability is set to SameZone or ZoneRedundant. + :vartype standby_availability_zone: str + """ + + mode: Optional[Union[str, "_models.PostgreSqlFlexibleServerHighAvailabilityMode"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """High availability mode for a server. Known values are: \"Disabled\", \"ZoneRedundant\", and + \"SameZone\".""" + state: Optional[Union[str, "_models.HighAvailabilityState"]] = rest_field(visibility=["read"]) + """Possible states of the standby server created when high availability is set to SameZone or + ZoneRedundant. Known values are: \"NotEnabled\", \"CreatingStandby\", \"ReplicatingData\", + \"FailingOver\", \"Healthy\", and \"RemovingStandby\".""" + standby_availability_zone: Optional[str] = rest_field( + name="standbyAvailabilityZone", visibility=["read", "create", "update", "delete", "query"] + ) + """Availability zone associated to the standby server created when high availability is set to + SameZone or ZoneRedundant.""" + + @overload + def __init__( + self, + *, + mode: Optional[Union[str, "_models.PostgreSqlFlexibleServerHighAvailabilityMode"]] = None, + standby_availability_zone: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ImpactRecord(_Model): + """Impact on some metric if this recommended action is applied. + + :ivar dimension_name: Dimension name. + :vartype dimension_name: str + :ivar unit: Dimension unit. + :vartype unit: str + :ivar query_id: Optional property that can be used to store the identifier of the query, if the + metric is for a specific query. + :vartype query_id: int + :ivar absolute_value: Absolute value. + :vartype absolute_value: float + """ + + dimension_name: Optional[str] = rest_field( + name="dimensionName", visibility=["read", "create", "update", "delete", "query"] + ) + """Dimension name.""" + unit: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Dimension unit.""" + query_id: Optional[int] = rest_field(name="queryId", visibility=["read", "create", "update", "delete", "query"]) + """Optional property that can be used to store the identifier of the query, if the metric is for a + specific query.""" + absolute_value: Optional[float] = rest_field( + name="absoluteValue", visibility=["read", "create", "update", "delete", "query"] + ) + """Absolute value.""" + + @overload + def __init__( + self, + *, + dimension_name: Optional[str] = None, + unit: Optional[str] = None, + query_id: Optional[int] = None, + absolute_value: Optional[float] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class LogSpecification(_Model): + """Log specification for an operation. + + :ivar name: Name of the log. + :vartype name: str + :ivar display_name: Display name of the log. + :vartype display_name: str + :ivar blob_duration: Blob duration for the log. + :vartype blob_duration: str + """ + + name: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Name of the log.""" + display_name: Optional[str] = rest_field( + name="displayName", visibility=["read", "create", "update", "delete", "query"] + ) + """Display name of the log.""" + blob_duration: Optional[str] = rest_field( + name="blobDuration", visibility=["read", "create", "update", "delete", "query"] + ) + """Blob duration for the log.""" + + @overload + def __init__( + self, + *, + name: Optional[str] = None, + display_name: Optional[str] = None, + blob_duration: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class LtrBackupOperationResponseProperties(_Model): + """Response for the backup request. + + :ivar datasource_size_in_bytes: Size of datasource in bytes. + :vartype datasource_size_in_bytes: int + :ivar data_transferred_in_bytes: Data transferred in bytes. + :vartype data_transferred_in_bytes: int + :ivar backup_name: Name of Backup operation. + :vartype backup_name: str + :ivar backup_metadata: Metadata to be stored in RP. Store everything that will be required to + perform a successful restore using this Recovery point. e.g. Versions, DataFormat etc. + :vartype backup_metadata: str + :ivar status: Service-set extensible enum indicating the status of operation. Required. Known + values are: "Running", "Cancelled", "Failed", and "Succeeded". + :vartype status: str or ~azure.mgmt.postgresqlflexibleservers.models.ExecutionStatus + :ivar start_time: Start time of the operation. Required. + :vartype start_time: ~datetime.datetime + :ivar end_time: End time of the operation. + :vartype end_time: ~datetime.datetime + :ivar percent_complete: PercentageCompleted. + :vartype percent_complete: float + :ivar error_code: The error code. + :vartype error_code: str + :ivar error_message: The error message. + :vartype error_message: str + """ + + datasource_size_in_bytes: Optional[int] = rest_field( + name="datasourceSizeInBytes", visibility=["read", "create", "update", "delete", "query"] + ) + """Size of datasource in bytes.""" + data_transferred_in_bytes: Optional[int] = rest_field( + name="dataTransferredInBytes", visibility=["read", "create", "update", "delete", "query"] + ) + """Data transferred in bytes.""" + backup_name: Optional[str] = rest_field( + name="backupName", visibility=["read", "create", "update", "delete", "query"] + ) + """Name of Backup operation.""" + backup_metadata: Optional[str] = rest_field( + name="backupMetadata", visibility=["read", "create", "update", "delete", "query"] + ) + """Metadata to be stored in RP. Store everything that will be required to perform a successful + restore using this Recovery point. e.g. Versions, DataFormat etc.""" + status: Union[str, "_models.ExecutionStatus"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Service-set extensible enum indicating the status of operation. Required. Known values are: + \"Running\", \"Cancelled\", \"Failed\", and \"Succeeded\".""" + start_time: datetime.datetime = rest_field( + name="startTime", visibility=["read", "create", "update", "delete", "query"], format="rfc3339" + ) + """Start time of the operation. Required.""" + end_time: Optional[datetime.datetime] = rest_field( + name="endTime", visibility=["read", "create", "update", "delete", "query"], format="rfc3339" + ) + """End time of the operation.""" + percent_complete: Optional[float] = rest_field( + name="percentComplete", visibility=["read", "create", "update", "delete", "query"] + ) + """PercentageCompleted.""" + error_code: Optional[str] = rest_field(name="errorCode", visibility=["read"]) + """The error code.""" + error_message: Optional[str] = rest_field(name="errorMessage", visibility=["read"]) + """The error message.""" + + @overload + def __init__( + self, + *, + status: Union[str, "_models.ExecutionStatus"], + start_time: datetime.datetime, + datasource_size_in_bytes: Optional[int] = None, + data_transferred_in_bytes: Optional[int] = None, + backup_name: Optional[str] = None, + backup_metadata: Optional[str] = None, + end_time: Optional[datetime.datetime] = None, + percent_complete: Optional[float] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class LtrPreBackupRequest(BackupRequestBase): + """A request that is made for pre-backup. + + :ivar backup_settings: Backup Settings. Required. + :vartype backup_settings: ~azure.mgmt.postgresqlflexibleservers.models.BackupSettings + """ + + @overload + def __init__( + self, + *, + backup_settings: "_models.BackupSettings", + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class LtrPreBackupResponse(_Model): + """Response for the LTR pre-backup API call. + + :ivar properties: Additional Properties for the pre backup response. Required. + :vartype properties: + ~azure.mgmt.postgresqlflexibleservers.models.BackupsLongTermRetentionResponseProperties + """ + + properties: "_models.BackupsLongTermRetentionResponseProperties" = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Additional Properties for the pre backup response. Required.""" + + __flattened_items = ["number_of_containers"] + + @overload + def __init__( + self, + *, + properties: "_models.BackupsLongTermRetentionResponseProperties", + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class MaintenanceWindow(_Model): + """Maintenance window properties of a server. + + :ivar custom_window: Indicates whether custom window is enabled or disabled. + :vartype custom_window: str + :ivar start_hour: Start hour to be used for maintenance window. + :vartype start_hour: int + :ivar start_minute: Start minute to be used for maintenance window. + :vartype start_minute: int + :ivar day_of_week: Day of the week to be used for maintenance window. + :vartype day_of_week: int + """ + + custom_window: Optional[str] = rest_field( + name="customWindow", visibility=["read", "create", "update", "delete", "query"] + ) + """Indicates whether custom window is enabled or disabled.""" + start_hour: Optional[int] = rest_field(name="startHour", visibility=["read", "create", "update", "delete", "query"]) + """Start hour to be used for maintenance window.""" + start_minute: Optional[int] = rest_field( + name="startMinute", visibility=["read", "create", "update", "delete", "query"] + ) + """Start minute to be used for maintenance window.""" + day_of_week: Optional[int] = rest_field( + name="dayOfWeek", visibility=["read", "create", "update", "delete", "query"] + ) + """Day of the week to be used for maintenance window.""" + + @overload + def __init__( + self, + *, + custom_window: Optional[str] = None, + start_hour: Optional[int] = None, + start_minute: Optional[int] = None, + day_of_week: Optional[int] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class MaintenanceWindowForPatch(_Model): + """Maintenance window properties of a server. + + :ivar custom_window: Indicates whether custom window is enabled or disabled. + :vartype custom_window: str + :ivar start_hour: Start hour to be used for maintenance window. + :vartype start_hour: int + :ivar start_minute: Start minute to be used for maintenance window. + :vartype start_minute: int + :ivar day_of_week: Day of the week to be used for maintenance window. + :vartype day_of_week: int + """ + + custom_window: Optional[str] = rest_field( + name="customWindow", visibility=["read", "create", "update", "delete", "query"] + ) + """Indicates whether custom window is enabled or disabled.""" + start_hour: Optional[int] = rest_field(name="startHour", visibility=["read", "create", "update", "delete", "query"]) + """Start hour to be used for maintenance window.""" + start_minute: Optional[int] = rest_field( + name="startMinute", visibility=["read", "create", "update", "delete", "query"] + ) + """Start minute to be used for maintenance window.""" + day_of_week: Optional[int] = rest_field( + name="dayOfWeek", visibility=["read", "create", "update", "delete", "query"] + ) + """Day of the week to be used for maintenance window.""" + + @overload + def __init__( + self, + *, + custom_window: Optional[str] = None, + start_hour: Optional[int] = None, + start_minute: Optional[int] = None, + day_of_week: Optional[int] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class MetricSpecification(_Model): + """Metric specification for an operation. + + :ivar name: Name of the metric. + :vartype name: str + :ivar display_name: Display name of the metric. + :vartype display_name: str + :ivar display_description: Display description of the metric. + :vartype display_description: str + :ivar unit: Unit of the metric. + :vartype unit: str + :ivar aggregation_type: Aggregation type of the metric. + :vartype aggregation_type: str + :ivar supported_aggregation_types: Supported aggregation types for the metric. + :vartype supported_aggregation_types: list[str] + :ivar supported_time_grain_types: Supported time grain types for the metric. + :vartype supported_time_grain_types: list[str] + :ivar category: Category of the metric. + :vartype category: str + """ + + name: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Name of the metric.""" + display_name: Optional[str] = rest_field( + name="displayName", visibility=["read", "create", "update", "delete", "query"] + ) + """Display name of the metric.""" + display_description: Optional[str] = rest_field( + name="displayDescription", visibility=["read", "create", "update", "delete", "query"] + ) + """Display description of the metric.""" + unit: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Unit of the metric.""" + aggregation_type: Optional[str] = rest_field( + name="aggregationType", visibility=["read", "create", "update", "delete", "query"] + ) + """Aggregation type of the metric.""" + supported_aggregation_types: Optional[list[str]] = rest_field( + name="supportedAggregationTypes", visibility=["read", "create", "update", "delete", "query"] + ) + """Supported aggregation types for the metric.""" + supported_time_grain_types: Optional[list[str]] = rest_field( + name="supportedTimeGrainTypes", visibility=["read", "create", "update", "delete", "query"] + ) + """Supported time grain types for the metric.""" + category: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Category of the metric.""" + + @overload + def __init__( + self, + *, + name: Optional[str] = None, + display_name: Optional[str] = None, + display_description: Optional[str] = None, + unit: Optional[str] = None, + aggregation_type: Optional[str] = None, + supported_aggregation_types: Optional[list[str]] = None, + supported_time_grain_types: Optional[list[str]] = None, + category: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class MigrateNetworkStatus(_Model): + """The status of a network migration operation. + + :ivar subscription_id: The ID of the subscription. + :vartype subscription_id: str + :ivar resource_group_name: The name of the resource group. + :vartype resource_group_name: str + :ivar server_name: The name of the server. + :vartype server_name: str + :ivar state: The state of the network migration operation. Known values are: "Pending", + "InProgress", "Succeeded", "Failed", "CancelInProgress", and "Cancelled". + :vartype state: str or ~azure.mgmt.postgresqlflexibleservers.models.NetworkMigrationState + """ + + subscription_id: Optional[str] = rest_field( + name="subscriptionId", visibility=["read", "create", "update", "delete", "query"] + ) + """The ID of the subscription.""" + resource_group_name: Optional[str] = rest_field( + name="resourceGroupName", visibility=["read", "create", "update", "delete", "query"] + ) + """The name of the resource group.""" + server_name: Optional[str] = rest_field( + name="serverName", visibility=["read", "create", "update", "delete", "query"] + ) + """The name of the server.""" + state: Optional[Union[str, "_models.NetworkMigrationState"]] = rest_field(visibility=["read"]) + """The state of the network migration operation. Known values are: \"Pending\", \"InProgress\", + \"Succeeded\", \"Failed\", \"CancelInProgress\", and \"Cancelled\".""" + + @overload + def __init__( + self, + *, + subscription_id: Optional[str] = None, + resource_group_name: Optional[str] = None, + server_name: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class TrackedResource(Resource): + """Tracked Resource. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.postgresqlflexibleservers.models.SystemData + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + :ivar location: The geo-location where the resource lives. Required. + :vartype location: str + """ + + tags: Optional[dict[str, str]] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Resource tags.""" + location: str = rest_field(visibility=["read", "create"]) + """The geo-location where the resource lives. Required.""" + + @overload + def __init__( + self, + *, + location: str, + tags: Optional[dict[str, str]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class Migration(TrackedResource): + """Properties of a migration. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.postgresqlflexibleservers.models.SystemData + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + :ivar location: The geo-location where the resource lives. Required. + :vartype location: str + :ivar properties: Migration properties. + :vartype properties: ~azure.mgmt.postgresqlflexibleservers.models.MigrationProperties + """ + + properties: Optional["_models.MigrationProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Migration properties.""" + + __flattened_items = [ + "migration_id", + "current_status", + "migration_instance_resource_id", + "migration_mode", + "migration_option", + "source_type", + "ssl_mode", + "source_db_server_metadata", + "target_db_server_metadata", + "source_db_server_resource_id", + "source_db_server_fully_qualified_domain_name", + "target_db_server_resource_id", + "target_db_server_fully_qualified_domain_name", + "secret_parameters", + "dbs_to_migrate", + "setup_logical_replication_on_source_db_if_needed", + "overwrite_dbs_in_target", + "migration_window_start_time_in_utc", + "migration_window_end_time_in_utc", + "migrate_roles", + "start_data_migration", + "trigger_cutover", + "dbs_to_trigger_cutover_on", + "cancel", + "dbs_to_cancel_migration_on", + ] + + @overload + def __init__( + self, + *, + location: str, + tags: Optional[dict[str, str]] = None, + properties: Optional["_models.MigrationProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class MigrationNameAvailability(_Model): + """Availability of a migration name. + + :ivar name: Name of the migration to check for validity and availability. Required. + :vartype name: str + :ivar type: Type of resource. Required. + :vartype type: str + :ivar name_available: Indicates if the migration name is available. + :vartype name_available: bool + :ivar reason: Migration name availability reason. Known values are: "Invalid" and + "AlreadyExists". + :vartype reason: str or + ~azure.mgmt.postgresqlflexibleservers.models.MigrationNameAvailabilityReason + :ivar message: Migration name availability message. + :vartype message: str + """ + + name: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Name of the migration to check for validity and availability. Required.""" + type: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Type of resource. Required.""" + name_available: Optional[bool] = rest_field(name="nameAvailable", visibility=["read"]) + """Indicates if the migration name is available.""" + reason: Optional[Union[str, "_models.MigrationNameAvailabilityReason"]] = rest_field(visibility=["read"]) + """Migration name availability reason. Known values are: \"Invalid\" and \"AlreadyExists\".""" + message: Optional[str] = rest_field(visibility=["read"]) + """Migration name availability message.""" + + @overload + def __init__( + self, + *, + name: str, + type: str, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class MigrationProperties(_Model): + """Migration. + + :ivar migration_id: Identifier of a migration. + :vartype migration_id: str + :ivar current_status: Current status of a migration. + :vartype current_status: ~azure.mgmt.postgresqlflexibleservers.models.MigrationStatus + :ivar migration_instance_resource_id: Identifier of the private endpoint migration instance. + :vartype migration_instance_resource_id: str + :ivar migration_mode: Mode used to perform the migration: Online or Offline. Known values are: + "Offline" and "Online". + :vartype migration_mode: str or ~azure.mgmt.postgresqlflexibleservers.models.MigrationMode + :ivar migration_option: Supported option for a migration. Known values are: "Validate", + "Migrate", and "ValidateAndMigrate". + :vartype migration_option: str or ~azure.mgmt.postgresqlflexibleservers.models.MigrationOption + :ivar source_type: Source server type used for the migration: ApsaraDB_RDS, AWS, AWS_AURORA, + AWS_EC2, AWS_RDS, AzureVM, Crunchy_PostgreSQL, Digital_Ocean_Droplets, + Digital_Ocean_PostgreSQL, EDB, EDB_Oracle_Server, EDB_PostgreSQL, GCP, GCP_AlloyDB, + GCP_CloudSQL, GCP_Compute, Heroku_PostgreSQL, Huawei_Compute, Huawei_RDS, OnPremises, + PostgreSQLCosmosDB, PostgreSQLFlexibleServer, PostgreSQLSingleServer, or Supabase_PostgreSQL. + Known values are: "OnPremises", "AWS", "GCP", "AzureVM", "PostgreSQLSingleServer", "AWS_RDS", + "AWS_AURORA", "AWS_EC2", "GCP_CloudSQL", "GCP_AlloyDB", "GCP_Compute", "EDB", + "EDB_Oracle_Server", "EDB_PostgreSQL", "PostgreSQLFlexibleServer", "PostgreSQLCosmosDB", + "Huawei_RDS", "Huawei_Compute", "Heroku_PostgreSQL", "Crunchy_PostgreSQL", "ApsaraDB_RDS", + "Digital_Ocean_Droplets", "Digital_Ocean_PostgreSQL", and "Supabase_PostgreSQL". + :vartype source_type: str or ~azure.mgmt.postgresqlflexibleservers.models.SourceType + :ivar ssl_mode: SSL mode used by a migration. Default SSL mode for 'PostgreSQLSingleServer' is + 'VerifyFull'. Default SSL mode for other source types is 'Prefer'. Known values are: "Prefer", + "Require", "VerifyCA", and "VerifyFull". + :vartype ssl_mode: str or ~azure.mgmt.postgresqlflexibleservers.models.SslMode + :ivar source_db_server_metadata: Metadata of source database server. + :vartype source_db_server_metadata: + ~azure.mgmt.postgresqlflexibleservers.models.DbServerMetadata + :ivar target_db_server_metadata: Metadata of target database server. + :vartype target_db_server_metadata: + ~azure.mgmt.postgresqlflexibleservers.models.DbServerMetadata + :ivar source_db_server_resource_id: Identifier of the source database server resource, when + 'sourceType' is 'PostgreSQLSingleServer'. For other source types this must be set to + ipaddress:port@username or hostname:port@username. + :vartype source_db_server_resource_id: str + :ivar source_db_server_fully_qualified_domain_name: Fully qualified domain name (FQDN) or IP + address of the source server. This property is optional. When provided, the migration service + will always use it to connect to the source server. + :vartype source_db_server_fully_qualified_domain_name: str + :ivar target_db_server_resource_id: Identifier of the target database server resource. + :vartype target_db_server_resource_id: str + :ivar target_db_server_fully_qualified_domain_name: Fully qualified domain name (FQDN) or IP + address of the target server. This property is optional. When provided, the migration service + will always use it to connect to the target server. + :vartype target_db_server_fully_qualified_domain_name: str + :ivar secret_parameters: Migration secret parameters. + :vartype secret_parameters: + ~azure.mgmt.postgresqlflexibleservers.models.MigrationSecretParameters + :ivar dbs_to_migrate: Names of databases to migrate. + :vartype dbs_to_migrate: list[str] + :ivar setup_logical_replication_on_source_db_if_needed: Indicates whether to setup logical + replication on source server, if needed. Known values are: "True" and "False". + :vartype setup_logical_replication_on_source_db_if_needed: str or + ~azure.mgmt.postgresqlflexibleservers.models.LogicalReplicationOnSourceServer + :ivar overwrite_dbs_in_target: Indicates if databases on the target server can be overwritten + when already present. If set to 'False', when the migration workflow detects that the database + already exists on the target server, it will wait for a confirmation. Known values are: "True" + and "False". + :vartype overwrite_dbs_in_target: str or + ~azure.mgmt.postgresqlflexibleservers.models.OverwriteDatabasesOnTargetServer + :ivar migration_window_start_time_in_utc: Start time (UTC) for migration window. + :vartype migration_window_start_time_in_utc: ~datetime.datetime + :ivar migration_window_end_time_in_utc: End time (UTC) for migration window. + :vartype migration_window_end_time_in_utc: ~datetime.datetime + :ivar migrate_roles: Indicates if roles and permissions must be migrated. Known values are: + "True" and "False". + :vartype migrate_roles: str or + ~azure.mgmt.postgresqlflexibleservers.models.MigrateRolesAndPermissions + :ivar start_data_migration: Indicates if data migration must start right away. Known values + are: "True" and "False". + :vartype start_data_migration: str or + ~azure.mgmt.postgresqlflexibleservers.models.StartDataMigration + :ivar trigger_cutover: Indicates if cutover must be triggered for the entire migration. Known + values are: "True" and "False". + :vartype trigger_cutover: str or ~azure.mgmt.postgresqlflexibleservers.models.TriggerCutover + :ivar dbs_to_trigger_cutover_on: When you want to trigger cutover for specific databases set + 'triggerCutover' to 'True' and the names of the specific databases in this array. + :vartype dbs_to_trigger_cutover_on: list[str] + :ivar cancel: Indicates if cancel must be triggered for the entire migration. Known values are: + "True" and "False". + :vartype cancel: str or ~azure.mgmt.postgresqlflexibleservers.models.Cancel + :ivar dbs_to_cancel_migration_on: When you want to trigger cancel for specific databases set + 'triggerCutover' to 'True' and the names of the specific databases in this array. + :vartype dbs_to_cancel_migration_on: list[str] + """ + + migration_id: Optional[str] = rest_field(name="migrationId", visibility=["read"]) + """Identifier of a migration.""" + current_status: Optional["_models.MigrationStatus"] = rest_field(name="currentStatus", visibility=["read"]) + """Current status of a migration.""" + migration_instance_resource_id: Optional[str] = rest_field( + name="migrationInstanceResourceId", visibility=["read", "create", "update", "delete", "query"] + ) + """Identifier of the private endpoint migration instance.""" + migration_mode: Optional[Union[str, "_models.MigrationMode"]] = rest_field( + name="migrationMode", visibility=["read", "create", "update", "delete", "query"] + ) + """Mode used to perform the migration: Online or Offline. Known values are: \"Offline\" and + \"Online\".""" + migration_option: Optional[Union[str, "_models.MigrationOption"]] = rest_field( + name="migrationOption", visibility=["read", "create", "update", "delete", "query"] + ) + """Supported option for a migration. Known values are: \"Validate\", \"Migrate\", and + \"ValidateAndMigrate\".""" + source_type: Optional[Union[str, "_models.SourceType"]] = rest_field( + name="sourceType", visibility=["read", "create", "update", "delete", "query"] + ) + """Source server type used for the migration: ApsaraDB_RDS, AWS, AWS_AURORA, AWS_EC2, AWS_RDS, + AzureVM, Crunchy_PostgreSQL, Digital_Ocean_Droplets, Digital_Ocean_PostgreSQL, EDB, + EDB_Oracle_Server, EDB_PostgreSQL, GCP, GCP_AlloyDB, GCP_CloudSQL, GCP_Compute, + Heroku_PostgreSQL, Huawei_Compute, Huawei_RDS, OnPremises, PostgreSQLCosmosDB, + PostgreSQLFlexibleServer, PostgreSQLSingleServer, or Supabase_PostgreSQL. Known values are: + \"OnPremises\", \"AWS\", \"GCP\", \"AzureVM\", \"PostgreSQLSingleServer\", \"AWS_RDS\", + \"AWS_AURORA\", \"AWS_EC2\", \"GCP_CloudSQL\", \"GCP_AlloyDB\", \"GCP_Compute\", \"EDB\", + \"EDB_Oracle_Server\", \"EDB_PostgreSQL\", \"PostgreSQLFlexibleServer\", + \"PostgreSQLCosmosDB\", \"Huawei_RDS\", \"Huawei_Compute\", \"Heroku_PostgreSQL\", + \"Crunchy_PostgreSQL\", \"ApsaraDB_RDS\", \"Digital_Ocean_Droplets\", + \"Digital_Ocean_PostgreSQL\", and \"Supabase_PostgreSQL\".""" + ssl_mode: Optional[Union[str, "_models.SslMode"]] = rest_field( + name="sslMode", visibility=["read", "create", "update", "delete", "query"] + ) + """SSL mode used by a migration. Default SSL mode for 'PostgreSQLSingleServer' is 'VerifyFull'. + Default SSL mode for other source types is 'Prefer'. Known values are: \"Prefer\", \"Require\", + \"VerifyCA\", and \"VerifyFull\".""" + source_db_server_metadata: Optional["_models.DbServerMetadata"] = rest_field( + name="sourceDbServerMetadata", visibility=["read"] + ) + """Metadata of source database server.""" + target_db_server_metadata: Optional["_models.DbServerMetadata"] = rest_field( + name="targetDbServerMetadata", visibility=["read"] + ) + """Metadata of target database server.""" + source_db_server_resource_id: Optional[str] = rest_field( + name="sourceDbServerResourceId", visibility=["read", "create", "update", "delete", "query"] + ) + """Identifier of the source database server resource, when 'sourceType' is + 'PostgreSQLSingleServer'. For other source types this must be set to ipaddress:port@username or + hostname:port@username.""" + source_db_server_fully_qualified_domain_name: Optional[str] = rest_field( + name="sourceDbServerFullyQualifiedDomainName", visibility=["read", "create", "update", "delete", "query"] + ) + """Fully qualified domain name (FQDN) or IP address of the source server. This property is + optional. When provided, the migration service will always use it to connect to the source + server.""" + target_db_server_resource_id: Optional[str] = rest_field(name="targetDbServerResourceId", visibility=["read"]) + """Identifier of the target database server resource.""" + target_db_server_fully_qualified_domain_name: Optional[str] = rest_field( + name="targetDbServerFullyQualifiedDomainName", visibility=["read", "create", "update", "delete", "query"] + ) + """Fully qualified domain name (FQDN) or IP address of the target server. This property is + optional. When provided, the migration service will always use it to connect to the target + server.""" + secret_parameters: Optional["_models.MigrationSecretParameters"] = rest_field( + name="secretParameters", visibility=["read", "create", "update", "delete", "query"] + ) + """Migration secret parameters.""" + dbs_to_migrate: Optional[list[str]] = rest_field( + name="dbsToMigrate", visibility=["read", "create", "update", "delete", "query"] + ) + """Names of databases to migrate.""" + setup_logical_replication_on_source_db_if_needed: Optional[ + Union[str, "_models.LogicalReplicationOnSourceServer"] + ] = rest_field( + name="setupLogicalReplicationOnSourceDbIfNeeded", visibility=["read", "create", "update", "delete", "query"] + ) + """Indicates whether to setup logical replication on source server, if needed. Known values are: + \"True\" and \"False\".""" + overwrite_dbs_in_target: Optional[Union[str, "_models.OverwriteDatabasesOnTargetServer"]] = rest_field( + name="overwriteDbsInTarget", visibility=["read", "create", "update", "delete", "query"] + ) + """Indicates if databases on the target server can be overwritten when already present. If set to + 'False', when the migration workflow detects that the database already exists on the target + server, it will wait for a confirmation. Known values are: \"True\" and \"False\".""" + migration_window_start_time_in_utc: Optional[datetime.datetime] = rest_field( + name="migrationWindowStartTimeInUtc", + visibility=["read", "create", "update", "delete", "query"], + format="rfc3339", + ) + """Start time (UTC) for migration window.""" + migration_window_end_time_in_utc: Optional[datetime.datetime] = rest_field( + name="migrationWindowEndTimeInUtc", visibility=["read", "create", "update", "delete", "query"], format="rfc3339" + ) + """End time (UTC) for migration window.""" + migrate_roles: Optional[Union[str, "_models.MigrateRolesAndPermissions"]] = rest_field( + name="migrateRoles", visibility=["read", "create", "update", "delete", "query"] + ) + """Indicates if roles and permissions must be migrated. Known values are: \"True\" and \"False\".""" + start_data_migration: Optional[Union[str, "_models.StartDataMigration"]] = rest_field( + name="startDataMigration", visibility=["read", "create", "update", "delete", "query"] + ) + """Indicates if data migration must start right away. Known values are: \"True\" and \"False\".""" + trigger_cutover: Optional[Union[str, "_models.TriggerCutover"]] = rest_field( + name="triggerCutover", visibility=["read", "create", "update", "delete", "query"] + ) + """Indicates if cutover must be triggered for the entire migration. Known values are: \"True\" and + \"False\".""" + dbs_to_trigger_cutover_on: Optional[list[str]] = rest_field( + name="dbsToTriggerCutoverOn", visibility=["read", "create", "update", "delete", "query"] + ) + """When you want to trigger cutover for specific databases set 'triggerCutover' to 'True' and the + names of the specific databases in this array.""" + cancel: Optional[Union[str, "_models.Cancel"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Indicates if cancel must be triggered for the entire migration. Known values are: \"True\" and + \"False\".""" + dbs_to_cancel_migration_on: Optional[list[str]] = rest_field( + name="dbsToCancelMigrationOn", visibility=["read", "create", "update", "delete", "query"] + ) + """When you want to trigger cancel for specific databases set 'triggerCutover' to 'True' and the + names of the specific databases in this array.""" + + @overload + def __init__( + self, + *, + migration_instance_resource_id: Optional[str] = None, + migration_mode: Optional[Union[str, "_models.MigrationMode"]] = None, + migration_option: Optional[Union[str, "_models.MigrationOption"]] = None, + source_type: Optional[Union[str, "_models.SourceType"]] = None, + ssl_mode: Optional[Union[str, "_models.SslMode"]] = None, + source_db_server_resource_id: Optional[str] = None, + source_db_server_fully_qualified_domain_name: Optional[str] = None, + target_db_server_fully_qualified_domain_name: Optional[str] = None, + secret_parameters: Optional["_models.MigrationSecretParameters"] = None, + dbs_to_migrate: Optional[list[str]] = None, + setup_logical_replication_on_source_db_if_needed: Optional[ + Union[str, "_models.LogicalReplicationOnSourceServer"] + ] = None, + overwrite_dbs_in_target: Optional[Union[str, "_models.OverwriteDatabasesOnTargetServer"]] = None, + migration_window_start_time_in_utc: Optional[datetime.datetime] = None, + migration_window_end_time_in_utc: Optional[datetime.datetime] = None, + migrate_roles: Optional[Union[str, "_models.MigrateRolesAndPermissions"]] = None, + start_data_migration: Optional[Union[str, "_models.StartDataMigration"]] = None, + trigger_cutover: Optional[Union[str, "_models.TriggerCutover"]] = None, + dbs_to_trigger_cutover_on: Optional[list[str]] = None, + cancel: Optional[Union[str, "_models.Cancel"]] = None, + dbs_to_cancel_migration_on: Optional[list[str]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class MigrationPropertiesForPatch(_Model): + """Migration properties. + + :ivar source_db_server_resource_id: Identifier of the source database server resource, when + 'sourceType' is 'PostgreSQLSingleServer'. For other source types this must be set to + ipaddress:port@username or hostname:port@username. + :vartype source_db_server_resource_id: str + :ivar source_db_server_fully_qualified_domain_name: Fully qualified domain name (FQDN) or IP + address of the source server. This property is optional. When provided, the migration service + will always use it to connect to the source server. + :vartype source_db_server_fully_qualified_domain_name: str + :ivar target_db_server_fully_qualified_domain_name: Fully qualified domain name (FQDN) or IP + address of the target server. This property is optional. When provided, the migration service + will always use it to connect to the target server. + :vartype target_db_server_fully_qualified_domain_name: str + :ivar secret_parameters: Migration secret parameters. + :vartype secret_parameters: + ~azure.mgmt.postgresqlflexibleservers.models.MigrationSecretParametersForPatch + :ivar dbs_to_migrate: Names of databases to migrate. + :vartype dbs_to_migrate: list[str] + :ivar setup_logical_replication_on_source_db_if_needed: Indicates whether to setup logical + replication on source server, if needed. Known values are: "True" and "False". + :vartype setup_logical_replication_on_source_db_if_needed: str or + ~azure.mgmt.postgresqlflexibleservers.models.LogicalReplicationOnSourceServer + :ivar overwrite_dbs_in_target: Indicates if databases on the target server can be overwritten + when already present. If set to 'False', when the migration workflow detects that the database + already exists on the target server, it will wait for a confirmation. Known values are: "True" + and "False". + :vartype overwrite_dbs_in_target: str or + ~azure.mgmt.postgresqlflexibleservers.models.OverwriteDatabasesOnTargetServer + :ivar migration_window_start_time_in_utc: Start time (UTC) for migration window. + :vartype migration_window_start_time_in_utc: ~datetime.datetime + :ivar migrate_roles: Indicates if roles and permissions must be migrated. Known values are: + "True" and "False". + :vartype migrate_roles: str or + ~azure.mgmt.postgresqlflexibleservers.models.MigrateRolesAndPermissions + :ivar start_data_migration: Indicates if data migration must start right away. Known values + are: "True" and "False". + :vartype start_data_migration: str or + ~azure.mgmt.postgresqlflexibleservers.models.StartDataMigration + :ivar trigger_cutover: Indicates if cutover must be triggered for the entire migration. Known + values are: "True" and "False". + :vartype trigger_cutover: str or ~azure.mgmt.postgresqlflexibleservers.models.TriggerCutover + :ivar dbs_to_trigger_cutover_on: When you want to trigger cutover for specific databases set + 'triggerCutover' to 'True' and the names of the specific databases in this array. + :vartype dbs_to_trigger_cutover_on: list[str] + :ivar cancel: Indicates if cancel must be triggered for the entire migration. Known values are: + "True" and "False". + :vartype cancel: str or ~azure.mgmt.postgresqlflexibleservers.models.Cancel + :ivar dbs_to_cancel_migration_on: When you want to trigger cancel for specific databases set + 'triggerCutover' to 'True' and the names of the specific databases in this array. + :vartype dbs_to_cancel_migration_on: list[str] + :ivar migration_mode: Mode used to perform the migration: Online or Offline. Known values are: + "Offline" and "Online". + :vartype migration_mode: str or ~azure.mgmt.postgresqlflexibleservers.models.MigrationMode + """ + + source_db_server_resource_id: Optional[str] = rest_field( + name="sourceDbServerResourceId", visibility=["read", "create", "update", "delete", "query"] + ) + """Identifier of the source database server resource, when 'sourceType' is + 'PostgreSQLSingleServer'. For other source types this must be set to ipaddress:port@username or + hostname:port@username.""" + source_db_server_fully_qualified_domain_name: Optional[str] = rest_field( + name="sourceDbServerFullyQualifiedDomainName", visibility=["read", "create", "update", "delete", "query"] + ) + """Fully qualified domain name (FQDN) or IP address of the source server. This property is + optional. When provided, the migration service will always use it to connect to the source + server.""" + target_db_server_fully_qualified_domain_name: Optional[str] = rest_field( + name="targetDbServerFullyQualifiedDomainName", visibility=["read", "create", "update", "delete", "query"] + ) + """Fully qualified domain name (FQDN) or IP address of the target server. This property is + optional. When provided, the migration service will always use it to connect to the target + server.""" + secret_parameters: Optional["_models.MigrationSecretParametersForPatch"] = rest_field( + name="secretParameters", visibility=["read", "create", "update", "delete", "query"] + ) + """Migration secret parameters.""" + dbs_to_migrate: Optional[list[str]] = rest_field( + name="dbsToMigrate", visibility=["read", "create", "update", "delete", "query"] + ) + """Names of databases to migrate.""" + setup_logical_replication_on_source_db_if_needed: Optional[ + Union[str, "_models.LogicalReplicationOnSourceServer"] + ] = rest_field( + name="setupLogicalReplicationOnSourceDbIfNeeded", visibility=["read", "create", "update", "delete", "query"] + ) + """Indicates whether to setup logical replication on source server, if needed. Known values are: + \"True\" and \"False\".""" + overwrite_dbs_in_target: Optional[Union[str, "_models.OverwriteDatabasesOnTargetServer"]] = rest_field( + name="overwriteDbsInTarget", visibility=["read", "create", "update", "delete", "query"] + ) + """Indicates if databases on the target server can be overwritten when already present. If set to + 'False', when the migration workflow detects that the database already exists on the target + server, it will wait for a confirmation. Known values are: \"True\" and \"False\".""" + migration_window_start_time_in_utc: Optional[datetime.datetime] = rest_field( + name="migrationWindowStartTimeInUtc", + visibility=["read", "create", "update", "delete", "query"], + format="rfc3339", + ) + """Start time (UTC) for migration window.""" + migrate_roles: Optional[Union[str, "_models.MigrateRolesAndPermissions"]] = rest_field( + name="migrateRoles", visibility=["read", "create", "update", "delete", "query"] + ) + """Indicates if roles and permissions must be migrated. Known values are: \"True\" and \"False\".""" + start_data_migration: Optional[Union[str, "_models.StartDataMigration"]] = rest_field( + name="startDataMigration", visibility=["read", "create", "update", "delete", "query"] + ) + """Indicates if data migration must start right away. Known values are: \"True\" and \"False\".""" + trigger_cutover: Optional[Union[str, "_models.TriggerCutover"]] = rest_field( + name="triggerCutover", visibility=["read", "create", "update", "delete", "query"] + ) + """Indicates if cutover must be triggered for the entire migration. Known values are: \"True\" and + \"False\".""" + dbs_to_trigger_cutover_on: Optional[list[str]] = rest_field( + name="dbsToTriggerCutoverOn", visibility=["read", "create", "update", "delete", "query"] + ) + """When you want to trigger cutover for specific databases set 'triggerCutover' to 'True' and the + names of the specific databases in this array.""" + cancel: Optional[Union[str, "_models.Cancel"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Indicates if cancel must be triggered for the entire migration. Known values are: \"True\" and + \"False\".""" + dbs_to_cancel_migration_on: Optional[list[str]] = rest_field( + name="dbsToCancelMigrationOn", visibility=["read", "create", "update", "delete", "query"] + ) + """When you want to trigger cancel for specific databases set 'triggerCutover' to 'True' and the + names of the specific databases in this array.""" + migration_mode: Optional[Union[str, "_models.MigrationMode"]] = rest_field( + name="migrationMode", visibility=["read", "create", "update", "delete", "query"] + ) + """Mode used to perform the migration: Online or Offline. Known values are: \"Offline\" and + \"Online\".""" + + @overload + def __init__( + self, + *, + source_db_server_resource_id: Optional[str] = None, + source_db_server_fully_qualified_domain_name: Optional[str] = None, + target_db_server_fully_qualified_domain_name: Optional[str] = None, + secret_parameters: Optional["_models.MigrationSecretParametersForPatch"] = None, + dbs_to_migrate: Optional[list[str]] = None, + setup_logical_replication_on_source_db_if_needed: Optional[ + Union[str, "_models.LogicalReplicationOnSourceServer"] + ] = None, + overwrite_dbs_in_target: Optional[Union[str, "_models.OverwriteDatabasesOnTargetServer"]] = None, + migration_window_start_time_in_utc: Optional[datetime.datetime] = None, + migrate_roles: Optional[Union[str, "_models.MigrateRolesAndPermissions"]] = None, + start_data_migration: Optional[Union[str, "_models.StartDataMigration"]] = None, + trigger_cutover: Optional[Union[str, "_models.TriggerCutover"]] = None, + dbs_to_trigger_cutover_on: Optional[list[str]] = None, + cancel: Optional[Union[str, "_models.Cancel"]] = None, + dbs_to_cancel_migration_on: Optional[list[str]] = None, + migration_mode: Optional[Union[str, "_models.MigrationMode"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class MigrationResourceForPatch(_Model): + """Migration. + + :ivar properties: Migration properties. + :vartype properties: ~azure.mgmt.postgresqlflexibleservers.models.MigrationPropertiesForPatch + :ivar tags: Application-specific metadata in the form of key-value pairs. + :vartype tags: dict[str, str] + """ + + properties: Optional["_models.MigrationPropertiesForPatch"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Migration properties.""" + tags: Optional[dict[str, str]] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Application-specific metadata in the form of key-value pairs.""" + + __flattened_items = [ + "source_db_server_resource_id", + "source_db_server_fully_qualified_domain_name", + "target_db_server_fully_qualified_domain_name", + "secret_parameters", + "dbs_to_migrate", + "setup_logical_replication_on_source_db_if_needed", + "overwrite_dbs_in_target", + "migration_window_start_time_in_utc", + "migrate_roles", + "start_data_migration", + "trigger_cutover", + "dbs_to_trigger_cutover_on", + "cancel", + "dbs_to_cancel_migration_on", + "migration_mode", + ] + + @overload + def __init__( + self, + *, + properties: Optional["_models.MigrationPropertiesForPatch"] = None, + tags: Optional[dict[str, str]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class MigrationSecretParameters(_Model): + """Migration secret parameters. + + :ivar admin_credentials: Credentials of administrator users for source and target servers. + Required. + :vartype admin_credentials: ~azure.mgmt.postgresqlflexibleservers.models.AdminCredentials + :ivar source_server_username: Gets or sets the name of the user for the source server. This + user doesn't need to be an administrator. + :vartype source_server_username: str + :ivar target_server_username: Gets or sets the name of the user for the target server. This + user doesn't need to be an administrator. + :vartype target_server_username: str + """ + + admin_credentials: "_models.AdminCredentials" = rest_field( + name="adminCredentials", visibility=["read", "create", "update", "delete", "query"] + ) + """Credentials of administrator users for source and target servers. Required.""" + source_server_username: Optional[str] = rest_field(name="sourceServerUsername", visibility=["create", "update"]) + """Gets or sets the name of the user for the source server. This user doesn't need to be an + administrator.""" + target_server_username: Optional[str] = rest_field(name="targetServerUsername", visibility=["create", "update"]) + """Gets or sets the name of the user for the target server. This user doesn't need to be an + administrator.""" + + @overload + def __init__( + self, + *, + admin_credentials: "_models.AdminCredentials", + source_server_username: Optional[str] = None, + target_server_username: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class MigrationSecretParametersForPatch(_Model): + """Migration secret parameters. + + :ivar admin_credentials: Credentials of administrator users for source and target servers. + :vartype admin_credentials: + ~azure.mgmt.postgresqlflexibleservers.models.AdminCredentialsForPatch + :ivar source_server_username: Gets or sets the name of the user for the source server. This + user doesn't need to be an administrator. + :vartype source_server_username: str + :ivar target_server_username: Gets or sets the name of the user for the target server. This + user doesn't need to be an administrator. + :vartype target_server_username: str + """ + + admin_credentials: Optional["_models.AdminCredentialsForPatch"] = rest_field( + name="adminCredentials", visibility=["read", "create", "update", "delete", "query"] + ) + """Credentials of administrator users for source and target servers.""" + source_server_username: Optional[str] = rest_field(name="sourceServerUsername", visibility=["update"]) + """Gets or sets the name of the user for the source server. This user doesn't need to be an + administrator.""" + target_server_username: Optional[str] = rest_field(name="targetServerUsername", visibility=["update"]) + """Gets or sets the name of the user for the target server. This user doesn't need to be an + administrator.""" + + @overload + def __init__( + self, + *, + admin_credentials: Optional["_models.AdminCredentialsForPatch"] = None, + source_server_username: Optional[str] = None, + target_server_username: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class MigrationStatus(_Model): + """State of migration. + + :ivar state: State of migration. Known values are: "InProgress", "WaitingForUserAction", + "Canceled", "Failed", "Succeeded", "ValidationFailed", and "CleaningUp". + :vartype state: str or ~azure.mgmt.postgresqlflexibleservers.models.MigrationState + :ivar error: Error message, if any, for the migration state. + :vartype error: str + :ivar current_sub_state_details: Current migration sub state details. + :vartype current_sub_state_details: + ~azure.mgmt.postgresqlflexibleservers.models.MigrationSubstateDetails + """ + + state: Optional[Union[str, "_models.MigrationState"]] = rest_field(visibility=["read"]) + """State of migration. Known values are: \"InProgress\", \"WaitingForUserAction\", \"Canceled\", + \"Failed\", \"Succeeded\", \"ValidationFailed\", and \"CleaningUp\".""" + error: Optional[str] = rest_field(visibility=["read"]) + """Error message, if any, for the migration state.""" + current_sub_state_details: Optional["_models.MigrationSubstateDetails"] = rest_field( + name="currentSubStateDetails", visibility=["read"] + ) + """Current migration sub state details.""" + + +class MigrationSubstateDetails(_Model): + """Details of migration substate. + + :ivar current_sub_state: Substate of migration. Known values are: + "PerformingPreRequisiteSteps", "WaitingForLogicalReplicationSetupRequestOnSourceDB", + "WaitingForDBsToMigrateSpecification", "WaitingForTargetDBOverwriteConfirmation", + "WaitingForDataMigrationScheduling", "WaitingForDataMigrationWindow", "MigratingData", + "WaitingForCutoverTrigger", "CompletingMigration", "Completed", + "CancelingRequestedDBMigrations", and "ValidationInProgress". + :vartype current_sub_state: str or + ~azure.mgmt.postgresqlflexibleservers.models.MigrationSubstate + :ivar db_details: + :vartype db_details: dict[str, + ~azure.mgmt.postgresqlflexibleservers.models.DatabaseMigrationState] + :ivar validation_details: + :vartype validation_details: ~azure.mgmt.postgresqlflexibleservers.models.ValidationDetails + """ + + current_sub_state: Optional[Union[str, "_models.MigrationSubstate"]] = rest_field( + name="currentSubState", visibility=["read"] + ) + """Substate of migration. Known values are: \"PerformingPreRequisiteSteps\", + \"WaitingForLogicalReplicationSetupRequestOnSourceDB\", + \"WaitingForDBsToMigrateSpecification\", \"WaitingForTargetDBOverwriteConfirmation\", + \"WaitingForDataMigrationScheduling\", \"WaitingForDataMigrationWindow\", \"MigratingData\", + \"WaitingForCutoverTrigger\", \"CompletingMigration\", \"Completed\", + \"CancelingRequestedDBMigrations\", and \"ValidationInProgress\".""" + db_details: Optional[dict[str, "_models.DatabaseMigrationState"]] = rest_field( + name="dbDetails", visibility=["read", "create", "update", "delete", "query"] + ) + validation_details: Optional["_models.ValidationDetails"] = rest_field( + name="validationDetails", visibility=["read", "create", "update", "delete", "query"] + ) + + @overload + def __init__( + self, + *, + db_details: Optional[dict[str, "_models.DatabaseMigrationState"]] = None, + validation_details: Optional["_models.ValidationDetails"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class NameAvailabilityModel(CheckNameAvailabilityResponse): + """Availability of a name. + + :ivar name_available: Indicates if the resource name is available. + :vartype name_available: bool + :ivar reason: The reason why the given name is not available. Known values are: "Invalid" and + "AlreadyExists". + :vartype reason: str or + ~azure.mgmt.postgresqlflexibleservers.models.CheckNameAvailabilityReason + :ivar message: Detailed reason why the given name is not available. + :vartype message: str + :ivar name: Name for which validity and availability was checked. + :vartype name: str + :ivar type: Type of resource. It can be 'Microsoft.DBforPostgreSQL/flexibleServers' or + 'Microsoft.DBforPostgreSQL/flexibleServers/virtualendpoints'. + :vartype type: str + """ + + name: Optional[str] = rest_field(visibility=["read"]) + """Name for which validity and availability was checked.""" + type: Optional[str] = rest_field(visibility=["read"]) + """Type of resource. It can be 'Microsoft.DBforPostgreSQL/flexibleServers' or + 'Microsoft.DBforPostgreSQL/flexibleServers/virtualendpoints'.""" + + @overload + def __init__( + self, + *, + name_available: Optional[bool] = None, + reason: Optional[Union[str, "_models.CheckNameAvailabilityReason"]] = None, + message: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class NameProperty(_Model): + """Name property for quota usage. + + :ivar value: Name value. + :vartype value: str + :ivar localized_value: Localized name. + :vartype localized_value: str + """ + + value: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Name value.""" + localized_value: Optional[str] = rest_field( + name="localizedValue", visibility=["read", "create", "update", "delete", "query"] + ) + """Localized name.""" + + @overload + def __init__( + self, + *, + value: Optional[str] = None, + localized_value: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class Network(_Model): + """Network properties of a server. + + :ivar public_network_access: Indicates if public network access is enabled or not. This is only + supported for servers that are not integrated into a virtual network which is owned and + provided by customer when server is deployed. Known values are: "Enabled" and "Disabled". + :vartype public_network_access: str or + ~azure.mgmt.postgresqlflexibleservers.models.ServerPublicNetworkAccessState + :ivar delegated_subnet_resource_id: Resource identifier of the delegated subnet. Required + during creation of a new server, in case you want the server to be integrated into your own + virtual network. For an update operation, you only have to provide this property if you want to + change the value assigned for the private DNS zone. + :vartype delegated_subnet_resource_id: str + :ivar private_dns_zone_arm_resource_id: Identifier of the private DNS zone. Required during + creation of a new server, in case you want the server to be integrated into your own virtual + network. For an update operation, you only have to provide this property if you want to change + the value assigned for the private DNS zone. + :vartype private_dns_zone_arm_resource_id: str + """ + + public_network_access: Optional[Union[str, "_models.ServerPublicNetworkAccessState"]] = rest_field( + name="publicNetworkAccess", visibility=["read", "create", "update", "delete", "query"] + ) + """Indicates if public network access is enabled or not. This is only supported for servers that + are not integrated into a virtual network which is owned and provided by customer when server + is deployed. Known values are: \"Enabled\" and \"Disabled\".""" + delegated_subnet_resource_id: Optional[str] = rest_field( + name="delegatedSubnetResourceId", visibility=["read", "create", "update", "delete", "query"] + ) + """Resource identifier of the delegated subnet. Required during creation of a new server, in case + you want the server to be integrated into your own virtual network. For an update operation, + you only have to provide this property if you want to change the value assigned for the private + DNS zone.""" + private_dns_zone_arm_resource_id: Optional[str] = rest_field( + name="privateDnsZoneArmResourceId", visibility=["read", "create", "update", "delete", "query"] + ) + """Identifier of the private DNS zone. Required during creation of a new server, in case you want + the server to be integrated into your own virtual network. For an update operation, you only + have to provide this property if you want to change the value assigned for the private DNS + zone.""" + + @overload + def __init__( + self, + *, + public_network_access: Optional[Union[str, "_models.ServerPublicNetworkAccessState"]] = None, + delegated_subnet_resource_id: Optional[str] = None, + private_dns_zone_arm_resource_id: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ObjectRecommendation(ProxyResource): + """Object recommendation properties. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.postgresqlflexibleservers.models.SystemData + :ivar kind: Always empty. + :vartype kind: str + :ivar properties: Properties of an object recommendation. + :vartype properties: + ~azure.mgmt.postgresqlflexibleservers.models.ObjectRecommendationProperties + """ + + kind: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Always empty.""" + properties: Optional["_models.ObjectRecommendationProperties"] = rest_field(visibility=["read"]) + """Properties of an object recommendation.""" + + __flattened_items = [ + "initial_recommended_time", + "last_recommended_time", + "times_recommended", + "improved_query_ids", + "recommendation_reason", + "current_state", + "recommendation_type", + "implementation_details", + "analyzed_workload", + "estimated_impact", + "details", + ] + + @overload + def __init__( + self, + *, + kind: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class ObjectRecommendationDetails(_Model): + """Recommendation details for the recommended action. + + :ivar database_name: Database name. + :vartype database_name: str + :ivar schema: Schema name. + :vartype schema: str + :ivar table: Table name. + :vartype table: str + :ivar index_type: Index type. + :vartype index_type: str + :ivar index_name: Index name. + :vartype index_name: str + :ivar index_columns: Index columns. + :vartype index_columns: list[str] + :ivar included_columns: Index included columns. + :vartype included_columns: list[str] + """ + + database_name: Optional[str] = rest_field( + name="databaseName", visibility=["read", "create", "update", "delete", "query"] + ) + """Database name.""" + schema: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Schema name.""" + table: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Table name.""" + index_type: Optional[str] = rest_field(name="indexType", visibility=["read", "create", "update", "delete", "query"]) + """Index type.""" + index_name: Optional[str] = rest_field(name="indexName", visibility=["read", "create", "update", "delete", "query"]) + """Index name.""" + index_columns: Optional[list[str]] = rest_field( + name="indexColumns", visibility=["read", "create", "update", "delete", "query"] + ) + """Index columns.""" + included_columns: Optional[list[str]] = rest_field( + name="includedColumns", visibility=["read", "create", "update", "delete", "query"] + ) + """Index included columns.""" + + @overload + def __init__( + self, + *, + database_name: Optional[str] = None, + schema: Optional[str] = None, + table: Optional[str] = None, + index_type: Optional[str] = None, + index_name: Optional[str] = None, + index_columns: Optional[list[str]] = None, + included_columns: Optional[list[str]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ObjectRecommendationProperties(_Model): + """Object recommendation properties. + + :ivar initial_recommended_time: Creation time (UTC) of this recommendation. + :vartype initial_recommended_time: ~datetime.datetime + :ivar last_recommended_time: Last time (UTC) that this recommendation was produced. + :vartype last_recommended_time: ~datetime.datetime + :ivar times_recommended: Number of times this recommendation has been produced. + :vartype times_recommended: int + :ivar improved_query_ids: List of identifiers for all queries identified as targets for + improvement if the recommendation is applied. The list is only populated for CREATE INDEX + recommendations. + :vartype improved_query_ids: list[int] + :ivar recommendation_reason: Reason for this recommendation. + :vartype recommendation_reason: str + :ivar current_state: Current state. + :vartype current_state: str + :ivar recommendation_type: Type for this recommendation. Known values are: "CreateIndex", + "DropIndex", "ReIndex", "AnalyzeTable", and "VacuumTable". + :vartype recommendation_type: str or + ~azure.mgmt.postgresqlflexibleservers.models.RecommendationTypeEnum + :ivar implementation_details: Implementation details for the recommended action. + :vartype implementation_details: + ~azure.mgmt.postgresqlflexibleservers.models.ObjectRecommendationPropertiesImplementationDetails + :ivar analyzed_workload: Workload information for the recommended action. + :vartype analyzed_workload: + ~azure.mgmt.postgresqlflexibleservers.models.ObjectRecommendationPropertiesAnalyzedWorkload + :ivar estimated_impact: Estimated impact of this recommended action. + :vartype estimated_impact: list[~azure.mgmt.postgresqlflexibleservers.models.ImpactRecord] + :ivar details: Recommendation details for the recommended action. + :vartype details: ~azure.mgmt.postgresqlflexibleservers.models.ObjectRecommendationDetails + """ + + initial_recommended_time: Optional[datetime.datetime] = rest_field( + name="initialRecommendedTime", visibility=["read", "create", "update", "delete", "query"], format="rfc3339" + ) + """Creation time (UTC) of this recommendation.""" + last_recommended_time: Optional[datetime.datetime] = rest_field( + name="lastRecommendedTime", visibility=["read", "create", "update", "delete", "query"], format="rfc3339" + ) + """Last time (UTC) that this recommendation was produced.""" + times_recommended: Optional[int] = rest_field( + name="timesRecommended", visibility=["read", "create", "update", "delete", "query"] + ) + """Number of times this recommendation has been produced.""" + improved_query_ids: Optional[list[int]] = rest_field( + name="improvedQueryIds", visibility=["read", "create", "update", "delete", "query"] + ) + """List of identifiers for all queries identified as targets for improvement if the recommendation + is applied. The list is only populated for CREATE INDEX recommendations.""" + recommendation_reason: Optional[str] = rest_field( + name="recommendationReason", visibility=["read", "create", "update", "delete", "query"] + ) + """Reason for this recommendation.""" + current_state: Optional[str] = rest_field( + name="currentState", visibility=["read", "create", "update", "delete", "query"] + ) + """Current state.""" + recommendation_type: Optional[Union[str, "_models.RecommendationTypeEnum"]] = rest_field( + name="recommendationType", visibility=["read", "create", "update", "delete", "query"] + ) + """Type for this recommendation. Known values are: \"CreateIndex\", \"DropIndex\", \"ReIndex\", + \"AnalyzeTable\", and \"VacuumTable\".""" + implementation_details: Optional["_models.ObjectRecommendationPropertiesImplementationDetails"] = rest_field( + name="implementationDetails", visibility=["read", "create", "update", "delete", "query"] + ) + """Implementation details for the recommended action.""" + analyzed_workload: Optional["_models.ObjectRecommendationPropertiesAnalyzedWorkload"] = rest_field( + name="analyzedWorkload", visibility=["read", "create", "update", "delete", "query"] + ) + """Workload information for the recommended action.""" + estimated_impact: Optional[list["_models.ImpactRecord"]] = rest_field(name="estimatedImpact", visibility=["read"]) + """Estimated impact of this recommended action.""" + details: Optional["_models.ObjectRecommendationDetails"] = rest_field(visibility=["read"]) + """Recommendation details for the recommended action.""" + + @overload + def __init__( + self, + *, + initial_recommended_time: Optional[datetime.datetime] = None, + last_recommended_time: Optional[datetime.datetime] = None, + times_recommended: Optional[int] = None, + improved_query_ids: Optional[list[int]] = None, + recommendation_reason: Optional[str] = None, + current_state: Optional[str] = None, + recommendation_type: Optional[Union[str, "_models.RecommendationTypeEnum"]] = None, + implementation_details: Optional["_models.ObjectRecommendationPropertiesImplementationDetails"] = None, + analyzed_workload: Optional["_models.ObjectRecommendationPropertiesAnalyzedWorkload"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ObjectRecommendationPropertiesAnalyzedWorkload(_Model): # pylint: disable=name-too-long + """Workload information for the recommended action. + + :ivar start_time: Start time (UTC) of the workload analyzed. + :vartype start_time: ~datetime.datetime + :ivar end_time: End time (UTC) of the workload analyzed. + :vartype end_time: ~datetime.datetime + :ivar query_count: Number of queries from the workload that were examined to produce this + recommendation. For DROP INDEX recommendations it's 0 (zero). + :vartype query_count: int + """ + + start_time: Optional[datetime.datetime] = rest_field( + name="startTime", visibility=["read", "create", "update", "delete", "query"], format="rfc3339" + ) + """Start time (UTC) of the workload analyzed.""" + end_time: Optional[datetime.datetime] = rest_field( + name="endTime", visibility=["read", "create", "update", "delete", "query"], format="rfc3339" + ) + """End time (UTC) of the workload analyzed.""" + query_count: Optional[int] = rest_field( + name="queryCount", visibility=["read", "create", "update", "delete", "query"] + ) + """Number of queries from the workload that were examined to produce this recommendation. For DROP + INDEX recommendations it's 0 (zero).""" + + @overload + def __init__( + self, + *, + start_time: Optional[datetime.datetime] = None, + end_time: Optional[datetime.datetime] = None, + query_count: Optional[int] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ObjectRecommendationPropertiesImplementationDetails(_Model): # pylint: disable=name-too-long + """Implementation details for the recommended action. + + :ivar method: Method of implementation for recommended action. + :vartype method: str + :ivar script: Implementation script for the recommended action. + :vartype script: str + """ + + method: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Method of implementation for recommended action.""" + script: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Implementation script for the recommended action.""" + + @overload + def __init__( + self, + *, + method: Optional[str] = None, + script: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class Operation(_Model): + """REST API operation definition. + + :ivar name: Name of the operation being performed on this particular object. + :vartype name: str + :ivar display: Localized display information for this particular operation or action. + :vartype display: ~azure.mgmt.postgresqlflexibleservers.models.OperationDisplay + :ivar is_data_action: Indicates if the operation is a data action. + :vartype is_data_action: bool + :ivar origin: Intended executor of the operation. Known values are: "NotSpecified", "user", and + "system". + :vartype origin: str or ~azure.mgmt.postgresqlflexibleservers.models.OperationOrigin + :ivar properties: Additional descriptions for the operation. + :vartype properties: ~azure.mgmt.postgresqlflexibleservers.models.OperationProperties + """ + + name: Optional[str] = rest_field(visibility=["read"]) + """Name of the operation being performed on this particular object.""" + display: Optional["_models.OperationDisplay"] = rest_field(visibility=["read"]) + """Localized display information for this particular operation or action.""" + is_data_action: Optional[bool] = rest_field( + name="isDataAction", visibility=["read", "create", "update", "delete", "query"] + ) + """Indicates if the operation is a data action.""" + origin: Optional[Union[str, "_models.OperationOrigin"]] = rest_field(visibility=["read"]) + """Intended executor of the operation. Known values are: \"NotSpecified\", \"user\", and + \"system\".""" + properties: Optional["_models.OperationProperties"] = rest_field(visibility=["read"]) + """Additional descriptions for the operation.""" + + @overload + def __init__( + self, + *, + is_data_action: Optional[bool] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class OperationDisplay(_Model): + """Display metadata associated with the operation. + + :ivar provider: Name of the resource provider. + :vartype provider: str + :ivar resource: Type of resource on which the operation is performed. + :vartype resource: str + :ivar operation: Name of the operation. + :vartype operation: str + :ivar description: Description of the operation. + :vartype description: str + """ + + provider: Optional[str] = rest_field(visibility=["read"]) + """Name of the resource provider.""" + resource: Optional[str] = rest_field(visibility=["read"]) + """Type of resource on which the operation is performed.""" + operation: Optional[str] = rest_field(visibility=["read"]) + """Name of the operation.""" + description: Optional[str] = rest_field(visibility=["read"]) + """Description of the operation.""" + + +class OperationProperties(_Model): + """Additional properties for operation metadata. + + :ivar service_specification: Service specification for the operation. + :vartype service_specification: + ~azure.mgmt.postgresqlflexibleservers.models.ServiceSpecification + """ + + service_specification: Optional["_models.ServiceSpecification"] = rest_field( + name="serviceSpecification", visibility=["read", "create", "update", "delete", "query"] + ) + """Service specification for the operation.""" + + @overload + def __init__( + self, + *, + service_specification: Optional["_models.ServiceSpecification"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class PrivateEndpoint(_Model): + """The private endpoint resource. + + :ivar id: The resource identifier of the private endpoint. + :vartype id: str + """ + + id: Optional[str] = rest_field(visibility=["read"]) + """The resource identifier of the private endpoint.""" + + +class PrivateEndpointConnection(Resource): + """The private endpoint connection resource. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.postgresqlflexibleservers.models.SystemData + :ivar properties: Resource properties. + :vartype properties: + ~azure.mgmt.postgresqlflexibleservers.models.PrivateEndpointConnectionProperties + """ + + properties: Optional["_models.PrivateEndpointConnectionProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Resource properties.""" + + __flattened_items = ["group_ids", "private_endpoint", "private_link_service_connection_state", "provisioning_state"] + + @overload + def __init__( + self, + *, + properties: Optional["_models.PrivateEndpointConnectionProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class PrivateEndpointConnectionProperties(_Model): + """Properties of the private endpoint connection. + + :ivar group_ids: The group ids for the private endpoint resource. + :vartype group_ids: list[str] + :ivar private_endpoint: The private endpoint resource. + :vartype private_endpoint: ~azure.mgmt.postgresqlflexibleservers.models.PrivateEndpoint + :ivar private_link_service_connection_state: A collection of information about the state of the + connection between service consumer and provider. Required. + :vartype private_link_service_connection_state: + ~azure.mgmt.postgresqlflexibleservers.models.PrivateLinkServiceConnectionState + :ivar provisioning_state: The provisioning state of the private endpoint connection resource. + Known values are: "Succeeded", "Creating", "Deleting", and "Failed". + :vartype provisioning_state: str or + ~azure.mgmt.postgresqlflexibleservers.models.PrivateEndpointConnectionProvisioningState + """ + + group_ids: Optional[list[str]] = rest_field(name="groupIds", visibility=["read"]) + """The group ids for the private endpoint resource.""" + private_endpoint: Optional["_models.PrivateEndpoint"] = rest_field( + name="privateEndpoint", visibility=["read", "create", "update", "delete", "query"] + ) + """The private endpoint resource.""" + private_link_service_connection_state: "_models.PrivateLinkServiceConnectionState" = rest_field( + name="privateLinkServiceConnectionState", visibility=["read", "create", "update", "delete", "query"] + ) + """A collection of information about the state of the connection between service consumer and + provider. Required.""" + provisioning_state: Optional[Union[str, "_models.PrivateEndpointConnectionProvisioningState"]] = rest_field( + name="provisioningState", visibility=["read"] + ) + """The provisioning state of the private endpoint connection resource. Known values are: + \"Succeeded\", \"Creating\", \"Deleting\", and \"Failed\".""" + + @overload + def __init__( + self, + *, + private_link_service_connection_state: "_models.PrivateLinkServiceConnectionState", + private_endpoint: Optional["_models.PrivateEndpoint"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class PrivateLinkResource(ProxyResource): + """A private link resource. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.postgresqlflexibleservers.models.SystemData + :ivar properties: Resource properties. + :vartype properties: ~azure.mgmt.postgresqlflexibleservers.models.PrivateLinkResourceProperties + """ + + properties: Optional["_models.PrivateLinkResourceProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Resource properties.""" + + __flattened_items = ["group_id", "required_members", "required_zone_names"] + + @overload + def __init__( + self, + *, + properties: Optional["_models.PrivateLinkResourceProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class PrivateLinkResourceProperties(_Model): + """Properties of a private link resource. + + :ivar group_id: The private link resource group id. + :vartype group_id: str + :ivar required_members: The private link resource required member names. + :vartype required_members: list[str] + :ivar required_zone_names: The private link resource private link DNS zone name. + :vartype required_zone_names: list[str] + """ + + group_id: Optional[str] = rest_field(name="groupId", visibility=["read"]) + """The private link resource group id.""" + required_members: Optional[list[str]] = rest_field(name="requiredMembers", visibility=["read"]) + """The private link resource required member names.""" + required_zone_names: Optional[list[str]] = rest_field( + name="requiredZoneNames", visibility=["read", "create", "update", "delete", "query"] + ) + """The private link resource private link DNS zone name.""" + + @overload + def __init__( + self, + *, + required_zone_names: Optional[list[str]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class PrivateLinkServiceConnectionState(_Model): + """A collection of information about the state of the connection between service consumer and + provider. + + :ivar status: Indicates whether the connection has been Approved/Rejected/Removed by the owner + of the service. Known values are: "Pending", "Approved", and "Rejected". + :vartype status: str or + ~azure.mgmt.postgresqlflexibleservers.models.PrivateEndpointServiceConnectionStatus + :ivar description: The reason for approval/rejection of the connection. + :vartype description: str + :ivar actions_required: A message indicating if changes on the service provider require any + updates on the consumer. + :vartype actions_required: str + """ + + status: Optional[Union[str, "_models.PrivateEndpointServiceConnectionStatus"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Indicates whether the connection has been Approved/Rejected/Removed by the owner of the + service. Known values are: \"Pending\", \"Approved\", and \"Rejected\".""" + description: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The reason for approval/rejection of the connection.""" + actions_required: Optional[str] = rest_field( + name="actionsRequired", visibility=["read", "create", "update", "delete", "query"] + ) + """A message indicating if changes on the service provider require any updates on the consumer.""" + + @overload + def __init__( + self, + *, + status: Optional[Union[str, "_models.PrivateEndpointServiceConnectionStatus"]] = None, + description: Optional[str] = None, + actions_required: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class QuotaUsage(_Model): + """Quota usage for servers. + + :ivar name: Name of quota usage for servers. + :vartype name: ~azure.mgmt.postgresqlflexibleservers.models.NameProperty + :ivar limit: Quota limit. + :vartype limit: int + :ivar unit: Quota unit. + :vartype unit: str + :ivar current_value: Current Quota usage value. + :vartype current_value: int + :ivar id: Fully qualified ARM resource Id. + :vartype id: str + """ + + name: Optional["_models.NameProperty"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Name of quota usage for servers.""" + limit: Optional[int] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Quota limit.""" + unit: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Quota unit.""" + current_value: Optional[int] = rest_field( + name="currentValue", visibility=["read", "create", "update", "delete", "query"] + ) + """Current Quota usage value.""" + id: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Fully qualified ARM resource Id.""" + + @overload + def __init__( + self, + *, + name: Optional["_models.NameProperty"] = None, + limit: Optional[int] = None, + unit: Optional[str] = None, + current_value: Optional[int] = None, + id: Optional[str] = None, # pylint: disable=redefined-builtin + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class Replica(_Model): + """Replica properties of a server. + + :ivar role: Role of the server in a replication set. Known values are: "None", "Primary", + "AsyncReplica", and "GeoAsyncReplica". + :vartype role: str or ~azure.mgmt.postgresqlflexibleservers.models.ReplicationRole + :ivar capacity: Maximum number of read replicas allowed for a server. + :vartype capacity: int + :ivar replication_state: Indicates the replication state of a read replica. This property is + returned only when the target server is a read replica. Possible values are Active, Broken, + Catchup, Provisioning, Reconfiguring, and Updating. Known values are: "Active", "Catchup", + "Provisioning", "Updating", "Broken", and "Reconfiguring". + :vartype replication_state: str or + ~azure.mgmt.postgresqlflexibleservers.models.ReplicationState + :ivar promote_mode: Type of operation to apply on the read replica. This property is write + only. Standalone means that the read replica will be promoted to a standalone server, and will + become a completely independent entity from the replication set. Switchover means that the read + replica will roles with the primary server. Known values are: "Standalone" and "Switchover". + :vartype promote_mode: str or + ~azure.mgmt.postgresqlflexibleservers.models.ReadReplicaPromoteMode + :ivar promote_option: Data synchronization option to use when processing the operation + specified in the promoteMode property. This property is write only. Known values are: "Planned" + and "Forced". + :vartype promote_option: str or + ~azure.mgmt.postgresqlflexibleservers.models.ReadReplicaPromoteOption + """ + + role: Optional[Union[str, "_models.ReplicationRole"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Role of the server in a replication set. Known values are: \"None\", \"Primary\", + \"AsyncReplica\", and \"GeoAsyncReplica\".""" + capacity: Optional[int] = rest_field(visibility=["read"]) + """Maximum number of read replicas allowed for a server.""" + replication_state: Optional[Union[str, "_models.ReplicationState"]] = rest_field( + name="replicationState", visibility=["read"] + ) + """Indicates the replication state of a read replica. This property is returned only when the + target server is a read replica. Possible values are Active, Broken, Catchup, Provisioning, + Reconfiguring, and Updating. Known values are: \"Active\", \"Catchup\", \"Provisioning\", + \"Updating\", \"Broken\", and \"Reconfiguring\".""" + promote_mode: Optional[Union[str, "_models.ReadReplicaPromoteMode"]] = rest_field( + name="promoteMode", visibility=["update"] + ) + """Type of operation to apply on the read replica. This property is write only. Standalone means + that the read replica will be promoted to a standalone server, and will become a completely + independent entity from the replication set. Switchover means that the read replica will roles + with the primary server. Known values are: \"Standalone\" and \"Switchover\".""" + promote_option: Optional[Union[str, "_models.ReadReplicaPromoteOption"]] = rest_field( + name="promoteOption", visibility=["update"] + ) + """Data synchronization option to use when processing the operation specified in the promoteMode + property. This property is write only. Known values are: \"Planned\" and \"Forced\".""" + + @overload + def __init__( + self, + *, + role: Optional[Union[str, "_models.ReplicationRole"]] = None, + promote_mode: Optional[Union[str, "_models.ReadReplicaPromoteMode"]] = None, + promote_option: Optional[Union[str, "_models.ReadReplicaPromoteOption"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class RestartParameter(_Model): + """PostgreSQL database engine restart parameters. + + :ivar restart_with_failover: Indicates if restart the PostgreSQL database engine should + failover or switch over from primary to standby. This only works if server has high + availability enabled. + :vartype restart_with_failover: bool + :ivar failover_mode: Failover mode. Known values are: "PlannedFailover", "ForcedFailover", + "PlannedSwitchover", and "ForcedSwitchover". + :vartype failover_mode: str or ~azure.mgmt.postgresqlflexibleservers.models.FailoverMode + """ + + restart_with_failover: Optional[bool] = rest_field( + name="restartWithFailover", visibility=["read", "create", "update", "delete", "query"] + ) + """Indicates if restart the PostgreSQL database engine should failover or switch over from primary + to standby. This only works if server has high availability enabled.""" + failover_mode: Optional[Union[str, "_models.FailoverMode"]] = rest_field( + name="failoverMode", visibility=["read", "create", "update", "delete", "query"] + ) + """Failover mode. Known values are: \"PlannedFailover\", \"ForcedFailover\", + \"PlannedSwitchover\", and \"ForcedSwitchover\".""" + + @overload + def __init__( + self, + *, + restart_with_failover: Optional[bool] = None, + failover_mode: Optional[Union[str, "_models.FailoverMode"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class Server(TrackedResource): + """Properties of a server. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.postgresqlflexibleservers.models.SystemData + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + :ivar location: The geo-location where the resource lives. Required. + :vartype location: str + :ivar properties: Properties of a server. + :vartype properties: ~azure.mgmt.postgresqlflexibleservers.models.ServerProperties + :ivar sku: Compute tier and size of a server. + :vartype sku: ~azure.mgmt.postgresqlflexibleservers.models.Sku + :ivar identity: User assigned managed identities assigned to the server. + :vartype identity: ~azure.mgmt.postgresqlflexibleservers.models.UserAssignedIdentity + """ + + properties: Optional["_models.ServerProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Properties of a server.""" + sku: Optional["_models.Sku"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Compute tier and size of a server.""" + identity: Optional["_models.UserAssignedIdentity"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """User assigned managed identities assigned to the server.""" + + __flattened_items = [ + "administrator_login", + "administrator_login_password", + "version", + "minor_version", + "state", + "fully_qualified_domain_name", + "storage", + "auth_config", + "data_encryption", + "backup", + "network", + "high_availability", + "maintenance_window", + "source_server_resource_id", + "point_in_time_utc", + "availability_zone", + "replication_role", + "replica_capacity", + "replica", + "create_mode", + "private_endpoint_connections", + "cluster", + ] + + @overload + def __init__( + self, + *, + location: str, + tags: Optional[dict[str, str]] = None, + properties: Optional["_models.ServerProperties"] = None, + sku: Optional["_models.Sku"] = None, + identity: Optional["_models.UserAssignedIdentity"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class ServerEditionCapability(CapabilityBase): + """Capabilities in terms of compute tier. + + :ivar status: The status of the capability. Known values are: "Visible", "Available", + "Default", and "Disabled". + :vartype status: str or ~azure.mgmt.postgresqlflexibleservers.models.CapabilityStatus + :ivar reason: The reason for the capability not being available. + :vartype reason: str + :ivar name: Name of compute tier. + :vartype name: str + :ivar default_sku_name: Default compute name (SKU) for this computer tier. + :vartype default_sku_name: str + :ivar supported_storage_editions: List of storage editions supported by this compute tier and + compute name. + :vartype supported_storage_editions: + list[~azure.mgmt.postgresqlflexibleservers.models.StorageEditionCapability] + :ivar supported_server_skus: List of supported compute names (SKUs). + :vartype supported_server_skus: + list[~azure.mgmt.postgresqlflexibleservers.models.ServerSkuCapability] + """ + + name: Optional[str] = rest_field(visibility=["read"]) + """Name of compute tier.""" + default_sku_name: Optional[str] = rest_field(name="defaultSkuName", visibility=["read"]) + """Default compute name (SKU) for this computer tier.""" + supported_storage_editions: Optional[list["_models.StorageEditionCapability"]] = rest_field( + name="supportedStorageEditions", visibility=["read"] + ) + """List of storage editions supported by this compute tier and compute name.""" + supported_server_skus: Optional[list["_models.ServerSkuCapability"]] = rest_field( + name="supportedServerSkus", visibility=["read"] + ) + """List of supported compute names (SKUs).""" + + +class ServerForPatch(_Model): + """Represents a server to be updated. + + :ivar sku: Compute tier and size of a server. + :vartype sku: ~azure.mgmt.postgresqlflexibleservers.models.SkuForPatch + :ivar identity: Describes the identity of the application. + :vartype identity: ~azure.mgmt.postgresqlflexibleservers.models.UserAssignedIdentity + :ivar properties: Properties of the server. + :vartype properties: ~azure.mgmt.postgresqlflexibleservers.models.ServerPropertiesForPatch + :ivar tags: Application-specific metadata in the form of key-value pairs. + :vartype tags: dict[str, str] + """ + + sku: Optional["_models.SkuForPatch"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Compute tier and size of a server.""" + identity: Optional["_models.UserAssignedIdentity"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Describes the identity of the application.""" + properties: Optional["_models.ServerPropertiesForPatch"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Properties of the server.""" + tags: Optional[dict[str, str]] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Application-specific metadata in the form of key-value pairs.""" + + __flattened_items = [ + "administrator_login", + "administrator_login_password", + "version", + "storage", + "backup", + "high_availability", + "maintenance_window", + "auth_config", + "data_encryption", + "availability_zone", + "create_mode", + "replication_role", + "replica", + "network", + "cluster", + ] + + @overload + def __init__( + self, + *, + sku: Optional["_models.SkuForPatch"] = None, + identity: Optional["_models.UserAssignedIdentity"] = None, + properties: Optional["_models.ServerPropertiesForPatch"] = None, + tags: Optional[dict[str, str]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class ServerProperties(_Model): + """Properties of a server. + + :ivar administrator_login: Name of the login designated as the first password based + administrator assigned to your instance of PostgreSQL. Must be specified the first time that + you enable password based authentication on a server. Once set to a given value, it cannot be + changed for the rest of the life of a server. If you disable password based authentication on a + server which had it enabled, this password based role isn't deleted. + :vartype administrator_login: str + :ivar administrator_login_password: Password assigned to the administrator login. As long as + password authentication is enabled, this password can be changed at any time. + :vartype administrator_login_password: str + :ivar version: Major version of PostgreSQL database engine. Known values are: "18", "17", "16", + "15", "14", "13", "12", and "11". + :vartype version: str or ~azure.mgmt.postgresqlflexibleservers.models.PostgresMajorVersion + :ivar minor_version: Minor version of PostgreSQL database engine. + :vartype minor_version: str + :ivar state: Possible states of a server. Known values are: "Ready", "Dropping", "Disabled", + "Starting", "Stopping", "Stopped", "Updating", "Restarting", "Inaccessible", and + "Provisioning". + :vartype state: str or ~azure.mgmt.postgresqlflexibleservers.models.ServerState + :ivar fully_qualified_domain_name: Fully qualified domain name of a server. + :vartype fully_qualified_domain_name: str + :ivar storage: Storage properties of a server. + :vartype storage: ~azure.mgmt.postgresqlflexibleservers.models.Storage + :ivar auth_config: Authentication configuration properties of a server. + :vartype auth_config: ~azure.mgmt.postgresqlflexibleservers.models.AuthConfig + :ivar data_encryption: Data encryption properties of a server. + :vartype data_encryption: ~azure.mgmt.postgresqlflexibleservers.models.DataEncryption + :ivar backup: Backup properties of a server. + :vartype backup: ~azure.mgmt.postgresqlflexibleservers.models.Backup + :ivar network: Network properties of a server. Only required if you want your server to be + integrated into a virtual network provided by customer. + :vartype network: ~azure.mgmt.postgresqlflexibleservers.models.Network + :ivar high_availability: High availability properties of a server. + :vartype high_availability: ~azure.mgmt.postgresqlflexibleservers.models.HighAvailability + :ivar maintenance_window: Maintenance window properties of a server. + :vartype maintenance_window: ~azure.mgmt.postgresqlflexibleservers.models.MaintenanceWindow + :ivar source_server_resource_id: Identifier of the server to be used as the source of the new + server. Required when 'createMode' is 'PointInTimeRestore', 'GeoRestore', 'Replica', or + 'ReviveDropped'. This property is returned only when the target server is a read replica. + :vartype source_server_resource_id: str + :ivar point_in_time_utc: Creation time (in ISO8601 format) of the backup which you want to + restore in the new server. It's required when 'createMode' is 'PointInTimeRestore', + 'GeoRestore', or 'ReviveDropped'. + :vartype point_in_time_utc: ~datetime.datetime + :ivar availability_zone: Availability zone of a server. + :vartype availability_zone: str + :ivar replication_role: Role of the server in a replication set. Known values are: "None", + "Primary", "AsyncReplica", and "GeoAsyncReplica". + :vartype replication_role: str or ~azure.mgmt.postgresqlflexibleservers.models.ReplicationRole + :ivar replica_capacity: Maximum number of read replicas allowed for a server. + :vartype replica_capacity: int + :ivar replica: Read replica properties of a server. Required only in case that you want to + promote a server. + :vartype replica: ~azure.mgmt.postgresqlflexibleservers.models.Replica + :ivar create_mode: Creation mode of a new server. Known values are: "Default", "Create", + "Update", "PointInTimeRestore", "GeoRestore", "Replica", and "ReviveDropped". + :vartype create_mode: str or ~azure.mgmt.postgresqlflexibleservers.models.CreateMode + :ivar private_endpoint_connections: List of private endpoint connections associated with the + specified server. + :vartype private_endpoint_connections: + list[~azure.mgmt.postgresqlflexibleservers.models.PrivateEndpointConnection] + :ivar cluster: Cluster properties of a server. + :vartype cluster: ~azure.mgmt.postgresqlflexibleservers.models.Cluster + """ + + administrator_login: Optional[str] = rest_field(name="administratorLogin", visibility=["read", "create"]) + """Name of the login designated as the first password based administrator assigned to your + instance of PostgreSQL. Must be specified the first time that you enable password based + authentication on a server. Once set to a given value, it cannot be changed for the rest of the + life of a server. If you disable password based authentication on a server which had it + enabled, this password based role isn't deleted.""" + administrator_login_password: Optional[str] = rest_field( + name="administratorLoginPassword", visibility=["create", "update"] + ) + """Password assigned to the administrator login. As long as password authentication is enabled, + this password can be changed at any time.""" + version: Optional[Union[str, "_models.PostgresMajorVersion"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Major version of PostgreSQL database engine. Known values are: \"18\", \"17\", \"16\", \"15\", + \"14\", \"13\", \"12\", and \"11\".""" + minor_version: Optional[str] = rest_field(name="minorVersion", visibility=["read"]) + """Minor version of PostgreSQL database engine.""" + state: Optional[Union[str, "_models.ServerState"]] = rest_field(visibility=["read"]) + """Possible states of a server. Known values are: \"Ready\", \"Dropping\", \"Disabled\", + \"Starting\", \"Stopping\", \"Stopped\", \"Updating\", \"Restarting\", \"Inaccessible\", and + \"Provisioning\".""" + fully_qualified_domain_name: Optional[str] = rest_field(name="fullyQualifiedDomainName", visibility=["read"]) + """Fully qualified domain name of a server.""" + storage: Optional["_models.Storage"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Storage properties of a server.""" + auth_config: Optional["_models.AuthConfig"] = rest_field( + name="authConfig", visibility=["read", "create", "update", "delete", "query"] + ) + """Authentication configuration properties of a server.""" + data_encryption: Optional["_models.DataEncryption"] = rest_field( + name="dataEncryption", visibility=["read", "create", "update", "delete", "query"] + ) + """Data encryption properties of a server.""" + backup: Optional["_models.Backup"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Backup properties of a server.""" + network: Optional["_models.Network"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Network properties of a server. Only required if you want your server to be integrated into a + virtual network provided by customer.""" + high_availability: Optional["_models.HighAvailability"] = rest_field( + name="highAvailability", visibility=["read", "create", "update", "delete", "query"] + ) + """High availability properties of a server.""" + maintenance_window: Optional["_models.MaintenanceWindow"] = rest_field( + name="maintenanceWindow", visibility=["read", "update"] + ) + """Maintenance window properties of a server.""" + source_server_resource_id: Optional[str] = rest_field(name="sourceServerResourceId", visibility=["read", "create"]) + """Identifier of the server to be used as the source of the new server. Required when 'createMode' + is 'PointInTimeRestore', 'GeoRestore', 'Replica', or 'ReviveDropped'. This property is returned + only when the target server is a read replica.""" + point_in_time_utc: Optional[datetime.datetime] = rest_field( + name="pointInTimeUTC", visibility=["create"], format="rfc3339" + ) + """Creation time (in ISO8601 format) of the backup which you want to restore in the new server. + It's required when 'createMode' is 'PointInTimeRestore', 'GeoRestore', or 'ReviveDropped'.""" + availability_zone: Optional[str] = rest_field(name="availabilityZone", visibility=["read", "create"]) + """Availability zone of a server.""" + replication_role: Optional[Union[str, "_models.ReplicationRole"]] = rest_field( + name="replicationRole", visibility=["read", "create", "update", "delete", "query"] + ) + """Role of the server in a replication set. Known values are: \"None\", \"Primary\", + \"AsyncReplica\", and \"GeoAsyncReplica\".""" + replica_capacity: Optional[int] = rest_field(name="replicaCapacity", visibility=["read"]) + """Maximum number of read replicas allowed for a server.""" + replica: Optional["_models.Replica"] = rest_field(visibility=["read", "update"]) + """Read replica properties of a server. Required only in case that you want to promote a server.""" + create_mode: Optional[Union[str, "_models.CreateMode"]] = rest_field( + name="createMode", visibility=["create", "update"] + ) + """Creation mode of a new server. Known values are: \"Default\", \"Create\", \"Update\", + \"PointInTimeRestore\", \"GeoRestore\", \"Replica\", and \"ReviveDropped\".""" + private_endpoint_connections: Optional[list["_models.PrivateEndpointConnection"]] = rest_field( + name="privateEndpointConnections", visibility=["read"] + ) + """List of private endpoint connections associated with the specified server.""" + cluster: Optional["_models.Cluster"] = rest_field(visibility=["read", "create", "update"]) + """Cluster properties of a server.""" + + @overload + def __init__( + self, + *, + administrator_login: Optional[str] = None, + administrator_login_password: Optional[str] = None, + version: Optional[Union[str, "_models.PostgresMajorVersion"]] = None, + storage: Optional["_models.Storage"] = None, + auth_config: Optional["_models.AuthConfig"] = None, + data_encryption: Optional["_models.DataEncryption"] = None, + backup: Optional["_models.Backup"] = None, + network: Optional["_models.Network"] = None, + high_availability: Optional["_models.HighAvailability"] = None, + maintenance_window: Optional["_models.MaintenanceWindow"] = None, + source_server_resource_id: Optional[str] = None, + point_in_time_utc: Optional[datetime.datetime] = None, + availability_zone: Optional[str] = None, + replication_role: Optional[Union[str, "_models.ReplicationRole"]] = None, + replica: Optional["_models.Replica"] = None, + create_mode: Optional[Union[str, "_models.CreateMode"]] = None, + cluster: Optional["_models.Cluster"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ServerPropertiesForPatch(_Model): + """Properties of a server. + + :ivar administrator_login: Name of the login designated as the first password based + administrator assigned to your instance of PostgreSQL. Must be specified the first time that + you enable password based authentication on a server. Once set to a given value, it cannot be + changed for the rest of the life of a server. If you disable password based authentication on a + server which had it enabled, this password based role isn't deleted. + :vartype administrator_login: str + :ivar administrator_login_password: Password assigned to the administrator login. As long as + password authentication is enabled, this password can be changed at any time. + :vartype administrator_login_password: str + :ivar version: Major version of PostgreSQL database engine. Known values are: "18", "17", "16", + "15", "14", "13", "12", and "11". + :vartype version: str or ~azure.mgmt.postgresqlflexibleservers.models.PostgresMajorVersion + :ivar storage: Storage properties of a server. + :vartype storage: ~azure.mgmt.postgresqlflexibleservers.models.Storage + :ivar backup: Backup properties of a server. + :vartype backup: ~azure.mgmt.postgresqlflexibleservers.models.BackupForPatch + :ivar high_availability: High availability properties of a server. + :vartype high_availability: + ~azure.mgmt.postgresqlflexibleservers.models.HighAvailabilityForPatch + :ivar maintenance_window: Maintenance window properties of a server. + :vartype maintenance_window: + ~azure.mgmt.postgresqlflexibleservers.models.MaintenanceWindowForPatch + :ivar auth_config: Authentication configuration properties of a server. + :vartype auth_config: ~azure.mgmt.postgresqlflexibleservers.models.AuthConfigForPatch + :ivar data_encryption: Data encryption properties of a server. + :vartype data_encryption: ~azure.mgmt.postgresqlflexibleservers.models.DataEncryption + :ivar availability_zone: Availability zone of a server. + :vartype availability_zone: str + :ivar create_mode: Update mode of an existing server. Known values are: "Default" and "Update". + :vartype create_mode: str or ~azure.mgmt.postgresqlflexibleservers.models.CreateModeForPatch + :ivar replication_role: Role of the server in a replication set. Known values are: "None", + "Primary", "AsyncReplica", and "GeoAsyncReplica". + :vartype replication_role: str or ~azure.mgmt.postgresqlflexibleservers.models.ReplicationRole + :ivar replica: Read replica properties of a server. Required only in case that you want to + promote a server. + :vartype replica: ~azure.mgmt.postgresqlflexibleservers.models.Replica + :ivar network: Network properties of a server. Only required if you want your server to be + integrated into a virtual network provided by customer. + :vartype network: ~azure.mgmt.postgresqlflexibleservers.models.Network + :ivar cluster: Cluster properties of a server. + :vartype cluster: ~azure.mgmt.postgresqlflexibleservers.models.Cluster + """ + + administrator_login: Optional[str] = rest_field(name="administratorLogin", visibility=["read"]) + """Name of the login designated as the first password based administrator assigned to your + instance of PostgreSQL. Must be specified the first time that you enable password based + authentication on a server. Once set to a given value, it cannot be changed for the rest of the + life of a server. If you disable password based authentication on a server which had it + enabled, this password based role isn't deleted.""" + administrator_login_password: Optional[str] = rest_field(name="administratorLoginPassword", visibility=["update"]) + """Password assigned to the administrator login. As long as password authentication is enabled, + this password can be changed at any time.""" + version: Optional[Union[str, "_models.PostgresMajorVersion"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Major version of PostgreSQL database engine. Known values are: \"18\", \"17\", \"16\", \"15\", + \"14\", \"13\", \"12\", and \"11\".""" + storage: Optional["_models.Storage"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Storage properties of a server.""" + backup: Optional["_models.BackupForPatch"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Backup properties of a server.""" + high_availability: Optional["_models.HighAvailabilityForPatch"] = rest_field( + name="highAvailability", visibility=["read", "create", "update", "delete", "query"] + ) + """High availability properties of a server.""" + maintenance_window: Optional["_models.MaintenanceWindowForPatch"] = rest_field( + name="maintenanceWindow", visibility=["read", "update"] + ) + """Maintenance window properties of a server.""" + auth_config: Optional["_models.AuthConfigForPatch"] = rest_field( + name="authConfig", visibility=["read", "create", "update", "delete", "query"] + ) + """Authentication configuration properties of a server.""" + data_encryption: Optional["_models.DataEncryption"] = rest_field( + name="dataEncryption", visibility=["read", "create", "update", "delete", "query"] + ) + """Data encryption properties of a server.""" + availability_zone: Optional[str] = rest_field( + name="availabilityZone", visibility=["read", "create", "update", "delete", "query"] + ) + """Availability zone of a server.""" + create_mode: Optional[Union[str, "_models.CreateModeForPatch"]] = rest_field( + name="createMode", visibility=["update"] + ) + """Update mode of an existing server. Known values are: \"Default\" and \"Update\".""" + replication_role: Optional[Union[str, "_models.ReplicationRole"]] = rest_field( + name="replicationRole", visibility=["read", "create", "update", "delete", "query"] + ) + """Role of the server in a replication set. Known values are: \"None\", \"Primary\", + \"AsyncReplica\", and \"GeoAsyncReplica\".""" + replica: Optional["_models.Replica"] = rest_field(visibility=["read", "update"]) + """Read replica properties of a server. Required only in case that you want to promote a server.""" + network: Optional["_models.Network"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Network properties of a server. Only required if you want your server to be integrated into a + virtual network provided by customer.""" + cluster: Optional["_models.Cluster"] = rest_field(visibility=["read", "update"]) + """Cluster properties of a server.""" + + @overload + def __init__( + self, + *, + administrator_login_password: Optional[str] = None, + version: Optional[Union[str, "_models.PostgresMajorVersion"]] = None, + storage: Optional["_models.Storage"] = None, + backup: Optional["_models.BackupForPatch"] = None, + high_availability: Optional["_models.HighAvailabilityForPatch"] = None, + maintenance_window: Optional["_models.MaintenanceWindowForPatch"] = None, + auth_config: Optional["_models.AuthConfigForPatch"] = None, + data_encryption: Optional["_models.DataEncryption"] = None, + availability_zone: Optional[str] = None, + create_mode: Optional[Union[str, "_models.CreateModeForPatch"]] = None, + replication_role: Optional[Union[str, "_models.ReplicationRole"]] = None, + replica: Optional["_models.Replica"] = None, + network: Optional["_models.Network"] = None, + cluster: Optional["_models.Cluster"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ServerSku(_Model): + """Compute information of a server. + + :ivar name: Compute tier and size of the database server. This object is empty for an Azure + Database for PostgreSQL single server. + :vartype name: str + :ivar tier: Tier of the compute assigned to a server. Known values are: "Burstable", + "GeneralPurpose", and "MemoryOptimized". + :vartype tier: str or ~azure.mgmt.postgresqlflexibleservers.models.SkuTier + """ + + name: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Compute tier and size of the database server. This object is empty for an Azure Database for + PostgreSQL single server.""" + tier: Optional[Union[str, "_models.SkuTier"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Tier of the compute assigned to a server. Known values are: \"Burstable\", \"GeneralPurpose\", + and \"MemoryOptimized\".""" + + @overload + def __init__( + self, + *, + name: Optional[str] = None, + tier: Optional[Union[str, "_models.SkuTier"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ServerSkuCapability(CapabilityBase): + """Capabilities in terms of compute. + + :ivar status: The status of the capability. Known values are: "Visible", "Available", + "Default", and "Disabled". + :vartype status: str or ~azure.mgmt.postgresqlflexibleservers.models.CapabilityStatus + :ivar reason: The reason for the capability not being available. + :vartype reason: str + :ivar name: Name of the compute (SKU). + :vartype name: str + :ivar v_cores: vCores available for this compute. + :vartype v_cores: int + :ivar supported_iops: Maximum IOPS supported by this compute. + :vartype supported_iops: int + :ivar supported_memory_per_vcore_mb: Supported memory (in MB) per virtual core assigned to this + compute. + :vartype supported_memory_per_vcore_mb: int + :ivar supported_zones: List of supported availability zones. E.g. '1', '2', '3'. + :vartype supported_zones: list[str] + :ivar supported_ha_mode: Modes of high availability supported for this compute. + :vartype supported_ha_mode: list[str or + ~azure.mgmt.postgresqlflexibleservers.models.HighAvailabilityMode] + :ivar supported_features: Features supported. + :vartype supported_features: + list[~azure.mgmt.postgresqlflexibleservers.models.SupportedFeature] + :ivar security_profile: Security profile of the compute. Indicates if it's a Confidential + Compute virtual machine. + :vartype security_profile: str + """ + + name: Optional[str] = rest_field(visibility=["read"]) + """Name of the compute (SKU).""" + v_cores: Optional[int] = rest_field(name="vCores", visibility=["read"]) + """vCores available for this compute.""" + supported_iops: Optional[int] = rest_field(name="supportedIops", visibility=["read"]) + """Maximum IOPS supported by this compute.""" + supported_memory_per_vcore_mb: Optional[int] = rest_field(name="supportedMemoryPerVcoreMb", visibility=["read"]) + """Supported memory (in MB) per virtual core assigned to this compute.""" + supported_zones: Optional[list[str]] = rest_field(name="supportedZones", visibility=["read"]) + """List of supported availability zones. E.g. '1', '2', '3'.""" + supported_ha_mode: Optional[list[Union[str, "_models.HighAvailabilityMode"]]] = rest_field( + name="supportedHaMode", visibility=["read"] + ) + """Modes of high availability supported for this compute.""" + supported_features: Optional[list["_models.SupportedFeature"]] = rest_field( + name="supportedFeatures", visibility=["read"] + ) + """Features supported.""" + security_profile: Optional[str] = rest_field(name="securityProfile", visibility=["read"]) + """Security profile of the compute. Indicates if it's a Confidential Compute virtual machine.""" + + +class ServerVersionCapability(CapabilityBase): + """Capabilities in terms of major versions of PostgreSQL database engine. + + :ivar status: The status of the capability. Known values are: "Visible", "Available", + "Default", and "Disabled". + :vartype status: str or ~azure.mgmt.postgresqlflexibleservers.models.CapabilityStatus + :ivar reason: The reason for the capability not being available. + :vartype reason: str + :ivar name: Major version of PostgreSQL database engine. + :vartype name: str + :ivar supported_versions_to_upgrade: Major versions of PostgreSQL database engine to which this + version can be automatically upgraded. + :vartype supported_versions_to_upgrade: list[str] + :ivar supported_features: Features supported. + :vartype supported_features: + list[~azure.mgmt.postgresqlflexibleservers.models.SupportedFeature] + """ + + name: Optional[str] = rest_field(visibility=["read"]) + """Major version of PostgreSQL database engine.""" + supported_versions_to_upgrade: Optional[list[str]] = rest_field( + name="supportedVersionsToUpgrade", visibility=["read"] + ) + """Major versions of PostgreSQL database engine to which this version can be automatically + upgraded.""" + supported_features: Optional[list["_models.SupportedFeature"]] = rest_field( + name="supportedFeatures", visibility=["read"] + ) + """Features supported.""" + + +class ServiceSpecification(_Model): + """Service specification for an operation. + + :ivar metric_specifications: Metric specifications for the operation. + :vartype metric_specifications: + list[~azure.mgmt.postgresqlflexibleservers.models.MetricSpecification] + :ivar log_specifications: Log specifications for the operation. + :vartype log_specifications: + list[~azure.mgmt.postgresqlflexibleservers.models.LogSpecification] + """ + + metric_specifications: Optional[list["_models.MetricSpecification"]] = rest_field( + name="metricSpecifications", visibility=["read"] + ) + """Metric specifications for the operation.""" + log_specifications: Optional[list["_models.LogSpecification"]] = rest_field( + name="logSpecifications", visibility=["read"] + ) + """Log specifications for the operation.""" + + +class Sku(_Model): + """Compute information of a server. + + :ivar name: Name by which is known a given compute size assigned to a server. Required. + :vartype name: str + :ivar tier: Tier of the compute assigned to a server. Required. Known values are: "Burstable", + "GeneralPurpose", and "MemoryOptimized". + :vartype tier: str or ~azure.mgmt.postgresqlflexibleservers.models.SkuTier + """ + + name: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Name by which is known a given compute size assigned to a server. Required.""" + tier: Union[str, "_models.SkuTier"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Tier of the compute assigned to a server. Required. Known values are: \"Burstable\", + \"GeneralPurpose\", and \"MemoryOptimized\".""" + + @overload + def __init__( + self, + *, + name: str, + tier: Union[str, "_models.SkuTier"], + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class SkuForPatch(_Model): + """Compute information of a server. + + :ivar name: Name by which is known a given compute size assigned to a server. + :vartype name: str + :ivar tier: Tier of the compute assigned to a server. Known values are: "Burstable", + "GeneralPurpose", and "MemoryOptimized". + :vartype tier: str or ~azure.mgmt.postgresqlflexibleservers.models.SkuTier + """ + + name: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Name by which is known a given compute size assigned to a server.""" + tier: Optional[Union[str, "_models.SkuTier"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Tier of the compute assigned to a server. Known values are: \"Burstable\", \"GeneralPurpose\", + and \"MemoryOptimized\".""" + + @overload + def __init__( + self, + *, + name: Optional[str] = None, + tier: Optional[Union[str, "_models.SkuTier"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class Storage(_Model): + """Storage properties of a server. + + :ivar storage_size_gb: Size of storage assigned to a server. + :vartype storage_size_gb: int + :ivar auto_grow: Flag to enable or disable the automatic growth of storage size of a server + when available space is nearing zero and conditions allow for automatically growing storage + size. Known values are: "Enabled" and "Disabled". + :vartype auto_grow: str or ~azure.mgmt.postgresqlflexibleservers.models.StorageAutoGrow + :ivar tier: Storage tier of a server. Known values are: "P1", "P2", "P3", "P4", "P6", "P10", + "P15", "P20", "P30", "P40", "P50", "P60", "P70", and "P80". + :vartype tier: str or + ~azure.mgmt.postgresqlflexibleservers.models.AzureManagedDiskPerformanceTier + :ivar iops: Maximum IOPS supported for storage. Required when type of storage is PremiumV2_LRS + or UltraSSD_LRS. + :vartype iops: int + :ivar throughput: Maximum throughput supported for storage. Required when type of storage is + PremiumV2_LRS or UltraSSD_LRS. + :vartype throughput: int + :ivar type: Type of storage assigned to a server. Allowed values are Premium_LRS, + PremiumV2_LRS, or UltraSSD_LRS. If not specified, it defaults to Premium_LRS. Known values are: + "Premium_LRS", "PremiumV2_LRS", and "UltraSSD_LRS". + :vartype type: str or ~azure.mgmt.postgresqlflexibleservers.models.StorageType + """ + + storage_size_gb: Optional[int] = rest_field( + name="storageSizeGB", visibility=["read", "create", "update", "delete", "query"] + ) + """Size of storage assigned to a server.""" + auto_grow: Optional[Union[str, "_models.StorageAutoGrow"]] = rest_field( + name="autoGrow", visibility=["read", "create", "update", "delete", "query"] + ) + """Flag to enable or disable the automatic growth of storage size of a server when available space + is nearing zero and conditions allow for automatically growing storage size. Known values are: + \"Enabled\" and \"Disabled\".""" + tier: Optional[Union[str, "_models.AzureManagedDiskPerformanceTier"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Storage tier of a server. Known values are: \"P1\", \"P2\", \"P3\", \"P4\", \"P6\", \"P10\", + \"P15\", \"P20\", \"P30\", \"P40\", \"P50\", \"P60\", \"P70\", and \"P80\".""" + iops: Optional[int] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Maximum IOPS supported for storage. Required when type of storage is PremiumV2_LRS or + UltraSSD_LRS.""" + throughput: Optional[int] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Maximum throughput supported for storage. Required when type of storage is PremiumV2_LRS or + UltraSSD_LRS.""" + type: Optional[Union[str, "_models.StorageType"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Type of storage assigned to a server. Allowed values are Premium_LRS, PremiumV2_LRS, or + UltraSSD_LRS. If not specified, it defaults to Premium_LRS. Known values are: \"Premium_LRS\", + \"PremiumV2_LRS\", and \"UltraSSD_LRS\".""" + + @overload + def __init__( + self, + *, + storage_size_gb: Optional[int] = None, + auto_grow: Optional[Union[str, "_models.StorageAutoGrow"]] = None, + tier: Optional[Union[str, "_models.AzureManagedDiskPerformanceTier"]] = None, + iops: Optional[int] = None, + throughput: Optional[int] = None, + type: Optional[Union[str, "_models.StorageType"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class StorageEditionCapability(CapabilityBase): + """Capabilities in terms of storage tier. + + :ivar status: The status of the capability. Known values are: "Visible", "Available", + "Default", and "Disabled". + :vartype status: str or ~azure.mgmt.postgresqlflexibleservers.models.CapabilityStatus + :ivar reason: The reason for the capability not being available. + :vartype reason: str + :ivar name: Name of storage tier. + :vartype name: str + :ivar default_storage_size_mb: Default storage size (in MB) for this storage tier. + :vartype default_storage_size_mb: int + :ivar supported_storage_mb: Configurations of storage supported for this storage tier. + :vartype supported_storage_mb: + list[~azure.mgmt.postgresqlflexibleservers.models.StorageMbCapability] + """ + + name: Optional[str] = rest_field(visibility=["read"]) + """Name of storage tier.""" + default_storage_size_mb: Optional[int] = rest_field(name="defaultStorageSizeMb", visibility=["read"]) + """Default storage size (in MB) for this storage tier.""" + supported_storage_mb: Optional[list["_models.StorageMbCapability"]] = rest_field( + name="supportedStorageMb", visibility=["read"] + ) + """Configurations of storage supported for this storage tier.""" + + +class StorageMbCapability(CapabilityBase): + """Storage size (in MB) capability. + + :ivar status: The status of the capability. Known values are: "Visible", "Available", + "Default", and "Disabled". + :vartype status: str or ~azure.mgmt.postgresqlflexibleservers.models.CapabilityStatus + :ivar reason: The reason for the capability not being available. + :vartype reason: str + :ivar supported_iops: Minimum IOPS supported by the storage size. + :vartype supported_iops: int + :ivar supported_maximum_iops: Maximum IOPS supported by the storage size. + :vartype supported_maximum_iops: int + :ivar storage_size_mb: Minimum supported size (in MB) of storage. + :vartype storage_size_mb: int + :ivar maximum_storage_size_mb: Maximum supported size (in MB) of storage. + :vartype maximum_storage_size_mb: int + :ivar supported_throughput: Minimum supported throughput (in MB/s) of storage. + :vartype supported_throughput: int + :ivar supported_maximum_throughput: Maximum supported throughput (in MB/s) of storage. + :vartype supported_maximum_throughput: int + :ivar default_iops_tier: Default IOPS for this tier and storage size. + :vartype default_iops_tier: str + :ivar supported_iops_tiers: List of all supported storage tiers for this tier and storage size. + :vartype supported_iops_tiers: + list[~azure.mgmt.postgresqlflexibleservers.models.StorageTierCapability] + """ + + supported_iops: Optional[int] = rest_field(name="supportedIops", visibility=["read"]) + """Minimum IOPS supported by the storage size.""" + supported_maximum_iops: Optional[int] = rest_field(name="supportedMaximumIops", visibility=["read"]) + """Maximum IOPS supported by the storage size.""" + storage_size_mb: Optional[int] = rest_field(name="storageSizeMb", visibility=["read"]) + """Minimum supported size (in MB) of storage.""" + maximum_storage_size_mb: Optional[int] = rest_field(name="maximumStorageSizeMb", visibility=["read"]) + """Maximum supported size (in MB) of storage.""" + supported_throughput: Optional[int] = rest_field(name="supportedThroughput", visibility=["read"]) + """Minimum supported throughput (in MB/s) of storage.""" + supported_maximum_throughput: Optional[int] = rest_field(name="supportedMaximumThroughput", visibility=["read"]) + """Maximum supported throughput (in MB/s) of storage.""" + default_iops_tier: Optional[str] = rest_field(name="defaultIopsTier", visibility=["read"]) + """Default IOPS for this tier and storage size.""" + supported_iops_tiers: Optional[list["_models.StorageTierCapability"]] = rest_field( + name="supportedIopsTiers", visibility=["read"] + ) + """List of all supported storage tiers for this tier and storage size.""" + + +class StorageTierCapability(CapabilityBase): + """Capability of a storage tier. + + :ivar status: The status of the capability. Known values are: "Visible", "Available", + "Default", and "Disabled". + :vartype status: str or ~azure.mgmt.postgresqlflexibleservers.models.CapabilityStatus + :ivar reason: The reason for the capability not being available. + :vartype reason: str + :ivar name: Name of the storage tier. + :vartype name: str + :ivar iops: Supported IOPS for the storage tier. + :vartype iops: int + """ + + name: Optional[str] = rest_field(visibility=["read"]) + """Name of the storage tier.""" + iops: Optional[int] = rest_field(visibility=["read"]) + """Supported IOPS for the storage tier.""" + + +class SupportedFeature(_Model): + """Features supported. + + :ivar name: Name of the feature. + :vartype name: str + :ivar status: Status of the feature. Indicates if the feature is enabled or not. Known values + are: "Enabled" and "Disabled". + :vartype status: str or ~azure.mgmt.postgresqlflexibleservers.models.FeatureStatus + """ + + name: Optional[str] = rest_field(visibility=["read"]) + """Name of the feature.""" + status: Optional[Union[str, "_models.FeatureStatus"]] = rest_field(visibility=["read"]) + """Status of the feature. Indicates if the feature is enabled or not. Known values are: + \"Enabled\" and \"Disabled\".""" + + +class SystemData(_Model): + """Metadata pertaining to creation and last modification of the resource. + + :ivar created_by: The identity that created the resource. + :vartype created_by: str + :ivar created_by_type: The type of identity that created the resource. Known values are: + "User", "Application", "ManagedIdentity", and "Key". + :vartype created_by_type: str or ~azure.mgmt.postgresqlflexibleservers.models.CreatedByType + :ivar created_at: The timestamp of resource creation (UTC). + :vartype created_at: ~datetime.datetime + :ivar last_modified_by: The identity that last modified the resource. + :vartype last_modified_by: str + :ivar last_modified_by_type: The type of identity that last modified the resource. Known values + are: "User", "Application", "ManagedIdentity", and "Key". + :vartype last_modified_by_type: str or + ~azure.mgmt.postgresqlflexibleservers.models.CreatedByType + :ivar last_modified_at: The timestamp of resource last modification (UTC). + :vartype last_modified_at: ~datetime.datetime + """ + + created_by: Optional[str] = rest_field(name="createdBy", visibility=["read", "create", "update", "delete", "query"]) + """The identity that created the resource.""" + created_by_type: Optional[Union[str, "_models.CreatedByType"]] = rest_field( + name="createdByType", visibility=["read", "create", "update", "delete", "query"] + ) + """The type of identity that created the resource. Known values are: \"User\", \"Application\", + \"ManagedIdentity\", and \"Key\".""" + created_at: Optional[datetime.datetime] = rest_field( + name="createdAt", visibility=["read", "create", "update", "delete", "query"], format="rfc3339" + ) + """The timestamp of resource creation (UTC).""" + last_modified_by: Optional[str] = rest_field( + name="lastModifiedBy", visibility=["read", "create", "update", "delete", "query"] + ) + """The identity that last modified the resource.""" + last_modified_by_type: Optional[Union[str, "_models.CreatedByType"]] = rest_field( + name="lastModifiedByType", visibility=["read", "create", "update", "delete", "query"] + ) + """The type of identity that last modified the resource. Known values are: \"User\", + \"Application\", \"ManagedIdentity\", and \"Key\".""" + last_modified_at: Optional[datetime.datetime] = rest_field( + name="lastModifiedAt", visibility=["read", "create", "update", "delete", "query"], format="rfc3339" + ) + """The timestamp of resource last modification (UTC).""" + + @overload + def __init__( + self, + *, + created_by: Optional[str] = None, + created_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, + created_at: Optional[datetime.datetime] = None, + last_modified_by: Optional[str] = None, + last_modified_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, + last_modified_at: Optional[datetime.datetime] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class TuningOptions(ProxyResource): + """Impact on some metric if this recommended action is applied. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.postgresqlflexibleservers.models.SystemData + :ivar properties: The resource-specific properties for this resource. + :vartype properties: ~azure.mgmt.postgresqlflexibleservers.models.TuningOptionsProperties + """ + + properties: Optional["_models.TuningOptionsProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The resource-specific properties for this resource.""" + + @overload + def __init__( + self, + *, + properties: Optional["_models.TuningOptionsProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class TuningOptionsProperties(_Model): + """Properties of a tuning option. + + :ivar state: State of the tuning option. + :vartype state: str + """ + + state: Optional[str] = rest_field(visibility=["read"]) + """State of the tuning option.""" + + +class UserAssignedIdentity(_Model): + """Identities associated with a server. + + :ivar user_assigned_identities: Map of user assigned managed identities. + :vartype user_assigned_identities: dict[str, + ~azure.mgmt.postgresqlflexibleservers.models.UserIdentity] + :ivar principal_id: Identifier of the object of the service principal associated to the user + assigned managed identity. + :vartype principal_id: str + :ivar type: Types of identities associated with a server. Required. Known values are: "None", + "UserAssigned", "SystemAssigned", and "SystemAssigned,UserAssigned". + :vartype type: str or ~azure.mgmt.postgresqlflexibleservers.models.IdentityType + :ivar tenant_id: Identifier of the tenant of a server. + :vartype tenant_id: str + """ + + user_assigned_identities: Optional[dict[str, "_models.UserIdentity"]] = rest_field( + name="userAssignedIdentities", visibility=["read", "create", "update", "delete", "query"] + ) + """Map of user assigned managed identities.""" + principal_id: Optional[str] = rest_field( + name="principalId", visibility=["read", "create", "update", "delete", "query"] + ) + """Identifier of the object of the service principal associated to the user assigned managed + identity.""" + type: Union[str, "_models.IdentityType"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Types of identities associated with a server. Required. Known values are: \"None\", + \"UserAssigned\", \"SystemAssigned\", and \"SystemAssigned,UserAssigned\".""" + tenant_id: Optional[str] = rest_field(name="tenantId", visibility=["read"]) + """Identifier of the tenant of a server.""" + + @overload + def __init__( + self, + *, + type: Union[str, "_models.IdentityType"], + user_assigned_identities: Optional[dict[str, "_models.UserIdentity"]] = None, + principal_id: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class UserIdentity(_Model): + """User assigned managed identity associated with a server. + + :ivar principal_id: Identifier of the object of the service principal associated to the user + assigned managed identity. + :vartype principal_id: str + :ivar client_id: Identifier of the client of the service principal associated to the user + assigned managed identity. + :vartype client_id: str + """ + + principal_id: Optional[str] = rest_field( + name="principalId", visibility=["read", "create", "update", "delete", "query"] + ) + """Identifier of the object of the service principal associated to the user assigned managed + identity.""" + client_id: Optional[str] = rest_field(name="clientId", visibility=["read", "create", "update", "delete", "query"]) + """Identifier of the client of the service principal associated to the user assigned managed + identity.""" + + @overload + def __init__( + self, + *, + principal_id: Optional[str] = None, + client_id: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ValidationDetails(_Model): + """Details for the validation for migration. + + :ivar status: Validation status for migration. Known values are: "Failed", "Succeeded", and + "Warning". + :vartype status: str or ~azure.mgmt.postgresqlflexibleservers.models.ValidationState + :ivar validation_start_time_in_utc: Start time (UTC) for validation. + :vartype validation_start_time_in_utc: ~datetime.datetime + :ivar validation_end_time_in_utc: End time (UTC) for validation. + :vartype validation_end_time_in_utc: ~datetime.datetime + :ivar server_level_validation_details: Details of server level validations. + :vartype server_level_validation_details: + list[~azure.mgmt.postgresqlflexibleservers.models.ValidationSummaryItem] + :ivar db_level_validation_details: Details of server level validations. + :vartype db_level_validation_details: + list[~azure.mgmt.postgresqlflexibleservers.models.DbLevelValidationStatus] + """ + + status: Optional[Union[str, "_models.ValidationState"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Validation status for migration. Known values are: \"Failed\", \"Succeeded\", and \"Warning\".""" + validation_start_time_in_utc: Optional[datetime.datetime] = rest_field( + name="validationStartTimeInUtc", visibility=["read", "create", "update", "delete", "query"], format="rfc3339" + ) + """Start time (UTC) for validation.""" + validation_end_time_in_utc: Optional[datetime.datetime] = rest_field( + name="validationEndTimeInUtc", visibility=["read", "create", "update", "delete", "query"], format="rfc3339" + ) + """End time (UTC) for validation.""" + server_level_validation_details: Optional[list["_models.ValidationSummaryItem"]] = rest_field( + name="serverLevelValidationDetails", visibility=["read", "create", "update", "delete", "query"] + ) + """Details of server level validations.""" + db_level_validation_details: Optional[list["_models.DbLevelValidationStatus"]] = rest_field( + name="dbLevelValidationDetails", visibility=["read", "create", "update", "delete", "query"] + ) + """Details of server level validations.""" + + @overload + def __init__( + self, + *, + status: Optional[Union[str, "_models.ValidationState"]] = None, + validation_start_time_in_utc: Optional[datetime.datetime] = None, + validation_end_time_in_utc: Optional[datetime.datetime] = None, + server_level_validation_details: Optional[list["_models.ValidationSummaryItem"]] = None, + db_level_validation_details: Optional[list["_models.DbLevelValidationStatus"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ValidationMessage(_Model): + """Validation message object. + + :ivar state: Severity of validation message. Known values are: "Failed", "Succeeded", and + "Warning". + :vartype state: str or ~azure.mgmt.postgresqlflexibleservers.models.ValidationState + :ivar message: Validation message string. + :vartype message: str + """ + + state: Optional[Union[str, "_models.ValidationState"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Severity of validation message. Known values are: \"Failed\", \"Succeeded\", and \"Warning\".""" + message: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Validation message string.""" + + @overload + def __init__( + self, + *, + state: Optional[Union[str, "_models.ValidationState"]] = None, + message: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ValidationSummaryItem(_Model): + """Validation summary object. + + :ivar type: Validation type. + :vartype type: str + :ivar state: Validation status for migration. Known values are: "Failed", "Succeeded", and + "Warning". + :vartype state: str or ~azure.mgmt.postgresqlflexibleservers.models.ValidationState + :ivar messages: Validation messages. + :vartype messages: list[~azure.mgmt.postgresqlflexibleservers.models.ValidationMessage] + """ + + type: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Validation type.""" + state: Optional[Union[str, "_models.ValidationState"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Validation status for migration. Known values are: \"Failed\", \"Succeeded\", and \"Warning\".""" + messages: Optional[list["_models.ValidationMessage"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Validation messages.""" + + @overload + def __init__( + self, + *, + type: Optional[str] = None, + state: Optional[Union[str, "_models.ValidationState"]] = None, + messages: Optional[list["_models.ValidationMessage"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class VirtualEndpoint(ProxyResource): + """Pair of virtual endpoints for a server. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.postgresqlflexibleservers.models.SystemData + :ivar properties: Properties of the pair of virtual endpoints. + :vartype properties: + ~azure.mgmt.postgresqlflexibleservers.models.VirtualEndpointResourceProperties + """ + + properties: Optional["_models.VirtualEndpointResourceProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Properties of the pair of virtual endpoints.""" + + __flattened_items = ["endpoint_type", "members", "virtual_endpoints"] + + @overload + def __init__( + self, + *, + properties: Optional["_models.VirtualEndpointResourceProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class VirtualEndpointResourceForPatch(_Model): + """Pair of virtual endpoints for a server. + + :ivar properties: Properties of the pair of virtual endpoints. + :vartype properties: + ~azure.mgmt.postgresqlflexibleservers.models.VirtualEndpointResourceProperties + """ + + properties: Optional["_models.VirtualEndpointResourceProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Properties of the pair of virtual endpoints.""" + + __flattened_items = ["endpoint_type", "members", "virtual_endpoints"] + + @overload + def __init__( + self, + *, + properties: Optional["_models.VirtualEndpointResourceProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class VirtualEndpointResourceProperties(_Model): + """Properties of a pair of virtual endpoints. + + :ivar endpoint_type: Type of endpoint for the virtual endpoints. "ReadWrite" + :vartype endpoint_type: str or ~azure.mgmt.postgresqlflexibleservers.models.VirtualEndpointType + :ivar members: List of servers that one of the virtual endpoints can refer to. + :vartype members: list[str] + :ivar virtual_endpoints: List of virtual endpoints for a server. + :vartype virtual_endpoints: list[str] + """ + + endpoint_type: Optional[Union[str, "_models.VirtualEndpointType"]] = rest_field( + name="endpointType", visibility=["read", "create", "update", "delete", "query"] + ) + """Type of endpoint for the virtual endpoints. \"ReadWrite\"""" + members: Optional[list[str]] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """List of servers that one of the virtual endpoints can refer to.""" + virtual_endpoints: Optional[list[str]] = rest_field(name="virtualEndpoints", visibility=["read"]) + """List of virtual endpoints for a server.""" + + @overload + def __init__( + self, + *, + endpoint_type: Optional[Union[str, "_models.VirtualEndpointType"]] = None, + members: Optional[list[str]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class VirtualNetworkSubnetUsageModel(_Model): + """Virtual network subnet usage data. + + :ivar delegated_subnets_usage: + :vartype delegated_subnets_usage: + list[~azure.mgmt.postgresqlflexibleservers.models.DelegatedSubnetUsage] + :ivar location: location of the delegated subnet usage. + :vartype location: str + :ivar subscription_id: subscriptionId of the delegated subnet usage. + :vartype subscription_id: str + """ + + delegated_subnets_usage: Optional[list["_models.DelegatedSubnetUsage"]] = rest_field( + name="delegatedSubnetsUsage", visibility=["read"] + ) + location: Optional[str] = rest_field(visibility=["read"]) + """location of the delegated subnet usage.""" + subscription_id: Optional[str] = rest_field(name="subscriptionId", visibility=["read"]) + """subscriptionId of the delegated subnet usage.""" + + +class VirtualNetworkSubnetUsageParameter(_Model): + """Virtual network subnet usage parameter. + + :ivar virtual_network_arm_resource_id: Virtual network resource id. + :vartype virtual_network_arm_resource_id: str + """ + + virtual_network_arm_resource_id: Optional[str] = rest_field( + name="virtualNetworkArmResourceId", visibility=["read", "create", "update", "delete", "query"] + ) + """Virtual network resource id.""" + + @overload + def __init__( + self, + *, + virtual_network_arm_resource_id: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) diff --git a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/azure/mgmt/postgresqlflexibleservers/models/_models_py3.py b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/azure/mgmt/postgresqlflexibleservers/models/_models_py3.py deleted file mode 100644 index ac19d04e63cd..000000000000 --- a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/azure/mgmt/postgresqlflexibleservers/models/_models_py3.py +++ /dev/null @@ -1,5885 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression,too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from collections.abc import MutableMapping -import datetime -from typing import Any, Optional, TYPE_CHECKING, Union - -from .._utils import serialization as _serialization - -if TYPE_CHECKING: - from .. import models as _models -JSON = MutableMapping[str, Any] - - -class AdminCredentials(_serialization.Model): - """Credentials of administrator users for source and target servers. - - All required parameters must be populated in order to send to server. - - :ivar source_server_password: Password for the user of the source server. Required. - :vartype source_server_password: str - :ivar target_server_password: Password for the user of the target server. Required. - :vartype target_server_password: str - """ - - _validation = { - "source_server_password": {"required": True}, - "target_server_password": {"required": True}, - } - - _attribute_map = { - "source_server_password": {"key": "sourceServerPassword", "type": "str"}, - "target_server_password": {"key": "targetServerPassword", "type": "str"}, - } - - def __init__(self, *, source_server_password: str, target_server_password: str, **kwargs: Any) -> None: - """ - :keyword source_server_password: Password for the user of the source server. Required. - :paramtype source_server_password: str - :keyword target_server_password: Password for the user of the target server. Required. - :paramtype target_server_password: str - """ - super().__init__(**kwargs) - self.source_server_password = source_server_password - self.target_server_password = target_server_password - - -class AdminCredentialsForPatch(_serialization.Model): - """Credentials of administrator users for source and target servers. - - :ivar source_server_password: Password for the user of the source server. - :vartype source_server_password: str - :ivar target_server_password: Password for the user of the target server. - :vartype target_server_password: str - """ - - _attribute_map = { - "source_server_password": {"key": "sourceServerPassword", "type": "str"}, - "target_server_password": {"key": "targetServerPassword", "type": "str"}, - } - - def __init__( - self, - *, - source_server_password: Optional[str] = None, - target_server_password: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword source_server_password: Password for the user of the source server. - :paramtype source_server_password: str - :keyword target_server_password: Password for the user of the target server. - :paramtype target_server_password: str - """ - super().__init__(**kwargs) - self.source_server_password = source_server_password - self.target_server_password = target_server_password - - -class Resource(_serialization.Model): - """Common fields that are returned in the response for all Azure Resource Manager resources. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Fully qualified resource ID for the resource. E.g. - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}". - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or - "Microsoft.Storage/storageAccounts". - :vartype type: str - :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy - information. - :vartype system_data: ~azure.mgmt.postgresqlflexibleservers.models.SystemData - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "system_data": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "system_data": {"key": "systemData", "type": "SystemData"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.id: Optional[str] = None - self.name: Optional[str] = None - self.type: Optional[str] = None - self.system_data: Optional["_models.SystemData"] = None - - -class ProxyResource(Resource): - """The resource model definition for a Azure Resource Manager proxy resource. It will not have - tags and a location. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Fully qualified resource ID for the resource. E.g. - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}". - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or - "Microsoft.Storage/storageAccounts". - :vartype type: str - :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy - information. - :vartype system_data: ~azure.mgmt.postgresqlflexibleservers.models.SystemData - """ - - -class AdministratorMicrosoftEntra(ProxyResource): - """Server administrator associated to a Microsoft Entra principal. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Fully qualified resource ID for the resource. E.g. - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}". - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or - "Microsoft.Storage/storageAccounts". - :vartype type: str - :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy - information. - :vartype system_data: ~azure.mgmt.postgresqlflexibleservers.models.SystemData - :ivar principal_type: Type of Microsoft Entra principal to which the server administrator is - associated. Known values are: "Unknown", "User", "Group", and "ServicePrincipal". - :vartype principal_type: str or ~azure.mgmt.postgresqlflexibleservers.models.PrincipalType - :ivar principal_name: Name of the Microsoft Entra principal. - :vartype principal_name: str - :ivar object_id: Object identifier of the Microsoft Entra principal. - :vartype object_id: str - :ivar tenant_id: Identifier of the tenant in which the Microsoft Entra principal exists. - :vartype tenant_id: str - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "system_data": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "system_data": {"key": "systemData", "type": "SystemData"}, - "principal_type": {"key": "properties.principalType", "type": "str"}, - "principal_name": {"key": "properties.principalName", "type": "str"}, - "object_id": {"key": "properties.objectId", "type": "str"}, - "tenant_id": {"key": "properties.tenantId", "type": "str"}, - } - - def __init__( - self, - *, - principal_type: Optional[Union[str, "_models.PrincipalType"]] = None, - principal_name: Optional[str] = None, - object_id: Optional[str] = None, - tenant_id: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword principal_type: Type of Microsoft Entra principal to which the server administrator is - associated. Known values are: "Unknown", "User", "Group", and "ServicePrincipal". - :paramtype principal_type: str or ~azure.mgmt.postgresqlflexibleservers.models.PrincipalType - :keyword principal_name: Name of the Microsoft Entra principal. - :paramtype principal_name: str - :keyword object_id: Object identifier of the Microsoft Entra principal. - :paramtype object_id: str - :keyword tenant_id: Identifier of the tenant in which the Microsoft Entra principal exists. - :paramtype tenant_id: str - """ - super().__init__(**kwargs) - self.principal_type = principal_type - self.principal_name = principal_name - self.object_id = object_id - self.tenant_id = tenant_id - - -class AdministratorMicrosoftEntraAdd(_serialization.Model): - """Server administrator associated to a Microsoft Entra principal. - - :ivar principal_type: Type of Microsoft Entra principal to which the server administrator is - associated. Known values are: "Unknown", "User", "Group", and "ServicePrincipal". - :vartype principal_type: str or ~azure.mgmt.postgresqlflexibleservers.models.PrincipalType - :ivar principal_name: Name of the Microsoft Entra principal. - :vartype principal_name: str - :ivar tenant_id: Identifier of the tenant in which the Microsoft Entra principal exists. - :vartype tenant_id: str - """ - - _attribute_map = { - "principal_type": {"key": "properties.principalType", "type": "str"}, - "principal_name": {"key": "properties.principalName", "type": "str"}, - "tenant_id": {"key": "properties.tenantId", "type": "str"}, - } - - def __init__( - self, - *, - principal_type: Optional[Union[str, "_models.PrincipalType"]] = None, - principal_name: Optional[str] = None, - tenant_id: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword principal_type: Type of Microsoft Entra principal to which the server administrator is - associated. Known values are: "Unknown", "User", "Group", and "ServicePrincipal". - :paramtype principal_type: str or ~azure.mgmt.postgresqlflexibleservers.models.PrincipalType - :keyword principal_name: Name of the Microsoft Entra principal. - :paramtype principal_name: str - :keyword tenant_id: Identifier of the tenant in which the Microsoft Entra principal exists. - :paramtype tenant_id: str - """ - super().__init__(**kwargs) - self.principal_type = principal_type - self.principal_name = principal_name - self.tenant_id = tenant_id - - -class AdministratorMicrosoftEntraList(_serialization.Model): - """List of server administrators associated to Microsoft Entra principals. - - :ivar value: List of server administrators associated to Microsoft Entra principals. - :vartype value: list[~azure.mgmt.postgresqlflexibleservers.models.AdministratorMicrosoftEntra] - :ivar next_link: Link used to get the next page of results. - :vartype next_link: str - """ - - _attribute_map = { - "value": {"key": "value", "type": "[AdministratorMicrosoftEntra]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, - *, - value: Optional[list["_models.AdministratorMicrosoftEntra"]] = None, - next_link: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword value: List of server administrators associated to Microsoft Entra principals. - :paramtype value: - list[~azure.mgmt.postgresqlflexibleservers.models.AdministratorMicrosoftEntra] - :keyword next_link: Link used to get the next page of results. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class AdvancedThreatProtectionSettingsList(_serialization.Model): - """List of advanced threat protection settings for a server. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: Array of results. - :vartype value: - list[~azure.mgmt.postgresqlflexibleservers.models.AdvancedThreatProtectionSettingsModel] - :ivar next_link: Link used to get the next page of results. - :vartype next_link: str - """ - - _validation = { - "value": {"readonly": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[AdvancedThreatProtectionSettingsModel]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, *, next_link: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword next_link: Link used to get the next page of results. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value: Optional[list["_models.AdvancedThreatProtectionSettingsModel"]] = None - self.next_link = next_link - - -class AdvancedThreatProtectionSettingsModel(ProxyResource): - """Advanced threat protection settings of the server. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Fully qualified resource ID for the resource. E.g. - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}". - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or - "Microsoft.Storage/storageAccounts". - :vartype type: str - :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy - information. - :vartype system_data: ~azure.mgmt.postgresqlflexibleservers.models.SystemData - :ivar state: Specifies the state of the advanced threat protection, whether it is enabled, - disabled, or a state has not been applied yet on the server. Known values are: "Enabled" and - "Disabled". - :vartype state: str or ~azure.mgmt.postgresqlflexibleservers.models.ThreatProtectionState - :ivar creation_time: Specifies the creation time (UTC) of the policy. - :vartype creation_time: ~datetime.datetime - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "system_data": {"readonly": True}, - "creation_time": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "system_data": {"key": "systemData", "type": "SystemData"}, - "state": {"key": "properties.state", "type": "str"}, - "creation_time": {"key": "properties.creationTime", "type": "iso-8601"}, - } - - def __init__(self, *, state: Optional[Union[str, "_models.ThreatProtectionState"]] = None, **kwargs: Any) -> None: - """ - :keyword state: Specifies the state of the advanced threat protection, whether it is enabled, - disabled, or a state has not been applied yet on the server. Known values are: "Enabled" and - "Disabled". - :paramtype state: str or ~azure.mgmt.postgresqlflexibleservers.models.ThreatProtectionState - """ - super().__init__(**kwargs) - self.state = state - self.creation_time: Optional[datetime.datetime] = None - - -class AuthConfig(_serialization.Model): - """Authentication configuration properties of a server. - - :ivar active_directory_auth: Indicates if the server supports Microsoft Entra authentication. - Known values are: "Enabled" and "Disabled". - :vartype active_directory_auth: str or - ~azure.mgmt.postgresqlflexibleservers.models.MicrosoftEntraAuth - :ivar password_auth: Indicates if the server supports password based authentication. Known - values are: "Enabled" and "Disabled". - :vartype password_auth: str or ~azure.mgmt.postgresqlflexibleservers.models.PasswordBasedAuth - :ivar tenant_id: Identifier of the tenant of the delegated resource. - :vartype tenant_id: str - """ - - _attribute_map = { - "active_directory_auth": {"key": "activeDirectoryAuth", "type": "str"}, - "password_auth": {"key": "passwordAuth", "type": "str"}, - "tenant_id": {"key": "tenantId", "type": "str"}, - } - - def __init__( - self, - *, - active_directory_auth: Optional[Union[str, "_models.MicrosoftEntraAuth"]] = None, - password_auth: Optional[Union[str, "_models.PasswordBasedAuth"]] = None, - tenant_id: str = "", - **kwargs: Any - ) -> None: - """ - :keyword active_directory_auth: Indicates if the server supports Microsoft Entra - authentication. Known values are: "Enabled" and "Disabled". - :paramtype active_directory_auth: str or - ~azure.mgmt.postgresqlflexibleservers.models.MicrosoftEntraAuth - :keyword password_auth: Indicates if the server supports password based authentication. Known - values are: "Enabled" and "Disabled". - :paramtype password_auth: str or ~azure.mgmt.postgresqlflexibleservers.models.PasswordBasedAuth - :keyword tenant_id: Identifier of the tenant of the delegated resource. - :paramtype tenant_id: str - """ - super().__init__(**kwargs) - self.active_directory_auth = active_directory_auth - self.password_auth = password_auth - self.tenant_id = tenant_id - - -class AuthConfigForPatch(_serialization.Model): - """Authentication configuration properties of a server. - - :ivar active_directory_auth: Indicates if the server supports Microsoft Entra authentication. - Known values are: "Enabled" and "Disabled". - :vartype active_directory_auth: str or - ~azure.mgmt.postgresqlflexibleservers.models.MicrosoftEntraAuth - :ivar password_auth: Indicates if the server supports password based authentication. Known - values are: "Enabled" and "Disabled". - :vartype password_auth: str or ~azure.mgmt.postgresqlflexibleservers.models.PasswordBasedAuth - :ivar tenant_id: Identifier of the tenant of the delegated resource. - :vartype tenant_id: str - """ - - _attribute_map = { - "active_directory_auth": {"key": "activeDirectoryAuth", "type": "str"}, - "password_auth": {"key": "passwordAuth", "type": "str"}, - "tenant_id": {"key": "tenantId", "type": "str"}, - } - - def __init__( - self, - *, - active_directory_auth: Optional[Union[str, "_models.MicrosoftEntraAuth"]] = None, - password_auth: Optional[Union[str, "_models.PasswordBasedAuth"]] = None, - tenant_id: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword active_directory_auth: Indicates if the server supports Microsoft Entra - authentication. Known values are: "Enabled" and "Disabled". - :paramtype active_directory_auth: str or - ~azure.mgmt.postgresqlflexibleservers.models.MicrosoftEntraAuth - :keyword password_auth: Indicates if the server supports password based authentication. Known - values are: "Enabled" and "Disabled". - :paramtype password_auth: str or ~azure.mgmt.postgresqlflexibleservers.models.PasswordBasedAuth - :keyword tenant_id: Identifier of the tenant of the delegated resource. - :paramtype tenant_id: str - """ - super().__init__(**kwargs) - self.active_directory_auth = active_directory_auth - self.password_auth = password_auth - self.tenant_id = tenant_id - - -class Backup(_serialization.Model): - """Backup properties of a server. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar backup_retention_days: Backup retention days for the server. - :vartype backup_retention_days: int - :ivar geo_redundant_backup: Indicates if the server is configured to create geographically - redundant backups. Known values are: "Enabled" and "Disabled". - :vartype geo_redundant_backup: str or - ~azure.mgmt.postgresqlflexibleservers.models.GeographicallyRedundantBackup - :ivar earliest_restore_date: Earliest restore point time (ISO8601 format) for a server. - :vartype earliest_restore_date: ~datetime.datetime - """ - - _validation = { - "earliest_restore_date": {"readonly": True}, - } - - _attribute_map = { - "backup_retention_days": {"key": "backupRetentionDays", "type": "int"}, - "geo_redundant_backup": {"key": "geoRedundantBackup", "type": "str"}, - "earliest_restore_date": {"key": "earliestRestoreDate", "type": "iso-8601"}, - } - - def __init__( - self, - *, - backup_retention_days: int = 7, - geo_redundant_backup: Optional[Union[str, "_models.GeographicallyRedundantBackup"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword backup_retention_days: Backup retention days for the server. - :paramtype backup_retention_days: int - :keyword geo_redundant_backup: Indicates if the server is configured to create geographically - redundant backups. Known values are: "Enabled" and "Disabled". - :paramtype geo_redundant_backup: str or - ~azure.mgmt.postgresqlflexibleservers.models.GeographicallyRedundantBackup - """ - super().__init__(**kwargs) - self.backup_retention_days = backup_retention_days - self.geo_redundant_backup = geo_redundant_backup - self.earliest_restore_date: Optional[datetime.datetime] = None - - -class BackupAutomaticAndOnDemand(ProxyResource): - """Properties of a backup. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Fully qualified resource ID for the resource. E.g. - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}". - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or - "Microsoft.Storage/storageAccounts". - :vartype type: str - :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy - information. - :vartype system_data: ~azure.mgmt.postgresqlflexibleservers.models.SystemData - :ivar backup_type: Type of backup. Known values are: "Full" and "Customer On-Demand". - :vartype backup_type: str or ~azure.mgmt.postgresqlflexibleservers.models.BackupType - :ivar completed_time: Time(ISO8601 format) at which the backup was completed. - :vartype completed_time: ~datetime.datetime - :ivar source: Source of the backup. - :vartype source: str - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "system_data": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "system_data": {"key": "systemData", "type": "SystemData"}, - "backup_type": {"key": "properties.backupType", "type": "str"}, - "completed_time": {"key": "properties.completedTime", "type": "iso-8601"}, - "source": {"key": "properties.source", "type": "str"}, - } - - def __init__( - self, - *, - backup_type: Optional[Union[str, "_models.BackupType"]] = None, - completed_time: Optional[datetime.datetime] = None, - source: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword backup_type: Type of backup. Known values are: "Full" and "Customer On-Demand". - :paramtype backup_type: str or ~azure.mgmt.postgresqlflexibleservers.models.BackupType - :keyword completed_time: Time(ISO8601 format) at which the backup was completed. - :paramtype completed_time: ~datetime.datetime - :keyword source: Source of the backup. - :paramtype source: str - """ - super().__init__(**kwargs) - self.backup_type = backup_type - self.completed_time = completed_time - self.source = source - - -class BackupAutomaticAndOnDemandList(_serialization.Model): - """List of backups. - - :ivar value: List of available backups. - :vartype value: list[~azure.mgmt.postgresqlflexibleservers.models.BackupAutomaticAndOnDemand] - :ivar next_link: Link used to get the next page of results. - :vartype next_link: str - """ - - _attribute_map = { - "value": {"key": "value", "type": "[BackupAutomaticAndOnDemand]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, - *, - value: Optional[list["_models.BackupAutomaticAndOnDemand"]] = None, - next_link: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword value: List of available backups. - :paramtype value: list[~azure.mgmt.postgresqlflexibleservers.models.BackupAutomaticAndOnDemand] - :keyword next_link: Link used to get the next page of results. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class BackupForPatch(_serialization.Model): - """Backup properties of a server. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar backup_retention_days: Backup retention days for the server. - :vartype backup_retention_days: int - :ivar geo_redundant_backup: Indicates if the server is configured to create geographically - redundant backups. Known values are: "Enabled" and "Disabled". - :vartype geo_redundant_backup: str or - ~azure.mgmt.postgresqlflexibleservers.models.GeographicallyRedundantBackup - :ivar earliest_restore_date: Earliest restore point time (ISO8601 format) for a server. - :vartype earliest_restore_date: ~datetime.datetime - """ - - _validation = { - "earliest_restore_date": {"readonly": True}, - } - - _attribute_map = { - "backup_retention_days": {"key": "backupRetentionDays", "type": "int"}, - "geo_redundant_backup": {"key": "geoRedundantBackup", "type": "str"}, - "earliest_restore_date": {"key": "earliestRestoreDate", "type": "iso-8601"}, - } - - def __init__( - self, - *, - backup_retention_days: Optional[int] = None, - geo_redundant_backup: Optional[Union[str, "_models.GeographicallyRedundantBackup"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword backup_retention_days: Backup retention days for the server. - :paramtype backup_retention_days: int - :keyword geo_redundant_backup: Indicates if the server is configured to create geographically - redundant backups. Known values are: "Enabled" and "Disabled". - :paramtype geo_redundant_backup: str or - ~azure.mgmt.postgresqlflexibleservers.models.GeographicallyRedundantBackup - """ - super().__init__(**kwargs) - self.backup_retention_days = backup_retention_days - self.geo_redundant_backup = geo_redundant_backup - self.earliest_restore_date: Optional[datetime.datetime] = None - - -class BackupRequestBase(_serialization.Model): - """BackupRequestBase is the base for all backup request. - - All required parameters must be populated in order to send to server. - - :ivar backup_settings: Backup Settings. Required. - :vartype backup_settings: ~azure.mgmt.postgresqlflexibleservers.models.BackupSettings - """ - - _validation = { - "backup_settings": {"required": True}, - } - - _attribute_map = { - "backup_settings": {"key": "backupSettings", "type": "BackupSettings"}, - } - - def __init__(self, *, backup_settings: "_models.BackupSettings", **kwargs: Any) -> None: - """ - :keyword backup_settings: Backup Settings. Required. - :paramtype backup_settings: ~azure.mgmt.postgresqlflexibleservers.models.BackupSettings - """ - super().__init__(**kwargs) - self.backup_settings = backup_settings - - -class BackupSettings(_serialization.Model): - """The settings for the long term backup. - - All required parameters must be populated in order to send to server. - - :ivar backup_name: Backup Name for the current backup. Required. - :vartype backup_name: str - """ - - _validation = { - "backup_name": {"required": True}, - } - - _attribute_map = { - "backup_name": {"key": "backupName", "type": "str"}, - } - - def __init__(self, *, backup_name: str, **kwargs: Any) -> None: - """ - :keyword backup_name: Backup Name for the current backup. Required. - :paramtype backup_name: str - """ - super().__init__(**kwargs) - self.backup_name = backup_name - - -class BackupsLongTermRetentionOperation(ProxyResource): - """Response for the LTR backup Operation API call. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Fully qualified resource ID for the resource. E.g. - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}". - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or - "Microsoft.Storage/storageAccounts". - :vartype type: str - :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy - information. - :vartype system_data: ~azure.mgmt.postgresqlflexibleservers.models.SystemData - :ivar datasource_size_in_bytes: Size of datasource in bytes. - :vartype datasource_size_in_bytes: int - :ivar data_transferred_in_bytes: Data transferred in bytes. - :vartype data_transferred_in_bytes: int - :ivar backup_name: Name of Backup operation. - :vartype backup_name: str - :ivar backup_metadata: Metadata to be stored in RP. Store everything that will be required to - perform a successful restore using this Recovery point. e.g. Versions, DataFormat etc. - :vartype backup_metadata: str - :ivar status: Service-set extensible enum indicating the status of operation. Known values are: - "Running", "Cancelled", "Failed", and "Succeeded". - :vartype status: str or ~azure.mgmt.postgresqlflexibleservers.models.ExecutionStatus - :ivar start_time: Start time of the operation. - :vartype start_time: ~datetime.datetime - :ivar end_time: End time of the operation. - :vartype end_time: ~datetime.datetime - :ivar percent_complete: PercentageCompleted. - :vartype percent_complete: float - :ivar error_code: The error code. - :vartype error_code: str - :ivar error_message: The error message. - :vartype error_message: str - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "system_data": {"readonly": True}, - "percent_complete": {"maximum": 100, "minimum": 0}, - "error_code": {"readonly": True}, - "error_message": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "system_data": {"key": "systemData", "type": "SystemData"}, - "datasource_size_in_bytes": {"key": "properties.datasourceSizeInBytes", "type": "int"}, - "data_transferred_in_bytes": {"key": "properties.dataTransferredInBytes", "type": "int"}, - "backup_name": {"key": "properties.backupName", "type": "str"}, - "backup_metadata": {"key": "properties.backupMetadata", "type": "str"}, - "status": {"key": "properties.status", "type": "str"}, - "start_time": {"key": "properties.startTime", "type": "iso-8601"}, - "end_time": {"key": "properties.endTime", "type": "iso-8601"}, - "percent_complete": {"key": "properties.percentComplete", "type": "float"}, - "error_code": {"key": "properties.errorCode", "type": "str"}, - "error_message": {"key": "properties.errorMessage", "type": "str"}, - } - - def __init__( - self, - *, - datasource_size_in_bytes: Optional[int] = None, - data_transferred_in_bytes: Optional[int] = None, - backup_name: Optional[str] = None, - backup_metadata: Optional[str] = None, - status: Optional[Union[str, "_models.ExecutionStatus"]] = None, - start_time: Optional[datetime.datetime] = None, - end_time: Optional[datetime.datetime] = None, - percent_complete: Optional[float] = None, - **kwargs: Any - ) -> None: - """ - :keyword datasource_size_in_bytes: Size of datasource in bytes. - :paramtype datasource_size_in_bytes: int - :keyword data_transferred_in_bytes: Data transferred in bytes. - :paramtype data_transferred_in_bytes: int - :keyword backup_name: Name of Backup operation. - :paramtype backup_name: str - :keyword backup_metadata: Metadata to be stored in RP. Store everything that will be required - to perform a successful restore using this Recovery point. e.g. Versions, DataFormat etc. - :paramtype backup_metadata: str - :keyword status: Service-set extensible enum indicating the status of operation. Known values - are: "Running", "Cancelled", "Failed", and "Succeeded". - :paramtype status: str or ~azure.mgmt.postgresqlflexibleservers.models.ExecutionStatus - :keyword start_time: Start time of the operation. - :paramtype start_time: ~datetime.datetime - :keyword end_time: End time of the operation. - :paramtype end_time: ~datetime.datetime - :keyword percent_complete: PercentageCompleted. - :paramtype percent_complete: float - """ - super().__init__(**kwargs) - self.datasource_size_in_bytes = datasource_size_in_bytes - self.data_transferred_in_bytes = data_transferred_in_bytes - self.backup_name = backup_name - self.backup_metadata = backup_metadata - self.status = status - self.start_time = start_time - self.end_time = end_time - self.percent_complete = percent_complete - self.error_code: Optional[str] = None - self.error_message: Optional[str] = None - - -class BackupsLongTermRetentionRequest(BackupRequestBase): - """The request that is made for a long term retention backup. - - All required parameters must be populated in order to send to server. - - :ivar backup_settings: Backup Settings. Required. - :vartype backup_settings: ~azure.mgmt.postgresqlflexibleservers.models.BackupSettings - :ivar target_details: Backup store detail for target server. Required. - :vartype target_details: ~azure.mgmt.postgresqlflexibleservers.models.BackupStoreDetails - """ - - _validation = { - "backup_settings": {"required": True}, - "target_details": {"required": True}, - } - - _attribute_map = { - "backup_settings": {"key": "backupSettings", "type": "BackupSettings"}, - "target_details": {"key": "targetDetails", "type": "BackupStoreDetails"}, - } - - def __init__( - self, *, backup_settings: "_models.BackupSettings", target_details: "_models.BackupStoreDetails", **kwargs: Any - ) -> None: - """ - :keyword backup_settings: Backup Settings. Required. - :paramtype backup_settings: ~azure.mgmt.postgresqlflexibleservers.models.BackupSettings - :keyword target_details: Backup store detail for target server. Required. - :paramtype target_details: ~azure.mgmt.postgresqlflexibleservers.models.BackupStoreDetails - """ - super().__init__(backup_settings=backup_settings, **kwargs) - self.target_details = target_details - - -class BackupsLongTermRetentionResponse(_serialization.Model): - """Response for the LTR backup API call. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar datasource_size_in_bytes: Size of datasource in bytes. - :vartype datasource_size_in_bytes: int - :ivar data_transferred_in_bytes: Data transferred in bytes. - :vartype data_transferred_in_bytes: int - :ivar backup_name: Name of Backup operation. - :vartype backup_name: str - :ivar backup_metadata: Metadata to be stored in RP. Store everything that will be required to - perform a successful restore using this Recovery point. e.g. Versions, DataFormat etc. - :vartype backup_metadata: str - :ivar status: Service-set extensible enum indicating the status of operation. Known values are: - "Running", "Cancelled", "Failed", and "Succeeded". - :vartype status: str or ~azure.mgmt.postgresqlflexibleservers.models.ExecutionStatus - :ivar start_time: Start time of the operation. - :vartype start_time: ~datetime.datetime - :ivar end_time: End time of the operation. - :vartype end_time: ~datetime.datetime - :ivar percent_complete: PercentageCompleted. - :vartype percent_complete: float - :ivar error_code: The error code. - :vartype error_code: str - :ivar error_message: The error message. - :vartype error_message: str - """ - - _validation = { - "percent_complete": {"maximum": 100, "minimum": 0}, - "error_code": {"readonly": True}, - "error_message": {"readonly": True}, - } - - _attribute_map = { - "datasource_size_in_bytes": {"key": "properties.datasourceSizeInBytes", "type": "int"}, - "data_transferred_in_bytes": {"key": "properties.dataTransferredInBytes", "type": "int"}, - "backup_name": {"key": "properties.backupName", "type": "str"}, - "backup_metadata": {"key": "properties.backupMetadata", "type": "str"}, - "status": {"key": "properties.status", "type": "str"}, - "start_time": {"key": "properties.startTime", "type": "iso-8601"}, - "end_time": {"key": "properties.endTime", "type": "iso-8601"}, - "percent_complete": {"key": "properties.percentComplete", "type": "float"}, - "error_code": {"key": "properties.errorCode", "type": "str"}, - "error_message": {"key": "properties.errorMessage", "type": "str"}, - } - - def __init__( - self, - *, - datasource_size_in_bytes: Optional[int] = None, - data_transferred_in_bytes: Optional[int] = None, - backup_name: Optional[str] = None, - backup_metadata: Optional[str] = None, - status: Optional[Union[str, "_models.ExecutionStatus"]] = None, - start_time: Optional[datetime.datetime] = None, - end_time: Optional[datetime.datetime] = None, - percent_complete: Optional[float] = None, - **kwargs: Any - ) -> None: - """ - :keyword datasource_size_in_bytes: Size of datasource in bytes. - :paramtype datasource_size_in_bytes: int - :keyword data_transferred_in_bytes: Data transferred in bytes. - :paramtype data_transferred_in_bytes: int - :keyword backup_name: Name of Backup operation. - :paramtype backup_name: str - :keyword backup_metadata: Metadata to be stored in RP. Store everything that will be required - to perform a successful restore using this Recovery point. e.g. Versions, DataFormat etc. - :paramtype backup_metadata: str - :keyword status: Service-set extensible enum indicating the status of operation. Known values - are: "Running", "Cancelled", "Failed", and "Succeeded". - :paramtype status: str or ~azure.mgmt.postgresqlflexibleservers.models.ExecutionStatus - :keyword start_time: Start time of the operation. - :paramtype start_time: ~datetime.datetime - :keyword end_time: End time of the operation. - :paramtype end_time: ~datetime.datetime - :keyword percent_complete: PercentageCompleted. - :paramtype percent_complete: float - """ - super().__init__(**kwargs) - self.datasource_size_in_bytes = datasource_size_in_bytes - self.data_transferred_in_bytes = data_transferred_in_bytes - self.backup_name = backup_name - self.backup_metadata = backup_metadata - self.status = status - self.start_time = start_time - self.end_time = end_time - self.percent_complete = percent_complete - self.error_code: Optional[str] = None - self.error_message: Optional[str] = None - - -class BackupStoreDetails(_serialization.Model): - """Details about the target where the backup content will be stored. - - All required parameters must be populated in order to send to server. - - :ivar sas_uri_list: List of SAS uri of storage containers where backup data is to be - streamed/copied. Required. - :vartype sas_uri_list: list[str] - """ - - _validation = { - "sas_uri_list": {"required": True}, - } - - _attribute_map = { - "sas_uri_list": {"key": "sasUriList", "type": "[str]"}, - } - - def __init__(self, *, sas_uri_list: list[str], **kwargs: Any) -> None: - """ - :keyword sas_uri_list: List of SAS uri of storage containers where backup data is to be - streamed/copied. Required. - :paramtype sas_uri_list: list[str] - """ - super().__init__(**kwargs) - self.sas_uri_list = sas_uri_list - - -class CapabilityBase(_serialization.Model): - """Base object for representing capability. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar status: The status of the capability. Known values are: "Visible", "Available", - "Default", and "Disabled". - :vartype status: str or ~azure.mgmt.postgresqlflexibleservers.models.CapabilityStatus - :ivar reason: The reason for the capability not being available. - :vartype reason: str - """ - - _validation = { - "status": {"readonly": True}, - "reason": {"readonly": True}, - } - - _attribute_map = { - "status": {"key": "status", "type": "str"}, - "reason": {"key": "reason", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.status: Optional[Union[str, "_models.CapabilityStatus"]] = None - self.reason: Optional[str] = None - - -class Capability(CapabilityBase): - """Capability for the Azure Database for PostgreSQL flexible server. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar status: The status of the capability. Known values are: "Visible", "Available", - "Default", and "Disabled". - :vartype status: str or ~azure.mgmt.postgresqlflexibleservers.models.CapabilityStatus - :ivar reason: The reason for the capability not being available. - :vartype reason: str - :ivar name: Name of flexible servers capabilities. - :vartype name: str - :ivar supported_server_editions: List of supported compute tiers. - :vartype supported_server_editions: - list[~azure.mgmt.postgresqlflexibleservers.models.ServerEditionCapability] - :ivar supported_server_versions: List of supported major versions of PostgreSQL database - engine. - :vartype supported_server_versions: - list[~azure.mgmt.postgresqlflexibleservers.models.ServerVersionCapability] - :ivar supported_features: Features supported. - :vartype supported_features: - list[~azure.mgmt.postgresqlflexibleservers.models.SupportedFeature] - :ivar fast_provisioning_supported: Indicates if fast provisioning is supported. 'Enabled' means - fast provisioning is supported. 'Disabled' stands for fast provisioning is not supported. Will - be deprecated in the future. Look to Supported Features for 'FastProvisioning'. Known values - are: "Enabled" and "Disabled". - :vartype fast_provisioning_supported: str or - ~azure.mgmt.postgresqlflexibleservers.models.FastProvisioningSupport - :ivar supported_fast_provisioning_editions: List of compute tiers supporting fast provisioning. - :vartype supported_fast_provisioning_editions: - list[~azure.mgmt.postgresqlflexibleservers.models.FastProvisioningEditionCapability] - :ivar geo_backup_supported: Indicates if geographically redundant backups are supported in this - location. 'Enabled' means geographically redundant backups are supported. 'Disabled' stands for - geographically redundant backup is not supported. Will be deprecated in the future. Look to - Supported Features for 'GeoBackup'. Known values are: "Enabled" and "Disabled". - :vartype geo_backup_supported: str or - ~azure.mgmt.postgresqlflexibleservers.models.GeographicallyRedundantBackupSupport - :ivar zone_redundant_ha_supported: Indicates if high availability with zone redundancy is - supported in this location. 'Enabled' means high availability with zone redundancy is - supported. 'Disabled' stands for high availability with zone redundancy is not supported. Will - be deprecated in the future. Look to Supported Features for 'ZoneRedundantHa'. Known values - are: "Enabled" and "Disabled". - :vartype zone_redundant_ha_supported: str or - ~azure.mgmt.postgresqlflexibleservers.models.ZoneRedundantHighAvailabilitySupport - :ivar zone_redundant_ha_and_geo_backup_supported: Indicates if high availability with zone - redundancy is supported in conjunction with geographically redundant backups in this location. - 'Enabled' means high availability with zone redundancy is supported in conjunction with - geographically redundant backups is supported. 'Disabled' stands for high availability with - zone redundancy is supported in conjunction with geographically redundant backups is not - supported. Will be deprecated in the future. Look to Supported Features for - 'ZoneRedundantHaAndGeoBackup'. Known values are: "Enabled" and "Disabled". - :vartype zone_redundant_ha_and_geo_backup_supported: str or - ~azure.mgmt.postgresqlflexibleservers.models.ZoneRedundantHighAvailabilityAndGeographicallyRedundantBackupSupport - :ivar storage_auto_growth_supported: Indicates if storage autogrow is supported in this - location. 'Enabled' means storage autogrow is supported. 'Disabled' stands for storage autogrow - is not supported. Will be deprecated in the future. Look to Supported Features for - 'StorageAutoGrowth'. Known values are: "Enabled" and "Disabled". - :vartype storage_auto_growth_supported: str or - ~azure.mgmt.postgresqlflexibleservers.models.StorageAutoGrowthSupport - :ivar online_resize_supported: Indicates if resizing the storage, without interrupting the - operation of the database engine, is supported in this location for the given subscription. - 'Enabled' means resizing the storage without interrupting the operation of the database engine - is supported. 'Disabled' means resizing the storage without interrupting the operation of the - database engine is not supported. Will be deprecated in the future. Look to Supported Features - for 'OnlineResize'. Known values are: "Enabled" and "Disabled". - :vartype online_resize_supported: str or - ~azure.mgmt.postgresqlflexibleservers.models.OnlineStorageResizeSupport - :ivar restricted: Indicates if this location is restricted. 'Enabled' means location is - restricted. 'Disabled' stands for location is not restricted. Will be deprecated in the future. - Look to Supported Features for 'Restricted'. Known values are: "Enabled" and "Disabled". - :vartype restricted: str or ~azure.mgmt.postgresqlflexibleservers.models.LocationRestricted - """ - - _validation = { - "status": {"readonly": True}, - "reason": {"readonly": True}, - "supported_server_editions": {"readonly": True}, - "supported_server_versions": {"readonly": True}, - "supported_features": {"readonly": True}, - "fast_provisioning_supported": {"readonly": True}, - "supported_fast_provisioning_editions": {"readonly": True}, - "geo_backup_supported": {"readonly": True}, - "zone_redundant_ha_supported": {"readonly": True}, - "zone_redundant_ha_and_geo_backup_supported": {"readonly": True}, - "storage_auto_growth_supported": {"readonly": True}, - "online_resize_supported": {"readonly": True}, - "restricted": {"readonly": True}, - } - - _attribute_map = { - "status": {"key": "status", "type": "str"}, - "reason": {"key": "reason", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "supported_server_editions": {"key": "supportedServerEditions", "type": "[ServerEditionCapability]"}, - "supported_server_versions": {"key": "supportedServerVersions", "type": "[ServerVersionCapability]"}, - "supported_features": {"key": "supportedFeatures", "type": "[SupportedFeature]"}, - "fast_provisioning_supported": {"key": "fastProvisioningSupported", "type": "str"}, - "supported_fast_provisioning_editions": { - "key": "supportedFastProvisioningEditions", - "type": "[FastProvisioningEditionCapability]", - }, - "geo_backup_supported": {"key": "geoBackupSupported", "type": "str"}, - "zone_redundant_ha_supported": {"key": "zoneRedundantHaSupported", "type": "str"}, - "zone_redundant_ha_and_geo_backup_supported": {"key": "zoneRedundantHaAndGeoBackupSupported", "type": "str"}, - "storage_auto_growth_supported": {"key": "storageAutoGrowthSupported", "type": "str"}, - "online_resize_supported": {"key": "onlineResizeSupported", "type": "str"}, - "restricted": {"key": "restricted", "type": "str"}, - } - - def __init__(self, *, name: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword name: Name of flexible servers capabilities. - :paramtype name: str - """ - super().__init__(**kwargs) - self.name = name - self.supported_server_editions: Optional[list["_models.ServerEditionCapability"]] = None - self.supported_server_versions: Optional[list["_models.ServerVersionCapability"]] = None - self.supported_features: Optional[list["_models.SupportedFeature"]] = None - self.fast_provisioning_supported: Optional[Union[str, "_models.FastProvisioningSupport"]] = None - self.supported_fast_provisioning_editions: Optional[list["_models.FastProvisioningEditionCapability"]] = None - self.geo_backup_supported: Optional[Union[str, "_models.GeographicallyRedundantBackupSupport"]] = None - self.zone_redundant_ha_supported: Optional[Union[str, "_models.ZoneRedundantHighAvailabilitySupport"]] = None - self.zone_redundant_ha_and_geo_backup_supported: Optional[ - Union[str, "_models.ZoneRedundantHighAvailabilityAndGeographicallyRedundantBackupSupport"] - ] = None - self.storage_auto_growth_supported: Optional[Union[str, "_models.StorageAutoGrowthSupport"]] = None - self.online_resize_supported: Optional[Union[str, "_models.OnlineStorageResizeSupport"]] = None - self.restricted: Optional[Union[str, "_models.LocationRestricted"]] = None - - -class CapabilityList(_serialization.Model): - """List of capabilities for the Azure Database for PostgreSQL flexible server. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: List of supported capabilities. - :vartype value: list[~azure.mgmt.postgresqlflexibleservers.models.Capability] - :ivar next_link: Link to retrieve next page of results. - :vartype next_link: str - """ - - _validation = { - "value": {"readonly": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[Capability]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, *, next_link: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword next_link: Link to retrieve next page of results. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value: Optional[list["_models.Capability"]] = None - self.next_link = next_link - - -class CapturedLog(ProxyResource): - """Log file. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Fully qualified resource ID for the resource. E.g. - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}". - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or - "Microsoft.Storage/storageAccounts". - :vartype type: str - :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy - information. - :vartype system_data: ~azure.mgmt.postgresqlflexibleservers.models.SystemData - :ivar created_time: Creation timestamp of the log file. - :vartype created_time: ~datetime.datetime - :ivar last_modified_time: Last modified timestamp of the log file. - :vartype last_modified_time: ~datetime.datetime - :ivar size_in_kb: Size (in KB) of the log file. - :vartype size_in_kb: int - :ivar type_properties_type: Type of log file. Can be 'ServerLogs' or 'UpgradeLogs'. - :vartype type_properties_type: str - :ivar url: URL to download the log file from. - :vartype url: str - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "system_data": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "system_data": {"key": "systemData", "type": "SystemData"}, - "created_time": {"key": "properties.createdTime", "type": "iso-8601"}, - "last_modified_time": {"key": "properties.lastModifiedTime", "type": "iso-8601"}, - "size_in_kb": {"key": "properties.sizeInKb", "type": "int"}, - "type_properties_type": {"key": "properties.type", "type": "str"}, - "url": {"key": "properties.url", "type": "str"}, - } - - def __init__( - self, - *, - created_time: Optional[datetime.datetime] = None, - last_modified_time: Optional[datetime.datetime] = None, - size_in_kb: Optional[int] = None, - type_properties_type: Optional[str] = None, - url: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword created_time: Creation timestamp of the log file. - :paramtype created_time: ~datetime.datetime - :keyword last_modified_time: Last modified timestamp of the log file. - :paramtype last_modified_time: ~datetime.datetime - :keyword size_in_kb: Size (in KB) of the log file. - :paramtype size_in_kb: int - :keyword type_properties_type: Type of log file. Can be 'ServerLogs' or 'UpgradeLogs'. - :paramtype type_properties_type: str - :keyword url: URL to download the log file from. - :paramtype url: str - """ - super().__init__(**kwargs) - self.created_time = created_time - self.last_modified_time = last_modified_time - self.size_in_kb = size_in_kb - self.type_properties_type = type_properties_type - self.url = url - - -class CapturedLogList(_serialization.Model): - """List of log files. - - :ivar value: List of log files in a server. - :vartype value: list[~azure.mgmt.postgresqlflexibleservers.models.CapturedLog] - :ivar next_link: Link used to get the next page of results. - :vartype next_link: str - """ - - _attribute_map = { - "value": {"key": "value", "type": "[CapturedLog]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, *, value: Optional[list["_models.CapturedLog"]] = None, next_link: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword value: List of log files in a server. - :paramtype value: list[~azure.mgmt.postgresqlflexibleservers.models.CapturedLog] - :keyword next_link: Link used to get the next page of results. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class CheckNameAvailabilityRequest(_serialization.Model): - """The check availability request body. - - :ivar name: The name of the resource for which availability needs to be checked. - :vartype name: str - :ivar type: The resource type. - :vartype type: str - """ - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - } - - def __init__(self, *, name: Optional[str] = None, type: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword name: The name of the resource for which availability needs to be checked. - :paramtype name: str - :keyword type: The resource type. - :paramtype type: str - """ - super().__init__(**kwargs) - self.name = name - self.type = type - - -class CheckNameAvailabilityResponse(_serialization.Model): - """The check availability result. - - :ivar name_available: Indicates if the resource name is available. - :vartype name_available: bool - :ivar reason: The reason why the given name is not available. Known values are: "Invalid" and - "AlreadyExists". - :vartype reason: str or - ~azure.mgmt.postgresqlflexibleservers.models.CheckNameAvailabilityReason - :ivar message: Detailed reason why the given name is available. - :vartype message: str - """ - - _attribute_map = { - "name_available": {"key": "nameAvailable", "type": "bool"}, - "reason": {"key": "reason", "type": "str"}, - "message": {"key": "message", "type": "str"}, - } - - def __init__( - self, - *, - name_available: Optional[bool] = None, - reason: Optional[Union[str, "_models.CheckNameAvailabilityReason"]] = None, - message: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword name_available: Indicates if the resource name is available. - :paramtype name_available: bool - :keyword reason: The reason why the given name is not available. Known values are: "Invalid" - and "AlreadyExists". - :paramtype reason: str or - ~azure.mgmt.postgresqlflexibleservers.models.CheckNameAvailabilityReason - :keyword message: Detailed reason why the given name is available. - :paramtype message: str - """ - super().__init__(**kwargs) - self.name_available = name_available - self.reason = reason - self.message = message - - -class Cluster(_serialization.Model): - """Cluster properties of a server. - - :ivar cluster_size: Number of nodes assigned to the elastic cluster. - :vartype cluster_size: int - :ivar default_database_name: Default database name for the elastic cluster. - :vartype default_database_name: str - """ - - _attribute_map = { - "cluster_size": {"key": "clusterSize", "type": "int"}, - "default_database_name": {"key": "defaultDatabaseName", "type": "str"}, - } - - def __init__(self, *, cluster_size: int = 0, default_database_name: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword cluster_size: Number of nodes assigned to the elastic cluster. - :paramtype cluster_size: int - :keyword default_database_name: Default database name for the elastic cluster. - :paramtype default_database_name: str - """ - super().__init__(**kwargs) - self.cluster_size = cluster_size - self.default_database_name = default_database_name - - -class Configuration(ProxyResource): - """Configuration (also known as server parameter). - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Fully qualified resource ID for the resource. E.g. - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}". - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or - "Microsoft.Storage/storageAccounts". - :vartype type: str - :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy - information. - :vartype system_data: ~azure.mgmt.postgresqlflexibleservers.models.SystemData - :ivar value: Value of the configuration (also known as server parameter). Required to update - the value assigned to a specific modifiable configuration. - :vartype value: str - :ivar description: Description of the configuration (also known as server parameter). - :vartype description: str - :ivar default_value: Value assigned by default to the configuration (also known as server - parameter). - :vartype default_value: str - :ivar data_type: Data type of the configuration (also known as server parameter). Known values - are: "Boolean", "Numeric", "Integer", "Enumeration", "String", and "Set". - :vartype data_type: str or ~azure.mgmt.postgresqlflexibleservers.models.ConfigurationDataType - :ivar allowed_values: Allowed values of the configuration (also known as server parameter). - :vartype allowed_values: str - :ivar source: Source of the value assigned to the configuration (also known as server - parameter). Required to update the value assigned to a specific modifiable configuration. - :vartype source: str - :ivar is_dynamic_config: Indicates if it's a dynamic (true) or static (false) configuration - (also known as server parameter). Static server parameters require a server restart after - changing the value assigned to them, for the change to take effect. Dynamic server parameters - do not require a server restart after changing the value assigned to them, for the change to - take effect. - :vartype is_dynamic_config: bool - :ivar is_read_only: Indicates if it's a read-only (true) or modifiable (false) configuration - (also known as server parameter). - :vartype is_read_only: bool - :ivar is_config_pending_restart: Indicates if the value assigned to the configuration (also - known as server parameter) is pending a server restart for it to take effect. - :vartype is_config_pending_restart: bool - :ivar unit: Units in which the configuration (also known as server parameter) value is - expressed. - :vartype unit: str - :ivar documentation_link: Link pointing to the documentation of the configuration (also known - as server parameter). - :vartype documentation_link: str - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "system_data": {"readonly": True}, - "description": {"readonly": True}, - "default_value": {"readonly": True}, - "data_type": {"readonly": True}, - "allowed_values": {"readonly": True}, - "is_dynamic_config": {"readonly": True}, - "is_read_only": {"readonly": True}, - "is_config_pending_restart": {"readonly": True}, - "unit": {"readonly": True}, - "documentation_link": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "system_data": {"key": "systemData", "type": "SystemData"}, - "value": {"key": "properties.value", "type": "str"}, - "description": {"key": "properties.description", "type": "str"}, - "default_value": {"key": "properties.defaultValue", "type": "str"}, - "data_type": {"key": "properties.dataType", "type": "str"}, - "allowed_values": {"key": "properties.allowedValues", "type": "str"}, - "source": {"key": "properties.source", "type": "str"}, - "is_dynamic_config": {"key": "properties.isDynamicConfig", "type": "bool"}, - "is_read_only": {"key": "properties.isReadOnly", "type": "bool"}, - "is_config_pending_restart": {"key": "properties.isConfigPendingRestart", "type": "bool"}, - "unit": {"key": "properties.unit", "type": "str"}, - "documentation_link": {"key": "properties.documentationLink", "type": "str"}, - } - - def __init__(self, *, value: Optional[str] = None, source: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword value: Value of the configuration (also known as server parameter). Required to update - the value assigned to a specific modifiable configuration. - :paramtype value: str - :keyword source: Source of the value assigned to the configuration (also known as server - parameter). Required to update the value assigned to a specific modifiable configuration. - :paramtype source: str - """ - super().__init__(**kwargs) - self.value = value - self.description: Optional[str] = None - self.default_value: Optional[str] = None - self.data_type: Optional[Union[str, "_models.ConfigurationDataType"]] = None - self.allowed_values: Optional[str] = None - self.source = source - self.is_dynamic_config: Optional[bool] = None - self.is_read_only: Optional[bool] = None - self.is_config_pending_restart: Optional[bool] = None - self.unit: Optional[str] = None - self.documentation_link: Optional[str] = None - - -class ConfigurationForUpdate(_serialization.Model): - """Configuration (also known as server parameter). - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: Value of the configuration (also known as server parameter). Required to update - the value assigned to a specific modifiable configuration. - :vartype value: str - :ivar description: Description of the configuration (also known as server parameter). - :vartype description: str - :ivar default_value: Value assigned by default to the configuration (also known as server - parameter). - :vartype default_value: str - :ivar data_type: Data type of the configuration (also known as server parameter). Known values - are: "Boolean", "Numeric", "Integer", "Enumeration", "String", and "Set". - :vartype data_type: str or ~azure.mgmt.postgresqlflexibleservers.models.ConfigurationDataType - :ivar allowed_values: Allowed values of the configuration (also known as server parameter). - :vartype allowed_values: str - :ivar source: Source of the value assigned to the configuration (also known as server - parameter). Required to update the value assigned to a specific modifiable configuration. - :vartype source: str - :ivar is_dynamic_config: Indicates if it's a dynamic (true) or static (false) configuration - (also known as server parameter). Static server parameters require a server restart after - changing the value assigned to them, for the change to take effect. Dynamic server parameters - do not require a server restart after changing the value assigned to them, for the change to - take effect. - :vartype is_dynamic_config: bool - :ivar is_read_only: Indicates if it's a read-only (true) or modifiable (false) configuration - (also known as server parameter). - :vartype is_read_only: bool - :ivar is_config_pending_restart: Indicates if the value assigned to the configuration (also - known as server parameter) is pending a server restart for it to take effect. - :vartype is_config_pending_restart: bool - :ivar unit: Units in which the configuration (also known as server parameter) value is - expressed. - :vartype unit: str - :ivar documentation_link: Link pointing to the documentation of the configuration (also known - as server parameter). - :vartype documentation_link: str - """ - - _validation = { - "description": {"readonly": True}, - "default_value": {"readonly": True}, - "data_type": {"readonly": True}, - "allowed_values": {"readonly": True}, - "is_dynamic_config": {"readonly": True}, - "is_read_only": {"readonly": True}, - "is_config_pending_restart": {"readonly": True}, - "unit": {"readonly": True}, - "documentation_link": {"readonly": True}, - } - - _attribute_map = { - "value": {"key": "properties.value", "type": "str"}, - "description": {"key": "properties.description", "type": "str"}, - "default_value": {"key": "properties.defaultValue", "type": "str"}, - "data_type": {"key": "properties.dataType", "type": "str"}, - "allowed_values": {"key": "properties.allowedValues", "type": "str"}, - "source": {"key": "properties.source", "type": "str"}, - "is_dynamic_config": {"key": "properties.isDynamicConfig", "type": "bool"}, - "is_read_only": {"key": "properties.isReadOnly", "type": "bool"}, - "is_config_pending_restart": {"key": "properties.isConfigPendingRestart", "type": "bool"}, - "unit": {"key": "properties.unit", "type": "str"}, - "documentation_link": {"key": "properties.documentationLink", "type": "str"}, - } - - def __init__(self, *, value: Optional[str] = None, source: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword value: Value of the configuration (also known as server parameter). Required to update - the value assigned to a specific modifiable configuration. - :paramtype value: str - :keyword source: Source of the value assigned to the configuration (also known as server - parameter). Required to update the value assigned to a specific modifiable configuration. - :paramtype source: str - """ - super().__init__(**kwargs) - self.value = value - self.description: Optional[str] = None - self.default_value: Optional[str] = None - self.data_type: Optional[Union[str, "_models.ConfigurationDataType"]] = None - self.allowed_values: Optional[str] = None - self.source = source - self.is_dynamic_config: Optional[bool] = None - self.is_read_only: Optional[bool] = None - self.is_config_pending_restart: Optional[bool] = None - self.unit: Optional[str] = None - self.documentation_link: Optional[str] = None - - -class ConfigurationList(_serialization.Model): - """List of configurations (also known as server parameters). - - :ivar value: List of configurations (also known as server parameters). - :vartype value: list[~azure.mgmt.postgresqlflexibleservers.models.Configuration] - :ivar next_link: Link used to get the next page of results. - :vartype next_link: str - """ - - _attribute_map = { - "value": {"key": "value", "type": "[Configuration]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, *, value: Optional[list["_models.Configuration"]] = None, next_link: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword value: List of configurations (also known as server parameters). - :paramtype value: list[~azure.mgmt.postgresqlflexibleservers.models.Configuration] - :keyword next_link: Link used to get the next page of results. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class Database(ProxyResource): - """Represents a database. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Fully qualified resource ID for the resource. E.g. - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}". - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or - "Microsoft.Storage/storageAccounts". - :vartype type: str - :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy - information. - :vartype system_data: ~azure.mgmt.postgresqlflexibleservers.models.SystemData - :ivar charset: Character set of the database. - :vartype charset: str - :ivar collation: Collation of the database. - :vartype collation: str - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "system_data": {"readonly": True}, - "charset": {"pattern": r"^[a-zA-Z]+\w*$"}, - "collation": {"pattern": r"^[a-zA-Z\-]+([. ]|\w)*$"}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "system_data": {"key": "systemData", "type": "SystemData"}, - "charset": {"key": "properties.charset", "type": "str"}, - "collation": {"key": "properties.collation", "type": "str"}, - } - - def __init__(self, *, charset: Optional[str] = None, collation: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword charset: Character set of the database. - :paramtype charset: str - :keyword collation: Collation of the database. - :paramtype collation: str - """ - super().__init__(**kwargs) - self.charset = charset - self.collation = collation - - -class DatabaseList(_serialization.Model): - """List of all databases in a server. - - :ivar value: List of all databases in a server. - :vartype value: list[~azure.mgmt.postgresqlflexibleservers.models.Database] - :ivar next_link: Link used to get the next page of results. - :vartype next_link: str - """ - - _attribute_map = { - "value": {"key": "value", "type": "[Database]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, *, value: Optional[list["_models.Database"]] = None, next_link: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword value: List of all databases in a server. - :paramtype value: list[~azure.mgmt.postgresqlflexibleservers.models.Database] - :keyword next_link: Link used to get the next page of results. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class DatabaseMigrationState(_serialization.Model): - """Migration state of a database. - - :ivar database_name: Name of database. - :vartype database_name: str - :ivar migration_state: Migration state of a database. Known values are: "InProgress", - "WaitingForCutoverTrigger", "Failed", "Canceled", "Succeeded", and "Canceling". - :vartype migration_state: str or - ~azure.mgmt.postgresqlflexibleservers.models.MigrationDatabaseState - :ivar migration_operation: Migration operation of a database. - :vartype migration_operation: str - :ivar started_on: Start time of a migration state. - :vartype started_on: ~datetime.datetime - :ivar ended_on: End time of a migration state. - :vartype ended_on: ~datetime.datetime - :ivar full_load_queued_tables: Number of tables queued for the migration of a database. - :vartype full_load_queued_tables: int - :ivar full_load_errored_tables: Number of tables encountering errors during the migration of a - database. - :vartype full_load_errored_tables: int - :ivar full_load_loading_tables: Number of tables loading during the migration of a database. - :vartype full_load_loading_tables: int - :ivar full_load_completed_tables: Number of tables loaded during the migration of a database. - :vartype full_load_completed_tables: int - :ivar cdc_update_counter: Change Data Capture update counter. - :vartype cdc_update_counter: int - :ivar cdc_delete_counter: Change Data Capture delete counter. - :vartype cdc_delete_counter: int - :ivar cdc_insert_counter: Change Data Capture insert counter. - :vartype cdc_insert_counter: int - :ivar applied_changes: Change Data Capture applied changes counter. - :vartype applied_changes: int - :ivar incoming_changes: Change Data Capture incoming changes counter. - :vartype incoming_changes: int - :ivar latency: Lag in seconds between source and target during online phase. - :vartype latency: int - :ivar message: Error message, if any, for the migration state. - :vartype message: str - """ - - _attribute_map = { - "database_name": {"key": "databaseName", "type": "str"}, - "migration_state": {"key": "migrationState", "type": "str"}, - "migration_operation": {"key": "migrationOperation", "type": "str"}, - "started_on": {"key": "startedOn", "type": "iso-8601"}, - "ended_on": {"key": "endedOn", "type": "iso-8601"}, - "full_load_queued_tables": {"key": "fullLoadQueuedTables", "type": "int"}, - "full_load_errored_tables": {"key": "fullLoadErroredTables", "type": "int"}, - "full_load_loading_tables": {"key": "fullLoadLoadingTables", "type": "int"}, - "full_load_completed_tables": {"key": "fullLoadCompletedTables", "type": "int"}, - "cdc_update_counter": {"key": "cdcUpdateCounter", "type": "int"}, - "cdc_delete_counter": {"key": "cdcDeleteCounter", "type": "int"}, - "cdc_insert_counter": {"key": "cdcInsertCounter", "type": "int"}, - "applied_changes": {"key": "appliedChanges", "type": "int"}, - "incoming_changes": {"key": "incomingChanges", "type": "int"}, - "latency": {"key": "latency", "type": "int"}, - "message": {"key": "message", "type": "str"}, - } - - def __init__( - self, - *, - database_name: Optional[str] = None, - migration_state: Optional[Union[str, "_models.MigrationDatabaseState"]] = None, - migration_operation: Optional[str] = None, - started_on: Optional[datetime.datetime] = None, - ended_on: Optional[datetime.datetime] = None, - full_load_queued_tables: Optional[int] = None, - full_load_errored_tables: Optional[int] = None, - full_load_loading_tables: Optional[int] = None, - full_load_completed_tables: Optional[int] = None, - cdc_update_counter: Optional[int] = None, - cdc_delete_counter: Optional[int] = None, - cdc_insert_counter: Optional[int] = None, - applied_changes: Optional[int] = None, - incoming_changes: Optional[int] = None, - latency: Optional[int] = None, - message: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword database_name: Name of database. - :paramtype database_name: str - :keyword migration_state: Migration state of a database. Known values are: "InProgress", - "WaitingForCutoverTrigger", "Failed", "Canceled", "Succeeded", and "Canceling". - :paramtype migration_state: str or - ~azure.mgmt.postgresqlflexibleservers.models.MigrationDatabaseState - :keyword migration_operation: Migration operation of a database. - :paramtype migration_operation: str - :keyword started_on: Start time of a migration state. - :paramtype started_on: ~datetime.datetime - :keyword ended_on: End time of a migration state. - :paramtype ended_on: ~datetime.datetime - :keyword full_load_queued_tables: Number of tables queued for the migration of a database. - :paramtype full_load_queued_tables: int - :keyword full_load_errored_tables: Number of tables encountering errors during the migration of - a database. - :paramtype full_load_errored_tables: int - :keyword full_load_loading_tables: Number of tables loading during the migration of a database. - :paramtype full_load_loading_tables: int - :keyword full_load_completed_tables: Number of tables loaded during the migration of a - database. - :paramtype full_load_completed_tables: int - :keyword cdc_update_counter: Change Data Capture update counter. - :paramtype cdc_update_counter: int - :keyword cdc_delete_counter: Change Data Capture delete counter. - :paramtype cdc_delete_counter: int - :keyword cdc_insert_counter: Change Data Capture insert counter. - :paramtype cdc_insert_counter: int - :keyword applied_changes: Change Data Capture applied changes counter. - :paramtype applied_changes: int - :keyword incoming_changes: Change Data Capture incoming changes counter. - :paramtype incoming_changes: int - :keyword latency: Lag in seconds between source and target during online phase. - :paramtype latency: int - :keyword message: Error message, if any, for the migration state. - :paramtype message: str - """ - super().__init__(**kwargs) - self.database_name = database_name - self.migration_state = migration_state - self.migration_operation = migration_operation - self.started_on = started_on - self.ended_on = ended_on - self.full_load_queued_tables = full_load_queued_tables - self.full_load_errored_tables = full_load_errored_tables - self.full_load_loading_tables = full_load_loading_tables - self.full_load_completed_tables = full_load_completed_tables - self.cdc_update_counter = cdc_update_counter - self.cdc_delete_counter = cdc_delete_counter - self.cdc_insert_counter = cdc_insert_counter - self.applied_changes = applied_changes - self.incoming_changes = incoming_changes - self.latency = latency - self.message = message - - -class DataEncryption(_serialization.Model): - """Data encryption properties of a server. - - :ivar primary_key_uri: URI of the key in Azure Key Vault used for data encryption of the - primary storage associated to a server. - :vartype primary_key_uri: str - :ivar primary_user_assigned_identity_id: Identifier of the user assigned managed identity used - to access the key in Azure Key Vault for data encryption of the primary storage associated to a - server. - :vartype primary_user_assigned_identity_id: str - :ivar geo_backup_key_uri: Identifier of the user assigned managed identity used to access the - key in Azure Key Vault for data encryption of the geographically redundant storage associated - to a server that is configured to support geographically redundant backups. - :vartype geo_backup_key_uri: str - :ivar geo_backup_user_assigned_identity_id: Identifier of the user assigned managed identity - used to access the key in Azure Key Vault for data encryption of the geographically redundant - storage associated to a server that is configured to support geographically redundant backups. - :vartype geo_backup_user_assigned_identity_id: str - :ivar type: Data encryption type used by a server. Known values are: "SystemManaged" and - "AzureKeyVault". - :vartype type: str or ~azure.mgmt.postgresqlflexibleservers.models.DataEncryptionType - :ivar primary_encryption_key_status: Status of key used by a server configured with data - encryption based on customer managed key, to encrypt the primary storage associated to the - server. Known values are: "Valid" and "Invalid". - :vartype primary_encryption_key_status: str or - ~azure.mgmt.postgresqlflexibleservers.models.EncryptionKeyStatus - :ivar geo_backup_encryption_key_status: Status of key used by a server configured with data - encryption based on customer managed key, to encrypt the geographically redundant storage - associated to the server when it is configured to support geographically redundant backups. - Known values are: "Valid" and "Invalid". - :vartype geo_backup_encryption_key_status: str or - ~azure.mgmt.postgresqlflexibleservers.models.EncryptionKeyStatus - """ - - _attribute_map = { - "primary_key_uri": {"key": "primaryKeyURI", "type": "str"}, - "primary_user_assigned_identity_id": {"key": "primaryUserAssignedIdentityId", "type": "str"}, - "geo_backup_key_uri": {"key": "geoBackupKeyURI", "type": "str"}, - "geo_backup_user_assigned_identity_id": {"key": "geoBackupUserAssignedIdentityId", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "primary_encryption_key_status": {"key": "primaryEncryptionKeyStatus", "type": "str"}, - "geo_backup_encryption_key_status": {"key": "geoBackupEncryptionKeyStatus", "type": "str"}, - } - - def __init__( - self, - *, - primary_key_uri: Optional[str] = None, - primary_user_assigned_identity_id: Optional[str] = None, - geo_backup_key_uri: Optional[str] = None, - geo_backup_user_assigned_identity_id: Optional[str] = None, - type: Optional[Union[str, "_models.DataEncryptionType"]] = None, - primary_encryption_key_status: Optional[Union[str, "_models.EncryptionKeyStatus"]] = None, - geo_backup_encryption_key_status: Optional[Union[str, "_models.EncryptionKeyStatus"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword primary_key_uri: URI of the key in Azure Key Vault used for data encryption of the - primary storage associated to a server. - :paramtype primary_key_uri: str - :keyword primary_user_assigned_identity_id: Identifier of the user assigned managed identity - used to access the key in Azure Key Vault for data encryption of the primary storage associated - to a server. - :paramtype primary_user_assigned_identity_id: str - :keyword geo_backup_key_uri: Identifier of the user assigned managed identity used to access - the key in Azure Key Vault for data encryption of the geographically redundant storage - associated to a server that is configured to support geographically redundant backups. - :paramtype geo_backup_key_uri: str - :keyword geo_backup_user_assigned_identity_id: Identifier of the user assigned managed identity - used to access the key in Azure Key Vault for data encryption of the geographically redundant - storage associated to a server that is configured to support geographically redundant backups. - :paramtype geo_backup_user_assigned_identity_id: str - :keyword type: Data encryption type used by a server. Known values are: "SystemManaged" and - "AzureKeyVault". - :paramtype type: str or ~azure.mgmt.postgresqlflexibleservers.models.DataEncryptionType - :keyword primary_encryption_key_status: Status of key used by a server configured with data - encryption based on customer managed key, to encrypt the primary storage associated to the - server. Known values are: "Valid" and "Invalid". - :paramtype primary_encryption_key_status: str or - ~azure.mgmt.postgresqlflexibleservers.models.EncryptionKeyStatus - :keyword geo_backup_encryption_key_status: Status of key used by a server configured with data - encryption based on customer managed key, to encrypt the geographically redundant storage - associated to the server when it is configured to support geographically redundant backups. - Known values are: "Valid" and "Invalid". - :paramtype geo_backup_encryption_key_status: str or - ~azure.mgmt.postgresqlflexibleservers.models.EncryptionKeyStatus - """ - super().__init__(**kwargs) - self.primary_key_uri = primary_key_uri - self.primary_user_assigned_identity_id = primary_user_assigned_identity_id - self.geo_backup_key_uri = geo_backup_key_uri - self.geo_backup_user_assigned_identity_id = geo_backup_user_assigned_identity_id - self.type = type - self.primary_encryption_key_status = primary_encryption_key_status - self.geo_backup_encryption_key_status = geo_backup_encryption_key_status - - -class DbLevelValidationStatus(_serialization.Model): - """Validation status summary for a database. - - :ivar database_name: Name of database. - :vartype database_name: str - :ivar started_on: Start time of a database level validation. - :vartype started_on: ~datetime.datetime - :ivar ended_on: End time of a database level validation. - :vartype ended_on: ~datetime.datetime - :ivar summary: Summary of database level validations. - :vartype summary: list[~azure.mgmt.postgresqlflexibleservers.models.ValidationSummaryItem] - """ - - _attribute_map = { - "database_name": {"key": "databaseName", "type": "str"}, - "started_on": {"key": "startedOn", "type": "iso-8601"}, - "ended_on": {"key": "endedOn", "type": "iso-8601"}, - "summary": {"key": "summary", "type": "[ValidationSummaryItem]"}, - } - - def __init__( - self, - *, - database_name: Optional[str] = None, - started_on: Optional[datetime.datetime] = None, - ended_on: Optional[datetime.datetime] = None, - summary: Optional[list["_models.ValidationSummaryItem"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword database_name: Name of database. - :paramtype database_name: str - :keyword started_on: Start time of a database level validation. - :paramtype started_on: ~datetime.datetime - :keyword ended_on: End time of a database level validation. - :paramtype ended_on: ~datetime.datetime - :keyword summary: Summary of database level validations. - :paramtype summary: list[~azure.mgmt.postgresqlflexibleservers.models.ValidationSummaryItem] - """ - super().__init__(**kwargs) - self.database_name = database_name - self.started_on = started_on - self.ended_on = ended_on - self.summary = summary - - -class DbServerMetadata(_serialization.Model): - """Database server metadata. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar location: Location of database server. - :vartype location: str - :ivar version: Major version of PostgreSQL database engine. - :vartype version: str - :ivar storage_mb: Storage size (in MB) for database server. - :vartype storage_mb: int - :ivar sku: Compute tier and size of the database server. This object is empty for an Azure - Database for PostgreSQL single server. - :vartype sku: ~azure.mgmt.postgresqlflexibleservers.models.ServerSku - """ - - _validation = { - "location": {"readonly": True}, - } - - _attribute_map = { - "location": {"key": "location", "type": "str"}, - "version": {"key": "version", "type": "str"}, - "storage_mb": {"key": "storageMb", "type": "int"}, - "sku": {"key": "sku", "type": "ServerSku"}, - } - - def __init__( - self, - *, - version: Optional[str] = None, - storage_mb: Optional[int] = None, - sku: Optional["_models.ServerSku"] = None, - **kwargs: Any - ) -> None: - """ - :keyword version: Major version of PostgreSQL database engine. - :paramtype version: str - :keyword storage_mb: Storage size (in MB) for database server. - :paramtype storage_mb: int - :keyword sku: Compute tier and size of the database server. This object is empty for an Azure - Database for PostgreSQL single server. - :paramtype sku: ~azure.mgmt.postgresqlflexibleservers.models.ServerSku - """ - super().__init__(**kwargs) - self.location: Optional[str] = None - self.version = version - self.storage_mb = storage_mb - self.sku = sku - - -class DelegatedSubnetUsage(_serialization.Model): - """Delegated subnet usage data. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar subnet_name: Name of the delegated subnet for which IP addresses are in use. - :vartype subnet_name: str - :ivar usage: Number of IP addresses used by the delegated subnet. - :vartype usage: int - """ - - _validation = { - "subnet_name": {"readonly": True}, - "usage": {"readonly": True}, - } - - _attribute_map = { - "subnet_name": {"key": "subnetName", "type": "str"}, - "usage": {"key": "usage", "type": "int"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.subnet_name: Optional[str] = None - self.usage: Optional[int] = None - - -class ErrorAdditionalInfo(_serialization.Model): - """The resource management error additional info. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar type: The additional info type. - :vartype type: str - :ivar info: The additional info. - :vartype info: JSON - """ - - _validation = { - "type": {"readonly": True}, - "info": {"readonly": True}, - } - - _attribute_map = { - "type": {"key": "type", "type": "str"}, - "info": {"key": "info", "type": "object"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.type: Optional[str] = None - self.info: Optional[JSON] = None - - -class ErrorDetail(_serialization.Model): - """The error detail. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar code: The error code. - :vartype code: str - :ivar message: The error message. - :vartype message: str - :ivar target: The error target. - :vartype target: str - :ivar details: The error details. - :vartype details: list[~azure.mgmt.postgresqlflexibleservers.models.ErrorDetail] - :ivar additional_info: The error additional info. - :vartype additional_info: - list[~azure.mgmt.postgresqlflexibleservers.models.ErrorAdditionalInfo] - """ - - _validation = { - "code": {"readonly": True}, - "message": {"readonly": True}, - "target": {"readonly": True}, - "details": {"readonly": True}, - "additional_info": {"readonly": True}, - } - - _attribute_map = { - "code": {"key": "code", "type": "str"}, - "message": {"key": "message", "type": "str"}, - "target": {"key": "target", "type": "str"}, - "details": {"key": "details", "type": "[ErrorDetail]"}, - "additional_info": {"key": "additionalInfo", "type": "[ErrorAdditionalInfo]"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.code: Optional[str] = None - self.message: Optional[str] = None - self.target: Optional[str] = None - self.details: Optional[list["_models.ErrorDetail"]] = None - self.additional_info: Optional[list["_models.ErrorAdditionalInfo"]] = None - - -class ErrorResponse(_serialization.Model): - """Common error response for all Azure Resource Manager APIs to return error details for failed - operations. (This also follows the OData error response format.). - - :ivar error: The error object. - :vartype error: ~azure.mgmt.postgresqlflexibleservers.models.ErrorDetail - """ - - _attribute_map = { - "error": {"key": "error", "type": "ErrorDetail"}, - } - - def __init__(self, *, error: Optional["_models.ErrorDetail"] = None, **kwargs: Any) -> None: - """ - :keyword error: The error object. - :paramtype error: ~azure.mgmt.postgresqlflexibleservers.models.ErrorDetail - """ - super().__init__(**kwargs) - self.error = error - - -class FastProvisioningEditionCapability(CapabilityBase): - """Capability of a fast provisioning compute tier. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar status: The status of the capability. Known values are: "Visible", "Available", - "Default", and "Disabled". - :vartype status: str or ~azure.mgmt.postgresqlflexibleservers.models.CapabilityStatus - :ivar reason: The reason for the capability not being available. - :vartype reason: str - :ivar supported_tier: Compute tier supporting fast provisioning. - :vartype supported_tier: str - :ivar supported_sku: Compute name (SKU) supporting fast provisioning. - :vartype supported_sku: str - :ivar supported_storage_gb: Storage size (in GB) supporting fast provisioning. - :vartype supported_storage_gb: int - :ivar supported_server_versions: Major version of PostgreSQL database engine supporting fast - provisioning. - :vartype supported_server_versions: str - :ivar server_count: Count of servers in cache matching this specification. - :vartype server_count: int - """ - - _validation = { - "status": {"readonly": True}, - "reason": {"readonly": True}, - "supported_tier": {"readonly": True}, - "supported_sku": {"readonly": True}, - "supported_storage_gb": {"readonly": True}, - "supported_server_versions": {"readonly": True}, - "server_count": {"readonly": True}, - } - - _attribute_map = { - "status": {"key": "status", "type": "str"}, - "reason": {"key": "reason", "type": "str"}, - "supported_tier": {"key": "supportedTier", "type": "str"}, - "supported_sku": {"key": "supportedSku", "type": "str"}, - "supported_storage_gb": {"key": "supportedStorageGb", "type": "int"}, - "supported_server_versions": {"key": "supportedServerVersions", "type": "str"}, - "server_count": {"key": "serverCount", "type": "int"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.supported_tier: Optional[str] = None - self.supported_sku: Optional[str] = None - self.supported_storage_gb: Optional[int] = None - self.supported_server_versions: Optional[str] = None - self.server_count: Optional[int] = None - - -class FirewallRule(ProxyResource): - """Firewall rule. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to server. - - :ivar id: Fully qualified resource ID for the resource. E.g. - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}". - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or - "Microsoft.Storage/storageAccounts". - :vartype type: str - :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy - information. - :vartype system_data: ~azure.mgmt.postgresqlflexibleservers.models.SystemData - :ivar start_ip_address: IP address defining the start of the range of addresses of a firewall - rule. Must be expressed in IPv4 format. Required. - :vartype start_ip_address: str - :ivar end_ip_address: IP address defining the end of the range of addresses of a firewall rule. - Must be expressed in IPv4 format. Required. - :vartype end_ip_address: str - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "system_data": {"readonly": True}, - "start_ip_address": { - "required": True, - "pattern": r"^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$", - }, - "end_ip_address": { - "required": True, - "pattern": r"^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$", - }, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "system_data": {"key": "systemData", "type": "SystemData"}, - "start_ip_address": {"key": "properties.startIpAddress", "type": "str"}, - "end_ip_address": {"key": "properties.endIpAddress", "type": "str"}, - } - - def __init__(self, *, start_ip_address: str, end_ip_address: str, **kwargs: Any) -> None: - """ - :keyword start_ip_address: IP address defining the start of the range of addresses of a - firewall rule. Must be expressed in IPv4 format. Required. - :paramtype start_ip_address: str - :keyword end_ip_address: IP address defining the end of the range of addresses of a firewall - rule. Must be expressed in IPv4 format. Required. - :paramtype end_ip_address: str - """ - super().__init__(**kwargs) - self.start_ip_address = start_ip_address - self.end_ip_address = end_ip_address - - -class FirewallRuleList(_serialization.Model): - """List of firewall rules. - - :ivar value: List of firewall rules in a server. - :vartype value: list[~azure.mgmt.postgresqlflexibleservers.models.FirewallRule] - :ivar next_link: Link to retrieve next page of results. - :vartype next_link: str - """ - - _attribute_map = { - "value": {"key": "value", "type": "[FirewallRule]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, *, value: Optional[list["_models.FirewallRule"]] = None, next_link: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword value: List of firewall rules in a server. - :paramtype value: list[~azure.mgmt.postgresqlflexibleservers.models.FirewallRule] - :keyword next_link: Link to retrieve next page of results. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class HighAvailability(_serialization.Model): - """High availability properties of a server. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar mode: High availability mode for a server. Known values are: "ZoneRedundant" and - "SameZone". - :vartype mode: str or ~azure.mgmt.postgresqlflexibleservers.models.HighAvailabilityMode - :ivar state: Possible states of the standby server created when high availability is set to - SameZone or ZoneRedundant. Known values are: "NotEnabled", "CreatingStandby", - "ReplicatingData", "FailingOver", "Healthy", and "RemovingStandby". - :vartype state: str or ~azure.mgmt.postgresqlflexibleservers.models.HighAvailabilityState - :ivar standby_availability_zone: Availability zone associated to the standby server created - when high availability is set to SameZone or ZoneRedundant. - :vartype standby_availability_zone: str - """ - - _validation = { - "state": {"readonly": True}, - } - - _attribute_map = { - "mode": {"key": "mode", "type": "str"}, - "state": {"key": "state", "type": "str"}, - "standby_availability_zone": {"key": "standbyAvailabilityZone", "type": "str"}, - } - - def __init__( - self, - *, - mode: Optional[Union[str, "_models.HighAvailabilityMode"]] = None, - standby_availability_zone: str = "", - **kwargs: Any - ) -> None: - """ - :keyword mode: High availability mode for a server. Known values are: "ZoneRedundant" and - "SameZone". - :paramtype mode: str or ~azure.mgmt.postgresqlflexibleservers.models.HighAvailabilityMode - :keyword standby_availability_zone: Availability zone associated to the standby server created - when high availability is set to SameZone or ZoneRedundant. - :paramtype standby_availability_zone: str - """ - super().__init__(**kwargs) - self.mode = mode - self.state: Optional[Union[str, "_models.HighAvailabilityState"]] = None - self.standby_availability_zone = standby_availability_zone - - -class HighAvailabilityForPatch(_serialization.Model): - """High availability properties of a server. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar mode: High availability mode for a server. Known values are: "ZoneRedundant" and - "SameZone". - :vartype mode: str or ~azure.mgmt.postgresqlflexibleservers.models.HighAvailabilityMode - :ivar state: Possible states of the standby server created when high availability is set to - SameZone or ZoneRedundant. Known values are: "NotEnabled", "CreatingStandby", - "ReplicatingData", "FailingOver", "Healthy", and "RemovingStandby". - :vartype state: str or ~azure.mgmt.postgresqlflexibleservers.models.HighAvailabilityState - :ivar standby_availability_zone: Availability zone associated to the standby server created - when high availability is set to SameZone or ZoneRedundant. - :vartype standby_availability_zone: str - """ - - _validation = { - "state": {"readonly": True}, - } - - _attribute_map = { - "mode": {"key": "mode", "type": "str"}, - "state": {"key": "state", "type": "str"}, - "standby_availability_zone": {"key": "standbyAvailabilityZone", "type": "str"}, - } - - def __init__( - self, - *, - mode: Optional[Union[str, "_models.HighAvailabilityMode"]] = None, - standby_availability_zone: str = "", - **kwargs: Any - ) -> None: - """ - :keyword mode: High availability mode for a server. Known values are: "ZoneRedundant" and - "SameZone". - :paramtype mode: str or ~azure.mgmt.postgresqlflexibleservers.models.HighAvailabilityMode - :keyword standby_availability_zone: Availability zone associated to the standby server created - when high availability is set to SameZone or ZoneRedundant. - :paramtype standby_availability_zone: str - """ - super().__init__(**kwargs) - self.mode = mode - self.state: Optional[Union[str, "_models.HighAvailabilityState"]] = None - self.standby_availability_zone = standby_availability_zone - - -class ImpactRecord(_serialization.Model): - """Impact on some metric if this recommended action is applied. - - :ivar dimension_name: Dimension name. - :vartype dimension_name: str - :ivar unit: Dimension unit. - :vartype unit: str - :ivar query_id: Optional property that can be used to store the identifier of the query, if the - metric is for a specific query. - :vartype query_id: int - :ivar absolute_value: Absolute value. - :vartype absolute_value: float - """ - - _attribute_map = { - "dimension_name": {"key": "dimensionName", "type": "str"}, - "unit": {"key": "unit", "type": "str"}, - "query_id": {"key": "queryId", "type": "int"}, - "absolute_value": {"key": "absoluteValue", "type": "float"}, - } - - def __init__( - self, - *, - dimension_name: Optional[str] = None, - unit: Optional[str] = None, - query_id: Optional[int] = None, - absolute_value: Optional[float] = None, - **kwargs: Any - ) -> None: - """ - :keyword dimension_name: Dimension name. - :paramtype dimension_name: str - :keyword unit: Dimension unit. - :paramtype unit: str - :keyword query_id: Optional property that can be used to store the identifier of the query, if - the metric is for a specific query. - :paramtype query_id: int - :keyword absolute_value: Absolute value. - :paramtype absolute_value: float - """ - super().__init__(**kwargs) - self.dimension_name = dimension_name - self.unit = unit - self.query_id = query_id - self.absolute_value = absolute_value - - -class LtrPreBackupRequest(BackupRequestBase): - """A request that is made for pre-backup. - - All required parameters must be populated in order to send to server. - - :ivar backup_settings: Backup Settings. Required. - :vartype backup_settings: ~azure.mgmt.postgresqlflexibleservers.models.BackupSettings - """ - - -class LtrPreBackupResponse(_serialization.Model): - """Response for the LTR pre-backup API call. - - All required parameters must be populated in order to send to server. - - :ivar number_of_containers: Number of storage containers the plugin will use during backup. - More than one containers may be used for size limitations, parallelism, or redundancy etc. - Required. - :vartype number_of_containers: int - """ - - _validation = { - "number_of_containers": {"required": True}, - } - - _attribute_map = { - "number_of_containers": {"key": "properties.numberOfContainers", "type": "int"}, - } - - def __init__(self, *, number_of_containers: int, **kwargs: Any) -> None: - """ - :keyword number_of_containers: Number of storage containers the plugin will use during backup. - More than one containers may be used for size limitations, parallelism, or redundancy etc. - Required. - :paramtype number_of_containers: int - """ - super().__init__(**kwargs) - self.number_of_containers = number_of_containers - - -class LtrServerBackupOperationList(_serialization.Model): - """A list of long term retention backup operations for server. - - :ivar value: The list of long term retention server backup operations. - :vartype value: - list[~azure.mgmt.postgresqlflexibleservers.models.BackupsLongTermRetentionOperation] - :ivar next_link: The link used to get the next page of operations. - :vartype next_link: str - """ - - _attribute_map = { - "value": {"key": "value", "type": "[BackupsLongTermRetentionOperation]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, - *, - value: Optional[list["_models.BackupsLongTermRetentionOperation"]] = None, - next_link: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword value: The list of long term retention server backup operations. - :paramtype value: - list[~azure.mgmt.postgresqlflexibleservers.models.BackupsLongTermRetentionOperation] - :keyword next_link: The link used to get the next page of operations. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class MaintenanceWindow(_serialization.Model): - """Maintenance window properties of a server. - - :ivar custom_window: Indicates whether custom window is enabled or disabled. - :vartype custom_window: str - :ivar start_hour: Start hour to be used for maintenance window. - :vartype start_hour: int - :ivar start_minute: Start minute to be used for maintenance window. - :vartype start_minute: int - :ivar day_of_week: Day of the week to be used for maintenance window. - :vartype day_of_week: int - """ - - _attribute_map = { - "custom_window": {"key": "customWindow", "type": "str"}, - "start_hour": {"key": "startHour", "type": "int"}, - "start_minute": {"key": "startMinute", "type": "int"}, - "day_of_week": {"key": "dayOfWeek", "type": "int"}, - } - - def __init__( - self, - *, - custom_window: str = "Disabled", - start_hour: int = 0, - start_minute: int = 0, - day_of_week: int = 0, - **kwargs: Any - ) -> None: - """ - :keyword custom_window: Indicates whether custom window is enabled or disabled. - :paramtype custom_window: str - :keyword start_hour: Start hour to be used for maintenance window. - :paramtype start_hour: int - :keyword start_minute: Start minute to be used for maintenance window. - :paramtype start_minute: int - :keyword day_of_week: Day of the week to be used for maintenance window. - :paramtype day_of_week: int - """ - super().__init__(**kwargs) - self.custom_window = custom_window - self.start_hour = start_hour - self.start_minute = start_minute - self.day_of_week = day_of_week - - -class MaintenanceWindowForPatch(_serialization.Model): - """Maintenance window properties of a server. - - :ivar custom_window: Indicates whether custom window is enabled or disabled. - :vartype custom_window: str - :ivar start_hour: Start hour to be used for maintenance window. - :vartype start_hour: int - :ivar start_minute: Start minute to be used for maintenance window. - :vartype start_minute: int - :ivar day_of_week: Day of the week to be used for maintenance window. - :vartype day_of_week: int - """ - - _attribute_map = { - "custom_window": {"key": "customWindow", "type": "str"}, - "start_hour": {"key": "startHour", "type": "int"}, - "start_minute": {"key": "startMinute", "type": "int"}, - "day_of_week": {"key": "dayOfWeek", "type": "int"}, - } - - def __init__( - self, - *, - custom_window: Optional[str] = None, - start_hour: Optional[int] = None, - start_minute: Optional[int] = None, - day_of_week: Optional[int] = None, - **kwargs: Any - ) -> None: - """ - :keyword custom_window: Indicates whether custom window is enabled or disabled. - :paramtype custom_window: str - :keyword start_hour: Start hour to be used for maintenance window. - :paramtype start_hour: int - :keyword start_minute: Start minute to be used for maintenance window. - :paramtype start_minute: int - :keyword day_of_week: Day of the week to be used for maintenance window. - :paramtype day_of_week: int - """ - super().__init__(**kwargs) - self.custom_window = custom_window - self.start_hour = start_hour - self.start_minute = start_minute - self.day_of_week = day_of_week - - -class TrackedResource(Resource): - """The resource model definition for an Azure Resource Manager tracked top level resource which - has 'tags' and a 'location'. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to server. - - :ivar id: Fully qualified resource ID for the resource. E.g. - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}". - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or - "Microsoft.Storage/storageAccounts". - :vartype type: str - :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy - information. - :vartype system_data: ~azure.mgmt.postgresqlflexibleservers.models.SystemData - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - :ivar location: The geo-location where the resource lives. Required. - :vartype location: str - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "system_data": {"readonly": True}, - "location": {"required": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "system_data": {"key": "systemData", "type": "SystemData"}, - "tags": {"key": "tags", "type": "{str}"}, - "location": {"key": "location", "type": "str"}, - } - - def __init__(self, *, location: str, tags: Optional[dict[str, str]] = None, **kwargs: Any) -> None: - """ - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword location: The geo-location where the resource lives. Required. - :paramtype location: str - """ - super().__init__(**kwargs) - self.tags = tags - self.location = location - - -class Migration(TrackedResource): - """Properties of a migration. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to server. - - :ivar id: Fully qualified resource ID for the resource. E.g. - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}". - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or - "Microsoft.Storage/storageAccounts". - :vartype type: str - :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy - information. - :vartype system_data: ~azure.mgmt.postgresqlflexibleservers.models.SystemData - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - :ivar location: The geo-location where the resource lives. Required. - :vartype location: str - :ivar migration_id: Identifier of a migration. - :vartype migration_id: str - :ivar current_status: Current status of a migration. - :vartype current_status: ~azure.mgmt.postgresqlflexibleservers.models.MigrationStatus - :ivar migration_instance_resource_id: Identifier of the private endpoint migration instance. - :vartype migration_instance_resource_id: str - :ivar migration_mode: Mode used to perform the migration: Online or Offline. Known values are: - "Offline" and "Online". - :vartype migration_mode: str or ~azure.mgmt.postgresqlflexibleservers.models.MigrationMode - :ivar migration_option: Supported option for a migration. Known values are: "Validate", - "Migrate", and "ValidateAndMigrate". - :vartype migration_option: str or ~azure.mgmt.postgresqlflexibleservers.models.MigrationOption - :ivar source_type: Source server type used for the migration: ApsaraDB_RDS, AWS, AWS_AURORA, - AWS_EC2, AWS_RDS, AzureVM, Crunchy_PostgreSQL, Digital_Ocean_Droplets, - Digital_Ocean_PostgreSQL, EDB, EDB_Oracle_Server, EDB_PostgreSQL, GCP, GCP_AlloyDB, - GCP_CloudSQL, GCP_Compute, Heroku_PostgreSQL, Huawei_Compute, Huawei_RDS, OnPremises, - PostgreSQLCosmosDB, PostgreSQLFlexibleServer, PostgreSQLSingleServer, or Supabase_PostgreSQL. - Known values are: "OnPremises", "AWS", "GCP", "AzureVM", "PostgreSQLSingleServer", "AWS_RDS", - "AWS_AURORA", "AWS_EC2", "GCP_CloudSQL", "GCP_AlloyDB", "GCP_Compute", "EDB", - "EDB_Oracle_Server", "EDB_PostgreSQL", "PostgreSQLFlexibleServer", "PostgreSQLCosmosDB", - "Huawei_RDS", "Huawei_Compute", "Heroku_PostgreSQL", "Crunchy_PostgreSQL", "ApsaraDB_RDS", - "Digital_Ocean_Droplets", "Digital_Ocean_PostgreSQL", and "Supabase_PostgreSQL". - :vartype source_type: str or ~azure.mgmt.postgresqlflexibleservers.models.SourceType - :ivar ssl_mode: SSL mode used by a migration. Default SSL mode for 'PostgreSQLSingleServer' is - 'VerifyFull'. Default SSL mode for other source types is 'Prefer'. Known values are: "Prefer", - "Require", "VerifyCA", and "VerifyFull". - :vartype ssl_mode: str or ~azure.mgmt.postgresqlflexibleservers.models.SslMode - :ivar source_db_server_metadata: Metadata of source database server. - :vartype source_db_server_metadata: - ~azure.mgmt.postgresqlflexibleservers.models.DbServerMetadata - :ivar target_db_server_metadata: Metadata of target database server. - :vartype target_db_server_metadata: - ~azure.mgmt.postgresqlflexibleservers.models.DbServerMetadata - :ivar source_db_server_resource_id: Identifier of the source database server resource, when - 'sourceType' is 'PostgreSQLSingleServer'. For other source types this must be set to - ipaddress:port@username or hostname:port@username. - :vartype source_db_server_resource_id: str - :ivar source_db_server_fully_qualified_domain_name: Fully qualified domain name (FQDN) or IP - address of the source server. This property is optional. When provided, the migration service - will always use it to connect to the source server. - :vartype source_db_server_fully_qualified_domain_name: str - :ivar target_db_server_resource_id: Identifier of the target database server resource. - :vartype target_db_server_resource_id: str - :ivar target_db_server_fully_qualified_domain_name: Fully qualified domain name (FQDN) or IP - address of the target server. This property is optional. When provided, the migration service - will always use it to connect to the target server. - :vartype target_db_server_fully_qualified_domain_name: str - :ivar secret_parameters: Migration secret parameters. - :vartype secret_parameters: - ~azure.mgmt.postgresqlflexibleservers.models.MigrationSecretParameters - :ivar dbs_to_migrate: Names of databases to migrate. - :vartype dbs_to_migrate: list[str] - :ivar setup_logical_replication_on_source_db_if_needed: Indicates whether to setup logical - replication on source server, if needed. Known values are: "True" and "False". - :vartype setup_logical_replication_on_source_db_if_needed: str or - ~azure.mgmt.postgresqlflexibleservers.models.LogicalReplicationOnSourceServer - :ivar overwrite_dbs_in_target: Indicates if databases on the target server can be overwritten - when already present. If set to 'False', when the migration workflow detects that the database - already exists on the target server, it will wait for a confirmation. Known values are: "True" - and "False". - :vartype overwrite_dbs_in_target: str or - ~azure.mgmt.postgresqlflexibleservers.models.OverwriteDatabasesOnTargetServer - :ivar migration_window_start_time_in_utc: Start time (UTC) for migration window. - :vartype migration_window_start_time_in_utc: ~datetime.datetime - :ivar migration_window_end_time_in_utc: End time (UTC) for migration window. - :vartype migration_window_end_time_in_utc: ~datetime.datetime - :ivar migrate_roles: Indicates if roles and permissions must be migrated. Known values are: - "True" and "False". - :vartype migrate_roles: str or - ~azure.mgmt.postgresqlflexibleservers.models.MigrateRolesAndPermissions - :ivar start_data_migration: Indicates if data migration must start right away. Known values - are: "True" and "False". - :vartype start_data_migration: str or - ~azure.mgmt.postgresqlflexibleservers.models.StartDataMigration - :ivar trigger_cutover: Indicates if cutover must be triggered for the entire migration. Known - values are: "True" and "False". - :vartype trigger_cutover: str or ~azure.mgmt.postgresqlflexibleservers.models.TriggerCutover - :ivar dbs_to_trigger_cutover_on: When you want to trigger cutover for specific databases set - 'triggerCutover' to 'True' and the names of the specific databases in this array. - :vartype dbs_to_trigger_cutover_on: list[str] - :ivar cancel: Indicates if cancel must be triggered for the entire migration. Known values are: - "True" and "False". - :vartype cancel: str or ~azure.mgmt.postgresqlflexibleservers.models.Cancel - :ivar dbs_to_cancel_migration_on: When you want to trigger cancel for specific databases set - 'triggerCutover' to 'True' and the names of the specific databases in this array. - :vartype dbs_to_cancel_migration_on: list[str] - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "system_data": {"readonly": True}, - "location": {"required": True}, - "migration_id": {"readonly": True}, - "current_status": {"readonly": True}, - "source_db_server_metadata": {"readonly": True}, - "target_db_server_metadata": {"readonly": True}, - "target_db_server_resource_id": {"readonly": True}, - "dbs_to_migrate": {"max_items": 50, "min_items": 0}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "system_data": {"key": "systemData", "type": "SystemData"}, - "tags": {"key": "tags", "type": "{str}"}, - "location": {"key": "location", "type": "str"}, - "migration_id": {"key": "properties.migrationId", "type": "str"}, - "current_status": {"key": "properties.currentStatus", "type": "MigrationStatus"}, - "migration_instance_resource_id": {"key": "properties.migrationInstanceResourceId", "type": "str"}, - "migration_mode": {"key": "properties.migrationMode", "type": "str"}, - "migration_option": {"key": "properties.migrationOption", "type": "str"}, - "source_type": {"key": "properties.sourceType", "type": "str"}, - "ssl_mode": {"key": "properties.sslMode", "type": "str"}, - "source_db_server_metadata": {"key": "properties.sourceDbServerMetadata", "type": "DbServerMetadata"}, - "target_db_server_metadata": {"key": "properties.targetDbServerMetadata", "type": "DbServerMetadata"}, - "source_db_server_resource_id": {"key": "properties.sourceDbServerResourceId", "type": "str"}, - "source_db_server_fully_qualified_domain_name": { - "key": "properties.sourceDbServerFullyQualifiedDomainName", - "type": "str", - }, - "target_db_server_resource_id": {"key": "properties.targetDbServerResourceId", "type": "str"}, - "target_db_server_fully_qualified_domain_name": { - "key": "properties.targetDbServerFullyQualifiedDomainName", - "type": "str", - }, - "secret_parameters": {"key": "properties.secretParameters", "type": "MigrationSecretParameters"}, - "dbs_to_migrate": {"key": "properties.dbsToMigrate", "type": "[str]"}, - "setup_logical_replication_on_source_db_if_needed": { - "key": "properties.setupLogicalReplicationOnSourceDbIfNeeded", - "type": "str", - }, - "overwrite_dbs_in_target": {"key": "properties.overwriteDbsInTarget", "type": "str"}, - "migration_window_start_time_in_utc": {"key": "properties.migrationWindowStartTimeInUtc", "type": "iso-8601"}, - "migration_window_end_time_in_utc": {"key": "properties.migrationWindowEndTimeInUtc", "type": "iso-8601"}, - "migrate_roles": {"key": "properties.migrateRoles", "type": "str"}, - "start_data_migration": {"key": "properties.startDataMigration", "type": "str"}, - "trigger_cutover": {"key": "properties.triggerCutover", "type": "str"}, - "dbs_to_trigger_cutover_on": {"key": "properties.dbsToTriggerCutoverOn", "type": "[str]"}, - "cancel": {"key": "properties.cancel", "type": "str"}, - "dbs_to_cancel_migration_on": {"key": "properties.dbsToCancelMigrationOn", "type": "[str]"}, - } - - def __init__( # pylint: disable=too-many-locals - self, - *, - location: str, - tags: Optional[dict[str, str]] = None, - migration_instance_resource_id: Optional[str] = None, - migration_mode: Optional[Union[str, "_models.MigrationMode"]] = None, - migration_option: Optional[Union[str, "_models.MigrationOption"]] = None, - source_type: Optional[Union[str, "_models.SourceType"]] = None, - ssl_mode: Optional[Union[str, "_models.SslMode"]] = None, - source_db_server_resource_id: Optional[str] = None, - source_db_server_fully_qualified_domain_name: Optional[str] = None, - target_db_server_fully_qualified_domain_name: Optional[str] = None, - secret_parameters: Optional["_models.MigrationSecretParameters"] = None, - dbs_to_migrate: Optional[list[str]] = None, - setup_logical_replication_on_source_db_if_needed: Optional[ - Union[str, "_models.LogicalReplicationOnSourceServer"] - ] = None, - overwrite_dbs_in_target: Optional[Union[str, "_models.OverwriteDatabasesOnTargetServer"]] = None, - migration_window_start_time_in_utc: Optional[datetime.datetime] = None, - migration_window_end_time_in_utc: Optional[datetime.datetime] = None, - migrate_roles: Optional[Union[str, "_models.MigrateRolesAndPermissions"]] = None, - start_data_migration: Optional[Union[str, "_models.StartDataMigration"]] = None, - trigger_cutover: Optional[Union[str, "_models.TriggerCutover"]] = None, - dbs_to_trigger_cutover_on: Optional[list[str]] = None, - cancel: Optional[Union[str, "_models.Cancel"]] = None, - dbs_to_cancel_migration_on: Optional[list[str]] = None, - **kwargs: Any - ) -> None: - """ - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword location: The geo-location where the resource lives. Required. - :paramtype location: str - :keyword migration_instance_resource_id: Identifier of the private endpoint migration instance. - :paramtype migration_instance_resource_id: str - :keyword migration_mode: Mode used to perform the migration: Online or Offline. Known values - are: "Offline" and "Online". - :paramtype migration_mode: str or ~azure.mgmt.postgresqlflexibleservers.models.MigrationMode - :keyword migration_option: Supported option for a migration. Known values are: "Validate", - "Migrate", and "ValidateAndMigrate". - :paramtype migration_option: str or - ~azure.mgmt.postgresqlflexibleservers.models.MigrationOption - :keyword source_type: Source server type used for the migration: ApsaraDB_RDS, AWS, AWS_AURORA, - AWS_EC2, AWS_RDS, AzureVM, Crunchy_PostgreSQL, Digital_Ocean_Droplets, - Digital_Ocean_PostgreSQL, EDB, EDB_Oracle_Server, EDB_PostgreSQL, GCP, GCP_AlloyDB, - GCP_CloudSQL, GCP_Compute, Heroku_PostgreSQL, Huawei_Compute, Huawei_RDS, OnPremises, - PostgreSQLCosmosDB, PostgreSQLFlexibleServer, PostgreSQLSingleServer, or Supabase_PostgreSQL. - Known values are: "OnPremises", "AWS", "GCP", "AzureVM", "PostgreSQLSingleServer", "AWS_RDS", - "AWS_AURORA", "AWS_EC2", "GCP_CloudSQL", "GCP_AlloyDB", "GCP_Compute", "EDB", - "EDB_Oracle_Server", "EDB_PostgreSQL", "PostgreSQLFlexibleServer", "PostgreSQLCosmosDB", - "Huawei_RDS", "Huawei_Compute", "Heroku_PostgreSQL", "Crunchy_PostgreSQL", "ApsaraDB_RDS", - "Digital_Ocean_Droplets", "Digital_Ocean_PostgreSQL", and "Supabase_PostgreSQL". - :paramtype source_type: str or ~azure.mgmt.postgresqlflexibleservers.models.SourceType - :keyword ssl_mode: SSL mode used by a migration. Default SSL mode for 'PostgreSQLSingleServer' - is 'VerifyFull'. Default SSL mode for other source types is 'Prefer'. Known values are: - "Prefer", "Require", "VerifyCA", and "VerifyFull". - :paramtype ssl_mode: str or ~azure.mgmt.postgresqlflexibleservers.models.SslMode - :keyword source_db_server_resource_id: Identifier of the source database server resource, when - 'sourceType' is 'PostgreSQLSingleServer'. For other source types this must be set to - ipaddress:port@username or hostname:port@username. - :paramtype source_db_server_resource_id: str - :keyword source_db_server_fully_qualified_domain_name: Fully qualified domain name (FQDN) or IP - address of the source server. This property is optional. When provided, the migration service - will always use it to connect to the source server. - :paramtype source_db_server_fully_qualified_domain_name: str - :keyword target_db_server_fully_qualified_domain_name: Fully qualified domain name (FQDN) or IP - address of the target server. This property is optional. When provided, the migration service - will always use it to connect to the target server. - :paramtype target_db_server_fully_qualified_domain_name: str - :keyword secret_parameters: Migration secret parameters. - :paramtype secret_parameters: - ~azure.mgmt.postgresqlflexibleservers.models.MigrationSecretParameters - :keyword dbs_to_migrate: Names of databases to migrate. - :paramtype dbs_to_migrate: list[str] - :keyword setup_logical_replication_on_source_db_if_needed: Indicates whether to setup logical - replication on source server, if needed. Known values are: "True" and "False". - :paramtype setup_logical_replication_on_source_db_if_needed: str or - ~azure.mgmt.postgresqlflexibleservers.models.LogicalReplicationOnSourceServer - :keyword overwrite_dbs_in_target: Indicates if databases on the target server can be - overwritten when already present. If set to 'False', when the migration workflow detects that - the database already exists on the target server, it will wait for a confirmation. Known values - are: "True" and "False". - :paramtype overwrite_dbs_in_target: str or - ~azure.mgmt.postgresqlflexibleservers.models.OverwriteDatabasesOnTargetServer - :keyword migration_window_start_time_in_utc: Start time (UTC) for migration window. - :paramtype migration_window_start_time_in_utc: ~datetime.datetime - :keyword migration_window_end_time_in_utc: End time (UTC) for migration window. - :paramtype migration_window_end_time_in_utc: ~datetime.datetime - :keyword migrate_roles: Indicates if roles and permissions must be migrated. Known values are: - "True" and "False". - :paramtype migrate_roles: str or - ~azure.mgmt.postgresqlflexibleservers.models.MigrateRolesAndPermissions - :keyword start_data_migration: Indicates if data migration must start right away. Known values - are: "True" and "False". - :paramtype start_data_migration: str or - ~azure.mgmt.postgresqlflexibleservers.models.StartDataMigration - :keyword trigger_cutover: Indicates if cutover must be triggered for the entire migration. - Known values are: "True" and "False". - :paramtype trigger_cutover: str or ~azure.mgmt.postgresqlflexibleservers.models.TriggerCutover - :keyword dbs_to_trigger_cutover_on: When you want to trigger cutover for specific databases set - 'triggerCutover' to 'True' and the names of the specific databases in this array. - :paramtype dbs_to_trigger_cutover_on: list[str] - :keyword cancel: Indicates if cancel must be triggered for the entire migration. Known values - are: "True" and "False". - :paramtype cancel: str or ~azure.mgmt.postgresqlflexibleservers.models.Cancel - :keyword dbs_to_cancel_migration_on: When you want to trigger cancel for specific databases set - 'triggerCutover' to 'True' and the names of the specific databases in this array. - :paramtype dbs_to_cancel_migration_on: list[str] - """ - super().__init__(tags=tags, location=location, **kwargs) - self.migration_id: Optional[str] = None - self.current_status: Optional["_models.MigrationStatus"] = None - self.migration_instance_resource_id = migration_instance_resource_id - self.migration_mode = migration_mode - self.migration_option = migration_option - self.source_type = source_type - self.ssl_mode = ssl_mode - self.source_db_server_metadata: Optional["_models.DbServerMetadata"] = None - self.target_db_server_metadata: Optional["_models.DbServerMetadata"] = None - self.source_db_server_resource_id = source_db_server_resource_id - self.source_db_server_fully_qualified_domain_name = source_db_server_fully_qualified_domain_name - self.target_db_server_resource_id: Optional[str] = None - self.target_db_server_fully_qualified_domain_name = target_db_server_fully_qualified_domain_name - self.secret_parameters = secret_parameters - self.dbs_to_migrate = dbs_to_migrate - self.setup_logical_replication_on_source_db_if_needed = setup_logical_replication_on_source_db_if_needed - self.overwrite_dbs_in_target = overwrite_dbs_in_target - self.migration_window_start_time_in_utc = migration_window_start_time_in_utc - self.migration_window_end_time_in_utc = migration_window_end_time_in_utc - self.migrate_roles = migrate_roles - self.start_data_migration = start_data_migration - self.trigger_cutover = trigger_cutover - self.dbs_to_trigger_cutover_on = dbs_to_trigger_cutover_on - self.cancel = cancel - self.dbs_to_cancel_migration_on = dbs_to_cancel_migration_on - - -class MigrationList(_serialization.Model): - """List of migrations. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: List of migrations. - :vartype value: list[~azure.mgmt.postgresqlflexibleservers.models.Migration] - :ivar next_link: Link used to get the next page of results. - :vartype next_link: str - """ - - _validation = { - "value": {"readonly": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[Migration]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, *, next_link: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword next_link: Link used to get the next page of results. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value: Optional[list["_models.Migration"]] = None - self.next_link = next_link - - -class MigrationNameAvailability(_serialization.Model): - """Availability of a migration name. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to server. - - :ivar name: Name of the migration to check for validity and availability. Required. - :vartype name: str - :ivar type: Type of resource. Required. - :vartype type: str - :ivar name_available: Indicates if the migration name is available. - :vartype name_available: bool - :ivar reason: Migration name availability reason. Known values are: "Invalid" and - "AlreadyExists". - :vartype reason: str or - ~azure.mgmt.postgresqlflexibleservers.models.MigrationNameAvailabilityReason - :ivar message: Migration name availability message. - :vartype message: str - """ - - _validation = { - "name": {"required": True}, - "type": {"required": True}, - "name_available": {"readonly": True}, - "reason": {"readonly": True}, - "message": {"readonly": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "name_available": {"key": "nameAvailable", "type": "bool"}, - "reason": {"key": "reason", "type": "str"}, - "message": {"key": "message", "type": "str"}, - } - - def __init__(self, *, name: str, type: str, **kwargs: Any) -> None: - """ - :keyword name: Name of the migration to check for validity and availability. Required. - :paramtype name: str - :keyword type: Type of resource. Required. - :paramtype type: str - """ - super().__init__(**kwargs) - self.name = name - self.type = type - self.name_available: Optional[bool] = None - self.reason: Optional[Union[str, "_models.MigrationNameAvailabilityReason"]] = None - self.message: Optional[str] = None - - -class MigrationResourceForPatch(_serialization.Model): - """Migration. - - :ivar tags: Application-specific metadata in the form of key-value pairs. - :vartype tags: dict[str, str] - :ivar source_db_server_resource_id: Identifier of the source database server resource, when - 'sourceType' is 'PostgreSQLSingleServer'. For other source types this must be set to - ipaddress:port@username or hostname:port@username. - :vartype source_db_server_resource_id: str - :ivar source_db_server_fully_qualified_domain_name: Fully qualified domain name (FQDN) or IP - address of the source server. This property is optional. When provided, the migration service - will always use it to connect to the source server. - :vartype source_db_server_fully_qualified_domain_name: str - :ivar target_db_server_fully_qualified_domain_name: Fully qualified domain name (FQDN) or IP - address of the target server. This property is optional. When provided, the migration service - will always use it to connect to the target server. - :vartype target_db_server_fully_qualified_domain_name: str - :ivar secret_parameters: Migration secret parameters. - :vartype secret_parameters: - ~azure.mgmt.postgresqlflexibleservers.models.MigrationSecretParametersForPatch - :ivar dbs_to_migrate: Names of databases to migrate. - :vartype dbs_to_migrate: list[str] - :ivar setup_logical_replication_on_source_db_if_needed: Indicates whether to setup logical - replication on source server, if needed. Known values are: "True" and "False". - :vartype setup_logical_replication_on_source_db_if_needed: str or - ~azure.mgmt.postgresqlflexibleservers.models.LogicalReplicationOnSourceServer - :ivar overwrite_dbs_in_target: Indicates if databases on the target server can be overwritten - when already present. If set to 'False', when the migration workflow detects that the database - already exists on the target server, it will wait for a confirmation. Known values are: "True" - and "False". - :vartype overwrite_dbs_in_target: str or - ~azure.mgmt.postgresqlflexibleservers.models.OverwriteDatabasesOnTargetServer - :ivar migration_window_start_time_in_utc: Start time (UTC) for migration window. - :vartype migration_window_start_time_in_utc: ~datetime.datetime - :ivar migrate_roles: Indicates if roles and permissions must be migrated. Known values are: - "True" and "False". - :vartype migrate_roles: str or - ~azure.mgmt.postgresqlflexibleservers.models.MigrateRolesAndPermissions - :ivar start_data_migration: Indicates if data migration must start right away. Known values - are: "True" and "False". - :vartype start_data_migration: str or - ~azure.mgmt.postgresqlflexibleservers.models.StartDataMigration - :ivar trigger_cutover: Indicates if cutover must be triggered for the entire migration. Known - values are: "True" and "False". - :vartype trigger_cutover: str or ~azure.mgmt.postgresqlflexibleservers.models.TriggerCutover - :ivar dbs_to_trigger_cutover_on: When you want to trigger cutover for specific databases set - 'triggerCutover' to 'True' and the names of the specific databases in this array. - :vartype dbs_to_trigger_cutover_on: list[str] - :ivar cancel: Indicates if cancel must be triggered for the entire migration. Known values are: - "True" and "False". - :vartype cancel: str or ~azure.mgmt.postgresqlflexibleservers.models.Cancel - :ivar dbs_to_cancel_migration_on: When you want to trigger cancel for specific databases set - 'triggerCutover' to 'True' and the names of the specific databases in this array. - :vartype dbs_to_cancel_migration_on: list[str] - :ivar migration_mode: Mode used to perform the migration: Online or Offline. Known values are: - "Offline" and "Online". - :vartype migration_mode: str or ~azure.mgmt.postgresqlflexibleservers.models.MigrationMode - """ - - _validation = { - "dbs_to_migrate": {"max_items": 50, "min_items": 0}, - } - - _attribute_map = { - "tags": {"key": "tags", "type": "{str}"}, - "source_db_server_resource_id": {"key": "properties.sourceDbServerResourceId", "type": "str"}, - "source_db_server_fully_qualified_domain_name": { - "key": "properties.sourceDbServerFullyQualifiedDomainName", - "type": "str", - }, - "target_db_server_fully_qualified_domain_name": { - "key": "properties.targetDbServerFullyQualifiedDomainName", - "type": "str", - }, - "secret_parameters": {"key": "properties.secretParameters", "type": "MigrationSecretParametersForPatch"}, - "dbs_to_migrate": {"key": "properties.dbsToMigrate", "type": "[str]"}, - "setup_logical_replication_on_source_db_if_needed": { - "key": "properties.setupLogicalReplicationOnSourceDbIfNeeded", - "type": "str", - }, - "overwrite_dbs_in_target": {"key": "properties.overwriteDbsInTarget", "type": "str"}, - "migration_window_start_time_in_utc": {"key": "properties.migrationWindowStartTimeInUtc", "type": "iso-8601"}, - "migrate_roles": {"key": "properties.migrateRoles", "type": "str"}, - "start_data_migration": {"key": "properties.startDataMigration", "type": "str"}, - "trigger_cutover": {"key": "properties.triggerCutover", "type": "str"}, - "dbs_to_trigger_cutover_on": {"key": "properties.dbsToTriggerCutoverOn", "type": "[str]"}, - "cancel": {"key": "properties.cancel", "type": "str"}, - "dbs_to_cancel_migration_on": {"key": "properties.dbsToCancelMigrationOn", "type": "[str]"}, - "migration_mode": {"key": "properties.migrationMode", "type": "str"}, - } - - def __init__( - self, - *, - tags: Optional[dict[str, str]] = None, - source_db_server_resource_id: Optional[str] = None, - source_db_server_fully_qualified_domain_name: Optional[str] = None, - target_db_server_fully_qualified_domain_name: Optional[str] = None, - secret_parameters: Optional["_models.MigrationSecretParametersForPatch"] = None, - dbs_to_migrate: Optional[list[str]] = None, - setup_logical_replication_on_source_db_if_needed: Optional[ - Union[str, "_models.LogicalReplicationOnSourceServer"] - ] = None, - overwrite_dbs_in_target: Optional[Union[str, "_models.OverwriteDatabasesOnTargetServer"]] = None, - migration_window_start_time_in_utc: Optional[datetime.datetime] = None, - migrate_roles: Optional[Union[str, "_models.MigrateRolesAndPermissions"]] = None, - start_data_migration: Optional[Union[str, "_models.StartDataMigration"]] = None, - trigger_cutover: Optional[Union[str, "_models.TriggerCutover"]] = None, - dbs_to_trigger_cutover_on: Optional[list[str]] = None, - cancel: Optional[Union[str, "_models.Cancel"]] = None, - dbs_to_cancel_migration_on: Optional[list[str]] = None, - migration_mode: Optional[Union[str, "_models.MigrationMode"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword tags: Application-specific metadata in the form of key-value pairs. - :paramtype tags: dict[str, str] - :keyword source_db_server_resource_id: Identifier of the source database server resource, when - 'sourceType' is 'PostgreSQLSingleServer'. For other source types this must be set to - ipaddress:port@username or hostname:port@username. - :paramtype source_db_server_resource_id: str - :keyword source_db_server_fully_qualified_domain_name: Fully qualified domain name (FQDN) or IP - address of the source server. This property is optional. When provided, the migration service - will always use it to connect to the source server. - :paramtype source_db_server_fully_qualified_domain_name: str - :keyword target_db_server_fully_qualified_domain_name: Fully qualified domain name (FQDN) or IP - address of the target server. This property is optional. When provided, the migration service - will always use it to connect to the target server. - :paramtype target_db_server_fully_qualified_domain_name: str - :keyword secret_parameters: Migration secret parameters. - :paramtype secret_parameters: - ~azure.mgmt.postgresqlflexibleservers.models.MigrationSecretParametersForPatch - :keyword dbs_to_migrate: Names of databases to migrate. - :paramtype dbs_to_migrate: list[str] - :keyword setup_logical_replication_on_source_db_if_needed: Indicates whether to setup logical - replication on source server, if needed. Known values are: "True" and "False". - :paramtype setup_logical_replication_on_source_db_if_needed: str or - ~azure.mgmt.postgresqlflexibleservers.models.LogicalReplicationOnSourceServer - :keyword overwrite_dbs_in_target: Indicates if databases on the target server can be - overwritten when already present. If set to 'False', when the migration workflow detects that - the database already exists on the target server, it will wait for a confirmation. Known values - are: "True" and "False". - :paramtype overwrite_dbs_in_target: str or - ~azure.mgmt.postgresqlflexibleservers.models.OverwriteDatabasesOnTargetServer - :keyword migration_window_start_time_in_utc: Start time (UTC) for migration window. - :paramtype migration_window_start_time_in_utc: ~datetime.datetime - :keyword migrate_roles: Indicates if roles and permissions must be migrated. Known values are: - "True" and "False". - :paramtype migrate_roles: str or - ~azure.mgmt.postgresqlflexibleservers.models.MigrateRolesAndPermissions - :keyword start_data_migration: Indicates if data migration must start right away. Known values - are: "True" and "False". - :paramtype start_data_migration: str or - ~azure.mgmt.postgresqlflexibleservers.models.StartDataMigration - :keyword trigger_cutover: Indicates if cutover must be triggered for the entire migration. - Known values are: "True" and "False". - :paramtype trigger_cutover: str or ~azure.mgmt.postgresqlflexibleservers.models.TriggerCutover - :keyword dbs_to_trigger_cutover_on: When you want to trigger cutover for specific databases set - 'triggerCutover' to 'True' and the names of the specific databases in this array. - :paramtype dbs_to_trigger_cutover_on: list[str] - :keyword cancel: Indicates if cancel must be triggered for the entire migration. Known values - are: "True" and "False". - :paramtype cancel: str or ~azure.mgmt.postgresqlflexibleservers.models.Cancel - :keyword dbs_to_cancel_migration_on: When you want to trigger cancel for specific databases set - 'triggerCutover' to 'True' and the names of the specific databases in this array. - :paramtype dbs_to_cancel_migration_on: list[str] - :keyword migration_mode: Mode used to perform the migration: Online or Offline. Known values - are: "Offline" and "Online". - :paramtype migration_mode: str or ~azure.mgmt.postgresqlflexibleservers.models.MigrationMode - """ - super().__init__(**kwargs) - self.tags = tags - self.source_db_server_resource_id = source_db_server_resource_id - self.source_db_server_fully_qualified_domain_name = source_db_server_fully_qualified_domain_name - self.target_db_server_fully_qualified_domain_name = target_db_server_fully_qualified_domain_name - self.secret_parameters = secret_parameters - self.dbs_to_migrate = dbs_to_migrate - self.setup_logical_replication_on_source_db_if_needed = setup_logical_replication_on_source_db_if_needed - self.overwrite_dbs_in_target = overwrite_dbs_in_target - self.migration_window_start_time_in_utc = migration_window_start_time_in_utc - self.migrate_roles = migrate_roles - self.start_data_migration = start_data_migration - self.trigger_cutover = trigger_cutover - self.dbs_to_trigger_cutover_on = dbs_to_trigger_cutover_on - self.cancel = cancel - self.dbs_to_cancel_migration_on = dbs_to_cancel_migration_on - self.migration_mode = migration_mode - - -class MigrationSecretParameters(_serialization.Model): - """Migration secret parameters. - - All required parameters must be populated in order to send to server. - - :ivar admin_credentials: Credentials of administrator users for source and target servers. - Required. - :vartype admin_credentials: ~azure.mgmt.postgresqlflexibleservers.models.AdminCredentials - :ivar source_server_username: Gets or sets the name of the user for the source server. This - user doesn't need to be an administrator. - :vartype source_server_username: str - :ivar target_server_username: Gets or sets the name of the user for the target server. This - user doesn't need to be an administrator. - :vartype target_server_username: str - """ - - _validation = { - "admin_credentials": {"required": True}, - } - - _attribute_map = { - "admin_credentials": {"key": "adminCredentials", "type": "AdminCredentials"}, - "source_server_username": {"key": "sourceServerUsername", "type": "str"}, - "target_server_username": {"key": "targetServerUsername", "type": "str"}, - } - - def __init__( - self, - *, - admin_credentials: "_models.AdminCredentials", - source_server_username: Optional[str] = None, - target_server_username: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword admin_credentials: Credentials of administrator users for source and target servers. - Required. - :paramtype admin_credentials: ~azure.mgmt.postgresqlflexibleservers.models.AdminCredentials - :keyword source_server_username: Gets or sets the name of the user for the source server. This - user doesn't need to be an administrator. - :paramtype source_server_username: str - :keyword target_server_username: Gets or sets the name of the user for the target server. This - user doesn't need to be an administrator. - :paramtype target_server_username: str - """ - super().__init__(**kwargs) - self.admin_credentials = admin_credentials - self.source_server_username = source_server_username - self.target_server_username = target_server_username - - -class MigrationSecretParametersForPatch(_serialization.Model): - """Migration secret parameters. - - :ivar admin_credentials: Credentials of administrator users for source and target servers. - :vartype admin_credentials: - ~azure.mgmt.postgresqlflexibleservers.models.AdminCredentialsForPatch - :ivar source_server_username: Gets or sets the name of the user for the source server. This - user doesn't need to be an administrator. - :vartype source_server_username: str - :ivar target_server_username: Gets or sets the name of the user for the target server. This - user doesn't need to be an administrator. - :vartype target_server_username: str - """ - - _attribute_map = { - "admin_credentials": {"key": "adminCredentials", "type": "AdminCredentialsForPatch"}, - "source_server_username": {"key": "sourceServerUsername", "type": "str"}, - "target_server_username": {"key": "targetServerUsername", "type": "str"}, - } - - def __init__( - self, - *, - admin_credentials: Optional["_models.AdminCredentialsForPatch"] = None, - source_server_username: Optional[str] = None, - target_server_username: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword admin_credentials: Credentials of administrator users for source and target servers. - :paramtype admin_credentials: - ~azure.mgmt.postgresqlflexibleservers.models.AdminCredentialsForPatch - :keyword source_server_username: Gets or sets the name of the user for the source server. This - user doesn't need to be an administrator. - :paramtype source_server_username: str - :keyword target_server_username: Gets or sets the name of the user for the target server. This - user doesn't need to be an administrator. - :paramtype target_server_username: str - """ - super().__init__(**kwargs) - self.admin_credentials = admin_credentials - self.source_server_username = source_server_username - self.target_server_username = target_server_username - - -class MigrationStatus(_serialization.Model): - """State of migration. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar state: State of migration. Known values are: "InProgress", "WaitingForUserAction", - "Canceled", "Failed", "Succeeded", "ValidationFailed", and "CleaningUp". - :vartype state: str or ~azure.mgmt.postgresqlflexibleservers.models.MigrationState - :ivar error: Error message, if any, for the migration state. - :vartype error: str - :ivar current_sub_state_details: Current migration sub state details. - :vartype current_sub_state_details: - ~azure.mgmt.postgresqlflexibleservers.models.MigrationSubstateDetails - """ - - _validation = { - "state": {"readonly": True}, - "error": {"readonly": True}, - "current_sub_state_details": {"readonly": True}, - } - - _attribute_map = { - "state": {"key": "state", "type": "str"}, - "error": {"key": "error", "type": "str"}, - "current_sub_state_details": {"key": "currentSubStateDetails", "type": "MigrationSubstateDetails"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.state: Optional[Union[str, "_models.MigrationState"]] = None - self.error: Optional[str] = None - self.current_sub_state_details: Optional["_models.MigrationSubstateDetails"] = None - - -class MigrationSubstateDetails(_serialization.Model): - """Details of migration substate. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar current_sub_state: Substate of migration. Known values are: - "PerformingPreRequisiteSteps", "WaitingForLogicalReplicationSetupRequestOnSourceDB", - "WaitingForDBsToMigrateSpecification", "WaitingForTargetDBOverwriteConfirmation", - "WaitingForDataMigrationScheduling", "WaitingForDataMigrationWindow", "MigratingData", - "WaitingForCutoverTrigger", "CompletingMigration", "Completed", - "CancelingRequestedDBMigrations", and "ValidationInProgress". - :vartype current_sub_state: str or - ~azure.mgmt.postgresqlflexibleservers.models.MigrationSubstate - :ivar db_details: Dictionary of :code:``. - :vartype db_details: dict[str, - ~azure.mgmt.postgresqlflexibleservers.models.DatabaseMigrationState] - :ivar validation_details: Details for the validation for migration. - :vartype validation_details: ~azure.mgmt.postgresqlflexibleservers.models.ValidationDetails - """ - - _validation = { - "current_sub_state": {"readonly": True}, - } - - _attribute_map = { - "current_sub_state": {"key": "currentSubState", "type": "str"}, - "db_details": {"key": "dbDetails", "type": "{DatabaseMigrationState}"}, - "validation_details": {"key": "validationDetails", "type": "ValidationDetails"}, - } - - def __init__( - self, - *, - db_details: Optional[dict[str, "_models.DatabaseMigrationState"]] = None, - validation_details: Optional["_models.ValidationDetails"] = None, - **kwargs: Any - ) -> None: - """ - :keyword db_details: Dictionary of :code:``. - :paramtype db_details: dict[str, - ~azure.mgmt.postgresqlflexibleservers.models.DatabaseMigrationState] - :keyword validation_details: Details for the validation for migration. - :paramtype validation_details: ~azure.mgmt.postgresqlflexibleservers.models.ValidationDetails - """ - super().__init__(**kwargs) - self.current_sub_state: Optional[Union[str, "_models.MigrationSubstate"]] = None - self.db_details = db_details - self.validation_details = validation_details - - -class NameAvailabilityModel(CheckNameAvailabilityResponse): - """Availability of a name. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar name_available: Indicates if the resource name is available. - :vartype name_available: bool - :ivar reason: The reason why the given name is not available. Known values are: "Invalid" and - "AlreadyExists". - :vartype reason: str or - ~azure.mgmt.postgresqlflexibleservers.models.CheckNameAvailabilityReason - :ivar message: Detailed reason why the given name is available. - :vartype message: str - :ivar name: Name for which validity and availability was checked. - :vartype name: str - :ivar type: Type of resource. It can be 'Microsoft.DBforPostgreSQL/flexibleServers' or - 'Microsoft.DBforPostgreSQL/flexibleServers/virtualendpoints'. - :vartype type: str - """ - - _validation = { - "name": {"readonly": True}, - "type": {"readonly": True}, - } - - _attribute_map = { - "name_available": {"key": "nameAvailable", "type": "bool"}, - "reason": {"key": "reason", "type": "str"}, - "message": {"key": "message", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - } - - def __init__( - self, - *, - name_available: Optional[bool] = None, - reason: Optional[Union[str, "_models.CheckNameAvailabilityReason"]] = None, - message: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword name_available: Indicates if the resource name is available. - :paramtype name_available: bool - :keyword reason: The reason why the given name is not available. Known values are: "Invalid" - and "AlreadyExists". - :paramtype reason: str or - ~azure.mgmt.postgresqlflexibleservers.models.CheckNameAvailabilityReason - :keyword message: Detailed reason why the given name is available. - :paramtype message: str - """ - super().__init__(name_available=name_available, reason=reason, message=message, **kwargs) - self.name: Optional[str] = None - self.type: Optional[str] = None - - -class NameProperty(_serialization.Model): - """Name property for quota usage. - - :ivar value: Name value. - :vartype value: str - :ivar localized_value: Localized name. - :vartype localized_value: str - """ - - _attribute_map = { - "value": {"key": "value", "type": "str"}, - "localized_value": {"key": "localizedValue", "type": "str"}, - } - - def __init__(self, *, value: Optional[str] = None, localized_value: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword value: Name value. - :paramtype value: str - :keyword localized_value: Localized name. - :paramtype localized_value: str - """ - super().__init__(**kwargs) - self.value = value - self.localized_value = localized_value - - -class Network(_serialization.Model): - """Network properties of a server. - - :ivar public_network_access: Indicates if public network access is enabled or not. This is only - supported for servers that are not integrated into a virtual network which is owned and - provided by customer when server is deployed. Known values are: "Enabled" and "Disabled". - :vartype public_network_access: str or - ~azure.mgmt.postgresqlflexibleservers.models.ServerPublicNetworkAccessState - :ivar delegated_subnet_resource_id: Resource identifier of the delegated subnet. Required - during creation of a new server, in case you want the server to be integrated into your own - virtual network. For an update operation, you only have to provide this property if you want to - change the value assigned for the private DNS zone. - :vartype delegated_subnet_resource_id: str - :ivar private_dns_zone_arm_resource_id: Identifier of the private DNS zone. Required during - creation of a new server, in case you want the server to be integrated into your own virtual - network. For an update operation, you only have to provide this property if you want to change - the value assigned for the private DNS zone. - :vartype private_dns_zone_arm_resource_id: str - """ - - _attribute_map = { - "public_network_access": {"key": "publicNetworkAccess", "type": "str"}, - "delegated_subnet_resource_id": {"key": "delegatedSubnetResourceId", "type": "str"}, - "private_dns_zone_arm_resource_id": {"key": "privateDnsZoneArmResourceId", "type": "str"}, - } - - def __init__( - self, - *, - public_network_access: Optional[Union[str, "_models.ServerPublicNetworkAccessState"]] = None, - delegated_subnet_resource_id: Optional[str] = None, - private_dns_zone_arm_resource_id: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword public_network_access: Indicates if public network access is enabled or not. This is - only supported for servers that are not integrated into a virtual network which is owned and - provided by customer when server is deployed. Known values are: "Enabled" and "Disabled". - :paramtype public_network_access: str or - ~azure.mgmt.postgresqlflexibleservers.models.ServerPublicNetworkAccessState - :keyword delegated_subnet_resource_id: Resource identifier of the delegated subnet. Required - during creation of a new server, in case you want the server to be integrated into your own - virtual network. For an update operation, you only have to provide this property if you want to - change the value assigned for the private DNS zone. - :paramtype delegated_subnet_resource_id: str - :keyword private_dns_zone_arm_resource_id: Identifier of the private DNS zone. Required during - creation of a new server, in case you want the server to be integrated into your own virtual - network. For an update operation, you only have to provide this property if you want to change - the value assigned for the private DNS zone. - :paramtype private_dns_zone_arm_resource_id: str - """ - super().__init__(**kwargs) - self.public_network_access = public_network_access - self.delegated_subnet_resource_id = delegated_subnet_resource_id - self.private_dns_zone_arm_resource_id = private_dns_zone_arm_resource_id - - -class ObjectRecommendation(ProxyResource): - """Object recommendation properties. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Fully qualified resource ID for the resource. E.g. - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}". - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or - "Microsoft.Storage/storageAccounts". - :vartype type: str - :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy - information. - :vartype system_data: ~azure.mgmt.postgresqlflexibleservers.models.SystemData - :ivar kind: Always empty. - :vartype kind: str - :ivar initial_recommended_time: Creation time (UTC) of this recommendation. - :vartype initial_recommended_time: ~datetime.datetime - :ivar last_recommended_time: Last time (UTC) that this recommendation was produced. - :vartype last_recommended_time: ~datetime.datetime - :ivar times_recommended: Number of times this recommendation has been produced. - :vartype times_recommended: int - :ivar improved_query_ids: List of identifiers for all queries identified as targets for - improvement if the recommendation is applied. The list is only populated for CREATE INDEX - recommendations. - :vartype improved_query_ids: list[int] - :ivar recommendation_reason: Reason for this recommendation. - :vartype recommendation_reason: str - :ivar current_state: Current state. - :vartype current_state: str - :ivar recommendation_type: Type for this recommendation. Known values are: "CreateIndex", - "DropIndex", "ReIndex", and "AnalyzeTable". - :vartype recommendation_type: str or - ~azure.mgmt.postgresqlflexibleservers.models.RecommendationTypeEnum - :ivar implementation_details: Implementation details for the recommended action. - :vartype implementation_details: - ~azure.mgmt.postgresqlflexibleservers.models.ObjectRecommendationPropertiesImplementationDetails - :ivar analyzed_workload: Workload information for the recommended action. - :vartype analyzed_workload: - ~azure.mgmt.postgresqlflexibleservers.models.ObjectRecommendationPropertiesAnalyzedWorkload - :ivar estimated_impact: Estimated impact of this recommended action. - :vartype estimated_impact: list[~azure.mgmt.postgresqlflexibleservers.models.ImpactRecord] - :ivar details: Recommendation details for the recommended action. - :vartype details: ~azure.mgmt.postgresqlflexibleservers.models.ObjectRecommendationDetails - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "system_data": {"readonly": True}, - "estimated_impact": {"readonly": True}, - "details": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "system_data": {"key": "systemData", "type": "SystemData"}, - "kind": {"key": "kind", "type": "str"}, - "initial_recommended_time": {"key": "properties.initialRecommendedTime", "type": "iso-8601"}, - "last_recommended_time": {"key": "properties.lastRecommendedTime", "type": "iso-8601"}, - "times_recommended": {"key": "properties.timesRecommended", "type": "int"}, - "improved_query_ids": {"key": "properties.improvedQueryIds", "type": "[int]"}, - "recommendation_reason": {"key": "properties.recommendationReason", "type": "str"}, - "current_state": {"key": "properties.currentState", "type": "str"}, - "recommendation_type": {"key": "properties.recommendationType", "type": "str"}, - "implementation_details": { - "key": "properties.implementationDetails", - "type": "ObjectRecommendationPropertiesImplementationDetails", - }, - "analyzed_workload": { - "key": "properties.analyzedWorkload", - "type": "ObjectRecommendationPropertiesAnalyzedWorkload", - }, - "estimated_impact": {"key": "properties.estimatedImpact", "type": "[ImpactRecord]"}, - "details": {"key": "properties.details", "type": "ObjectRecommendationDetails"}, - } - - def __init__( - self, - *, - kind: Optional[str] = None, - initial_recommended_time: Optional[datetime.datetime] = None, - last_recommended_time: Optional[datetime.datetime] = None, - times_recommended: Optional[int] = None, - improved_query_ids: Optional[list[int]] = None, - recommendation_reason: Optional[str] = None, - current_state: Optional[str] = None, - recommendation_type: Optional[Union[str, "_models.RecommendationTypeEnum"]] = None, - implementation_details: Optional["_models.ObjectRecommendationPropertiesImplementationDetails"] = None, - analyzed_workload: Optional["_models.ObjectRecommendationPropertiesAnalyzedWorkload"] = None, - **kwargs: Any - ) -> None: - """ - :keyword kind: Always empty. - :paramtype kind: str - :keyword initial_recommended_time: Creation time (UTC) of this recommendation. - :paramtype initial_recommended_time: ~datetime.datetime - :keyword last_recommended_time: Last time (UTC) that this recommendation was produced. - :paramtype last_recommended_time: ~datetime.datetime - :keyword times_recommended: Number of times this recommendation has been produced. - :paramtype times_recommended: int - :keyword improved_query_ids: List of identifiers for all queries identified as targets for - improvement if the recommendation is applied. The list is only populated for CREATE INDEX - recommendations. - :paramtype improved_query_ids: list[int] - :keyword recommendation_reason: Reason for this recommendation. - :paramtype recommendation_reason: str - :keyword current_state: Current state. - :paramtype current_state: str - :keyword recommendation_type: Type for this recommendation. Known values are: "CreateIndex", - "DropIndex", "ReIndex", and "AnalyzeTable". - :paramtype recommendation_type: str or - ~azure.mgmt.postgresqlflexibleservers.models.RecommendationTypeEnum - :keyword implementation_details: Implementation details for the recommended action. - :paramtype implementation_details: - ~azure.mgmt.postgresqlflexibleservers.models.ObjectRecommendationPropertiesImplementationDetails - :keyword analyzed_workload: Workload information for the recommended action. - :paramtype analyzed_workload: - ~azure.mgmt.postgresqlflexibleservers.models.ObjectRecommendationPropertiesAnalyzedWorkload - """ - super().__init__(**kwargs) - self.kind = kind - self.initial_recommended_time = initial_recommended_time - self.last_recommended_time = last_recommended_time - self.times_recommended = times_recommended - self.improved_query_ids = improved_query_ids - self.recommendation_reason = recommendation_reason - self.current_state = current_state - self.recommendation_type = recommendation_type - self.implementation_details = implementation_details - self.analyzed_workload = analyzed_workload - self.estimated_impact: Optional[list["_models.ImpactRecord"]] = None - self.details: Optional["_models.ObjectRecommendationDetails"] = None - - -class ObjectRecommendationDetails(_serialization.Model): - """Recommendation details for the recommended action. - - :ivar database_name: Database name. - :vartype database_name: str - :ivar schema: Schema name. - :vartype schema: str - :ivar table: Table name. - :vartype table: str - :ivar index_type: Index type. - :vartype index_type: str - :ivar index_name: Index name. - :vartype index_name: str - :ivar index_columns: Index columns. - :vartype index_columns: list[str] - :ivar included_columns: Index included columns. - :vartype included_columns: list[str] - """ - - _attribute_map = { - "database_name": {"key": "databaseName", "type": "str"}, - "schema": {"key": "schema", "type": "str"}, - "table": {"key": "table", "type": "str"}, - "index_type": {"key": "indexType", "type": "str"}, - "index_name": {"key": "indexName", "type": "str"}, - "index_columns": {"key": "indexColumns", "type": "[str]"}, - "included_columns": {"key": "includedColumns", "type": "[str]"}, - } - - def __init__( - self, - *, - database_name: Optional[str] = None, - schema: Optional[str] = None, - table: Optional[str] = None, - index_type: Optional[str] = None, - index_name: Optional[str] = None, - index_columns: Optional[list[str]] = None, - included_columns: Optional[list[str]] = None, - **kwargs: Any - ) -> None: - """ - :keyword database_name: Database name. - :paramtype database_name: str - :keyword schema: Schema name. - :paramtype schema: str - :keyword table: Table name. - :paramtype table: str - :keyword index_type: Index type. - :paramtype index_type: str - :keyword index_name: Index name. - :paramtype index_name: str - :keyword index_columns: Index columns. - :paramtype index_columns: list[str] - :keyword included_columns: Index included columns. - :paramtype included_columns: list[str] - """ - super().__init__(**kwargs) - self.database_name = database_name - self.schema = schema - self.table = table - self.index_type = index_type - self.index_name = index_name - self.index_columns = index_columns - self.included_columns = included_columns - - -class ObjectRecommendationList(_serialization.Model): - """List of available object recommendations. - - :ivar value: List of available object recommendations. - :vartype value: list[~azure.mgmt.postgresqlflexibleservers.models.ObjectRecommendation] - :ivar next_link: Link used to get the next page of results. - :vartype next_link: str - """ - - _attribute_map = { - "value": {"key": "value", "type": "[ObjectRecommendation]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, - *, - value: Optional[list["_models.ObjectRecommendation"]] = None, - next_link: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword value: List of available object recommendations. - :paramtype value: list[~azure.mgmt.postgresqlflexibleservers.models.ObjectRecommendation] - :keyword next_link: Link used to get the next page of results. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class ObjectRecommendationPropertiesAnalyzedWorkload(_serialization.Model): # pylint: disable=name-too-long - """Workload information for the recommended action. - - :ivar start_time: Start time (UTC) of the workload analyzed. - :vartype start_time: ~datetime.datetime - :ivar end_time: End time (UTC) of the workload analyzed. - :vartype end_time: ~datetime.datetime - :ivar query_count: Number of queries from the workload that were examined to produce this - recommendation. For DROP INDEX recommendations it's 0 (zero). - :vartype query_count: int - """ - - _attribute_map = { - "start_time": {"key": "startTime", "type": "iso-8601"}, - "end_time": {"key": "endTime", "type": "iso-8601"}, - "query_count": {"key": "queryCount", "type": "int"}, - } - - def __init__( - self, - *, - start_time: Optional[datetime.datetime] = None, - end_time: Optional[datetime.datetime] = None, - query_count: Optional[int] = None, - **kwargs: Any - ) -> None: - """ - :keyword start_time: Start time (UTC) of the workload analyzed. - :paramtype start_time: ~datetime.datetime - :keyword end_time: End time (UTC) of the workload analyzed. - :paramtype end_time: ~datetime.datetime - :keyword query_count: Number of queries from the workload that were examined to produce this - recommendation. For DROP INDEX recommendations it's 0 (zero). - :paramtype query_count: int - """ - super().__init__(**kwargs) - self.start_time = start_time - self.end_time = end_time - self.query_count = query_count - - -class ObjectRecommendationPropertiesImplementationDetails(_serialization.Model): # pylint: disable=name-too-long - """Implementation details for the recommended action. - - :ivar method: Method of implementation for recommended action. - :vartype method: str - :ivar script: Implementation script for the recommended action. - :vartype script: str - """ - - _attribute_map = { - "method": {"key": "method", "type": "str"}, - "script": {"key": "script", "type": "str"}, - } - - def __init__(self, *, method: Optional[str] = None, script: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword method: Method of implementation for recommended action. - :paramtype method: str - :keyword script: Implementation script for the recommended action. - :paramtype script: str - """ - super().__init__(**kwargs) - self.method = method - self.script = script - - -class Operation(_serialization.Model): - """REST API operation definition. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar name: Name of the operation being performed on this particular object. - :vartype name: str - :ivar display: Localized display information for this particular operation or action. - :vartype display: ~azure.mgmt.postgresqlflexibleservers.models.OperationDisplay - :ivar is_data_action: Indicates if the operation is a data action. - :vartype is_data_action: bool - :ivar origin: Intended executor of the operation. Known values are: "NotSpecified", "user", and - "system". - :vartype origin: str or ~azure.mgmt.postgresqlflexibleservers.models.OperationOrigin - :ivar properties: Additional descriptions for the operation. - :vartype properties: dict[str, JSON] - """ - - _validation = { - "name": {"readonly": True}, - "display": {"readonly": True}, - "origin": {"readonly": True}, - "properties": {"readonly": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "display": {"key": "display", "type": "OperationDisplay"}, - "is_data_action": {"key": "isDataAction", "type": "bool"}, - "origin": {"key": "origin", "type": "str"}, - "properties": {"key": "properties", "type": "{object}"}, - } - - def __init__(self, *, is_data_action: Optional[bool] = None, **kwargs: Any) -> None: - """ - :keyword is_data_action: Indicates if the operation is a data action. - :paramtype is_data_action: bool - """ - super().__init__(**kwargs) - self.name: Optional[str] = None - self.display: Optional["_models.OperationDisplay"] = None - self.is_data_action = is_data_action - self.origin: Optional[Union[str, "_models.OperationOrigin"]] = None - self.properties: Optional[dict[str, JSON]] = None - - -class OperationDisplay(_serialization.Model): - """Display metadata associated with the operation. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar provider: Name of the resource provider. - :vartype provider: str - :ivar resource: Type of resource on which the operation is performed. - :vartype resource: str - :ivar operation: Name of the operation. - :vartype operation: str - :ivar description: Description of the operation. - :vartype description: str - """ - - _validation = { - "provider": {"readonly": True}, - "resource": {"readonly": True}, - "operation": {"readonly": True}, - "description": {"readonly": True}, - } - - _attribute_map = { - "provider": {"key": "provider", "type": "str"}, - "resource": {"key": "resource", "type": "str"}, - "operation": {"key": "operation", "type": "str"}, - "description": {"key": "description", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.provider: Optional[str] = None - self.resource: Optional[str] = None - self.operation: Optional[str] = None - self.description: Optional[str] = None - - -class OperationList(_serialization.Model): - """List of resource provider operations. - - :ivar value: Collection of available operation details. - :vartype value: list[~azure.mgmt.postgresqlflexibleservers.models.Operation] - :ivar next_link: Link used to get the next page of results. - :vartype next_link: str - """ - - _attribute_map = { - "value": {"key": "value", "type": "[Operation]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, *, value: Optional[list["_models.Operation"]] = None, next_link: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword value: Collection of available operation details. - :paramtype value: list[~azure.mgmt.postgresqlflexibleservers.models.Operation] - :keyword next_link: Link used to get the next page of results. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class PrivateEndpoint(_serialization.Model): - """The private endpoint resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The ARM identifier for private endpoint. - :vartype id: str - """ - - _validation = { - "id": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.id: Optional[str] = None - - -class PrivateEndpointConnection(Resource): - """The private endpoint connection resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Fully qualified resource ID for the resource. E.g. - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}". - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or - "Microsoft.Storage/storageAccounts". - :vartype type: str - :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy - information. - :vartype system_data: ~azure.mgmt.postgresqlflexibleservers.models.SystemData - :ivar group_ids: The group ids for the private endpoint resource. - :vartype group_ids: list[str] - :ivar private_endpoint: The private endpoint resource. - :vartype private_endpoint: ~azure.mgmt.postgresqlflexibleservers.models.PrivateEndpoint - :ivar private_link_service_connection_state: A collection of information about the state of the - connection between service consumer and provider. - :vartype private_link_service_connection_state: - ~azure.mgmt.postgresqlflexibleservers.models.PrivateLinkServiceConnectionState - :ivar provisioning_state: The provisioning state of the private endpoint connection resource. - Known values are: "Succeeded", "Creating", "Deleting", and "Failed". - :vartype provisioning_state: str or - ~azure.mgmt.postgresqlflexibleservers.models.PrivateEndpointConnectionProvisioningState - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "system_data": {"readonly": True}, - "group_ids": {"readonly": True}, - "provisioning_state": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "system_data": {"key": "systemData", "type": "SystemData"}, - "group_ids": {"key": "properties.groupIds", "type": "[str]"}, - "private_endpoint": {"key": "properties.privateEndpoint", "type": "PrivateEndpoint"}, - "private_link_service_connection_state": { - "key": "properties.privateLinkServiceConnectionState", - "type": "PrivateLinkServiceConnectionState", - }, - "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - } - - def __init__( - self, - *, - private_endpoint: Optional["_models.PrivateEndpoint"] = None, - private_link_service_connection_state: Optional["_models.PrivateLinkServiceConnectionState"] = None, - **kwargs: Any - ) -> None: - """ - :keyword private_endpoint: The private endpoint resource. - :paramtype private_endpoint: ~azure.mgmt.postgresqlflexibleservers.models.PrivateEndpoint - :keyword private_link_service_connection_state: A collection of information about the state of - the connection between service consumer and provider. - :paramtype private_link_service_connection_state: - ~azure.mgmt.postgresqlflexibleservers.models.PrivateLinkServiceConnectionState - """ - super().__init__(**kwargs) - self.group_ids: Optional[list[str]] = None - self.private_endpoint = private_endpoint - self.private_link_service_connection_state = private_link_service_connection_state - self.provisioning_state: Optional[Union[str, "_models.PrivateEndpointConnectionProvisioningState"]] = None - - -class PrivateEndpointConnectionList(_serialization.Model): - """List of private endpoint connections. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: Array of results. - :vartype value: list[~azure.mgmt.postgresqlflexibleservers.models.PrivateEndpointConnection] - :ivar next_link: Link used to get the next page of results. - :vartype next_link: str - """ - - _validation = { - "value": {"readonly": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[PrivateEndpointConnection]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, *, next_link: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword next_link: Link used to get the next page of results. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value: Optional[list["_models.PrivateEndpointConnection"]] = None - self.next_link = next_link - - -class PrivateLinkResource(Resource): - """A private link resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Fully qualified resource ID for the resource. E.g. - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}". - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or - "Microsoft.Storage/storageAccounts". - :vartype type: str - :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy - information. - :vartype system_data: ~azure.mgmt.postgresqlflexibleservers.models.SystemData - :ivar group_id: The private link resource group id. - :vartype group_id: str - :ivar required_members: The private link resource required member names. - :vartype required_members: list[str] - :ivar required_zone_names: The private link resource private link DNS zone name. - :vartype required_zone_names: list[str] - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "system_data": {"readonly": True}, - "group_id": {"readonly": True}, - "required_members": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "system_data": {"key": "systemData", "type": "SystemData"}, - "group_id": {"key": "properties.groupId", "type": "str"}, - "required_members": {"key": "properties.requiredMembers", "type": "[str]"}, - "required_zone_names": {"key": "properties.requiredZoneNames", "type": "[str]"}, - } - - def __init__(self, *, required_zone_names: Optional[list[str]] = None, **kwargs: Any) -> None: - """ - :keyword required_zone_names: The private link resource private link DNS zone name. - :paramtype required_zone_names: list[str] - """ - super().__init__(**kwargs) - self.group_id: Optional[str] = None - self.required_members: Optional[list[str]] = None - self.required_zone_names = required_zone_names - - -class PrivateLinkResourceList(_serialization.Model): - """A list of private link resources. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: Array of results. - :vartype value: list[~azure.mgmt.postgresqlflexibleservers.models.PrivateLinkResource] - :ivar next_link: Link to retrieve next page of results. - :vartype next_link: str - """ - - _validation = { - "value": {"readonly": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[PrivateLinkResource]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, *, next_link: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword next_link: Link to retrieve next page of results. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value: Optional[list["_models.PrivateLinkResource"]] = None - self.next_link = next_link - - -class PrivateLinkServiceConnectionState(_serialization.Model): - """A collection of information about the state of the connection between service consumer and - provider. - - :ivar status: Indicates whether the connection has been Approved/Rejected/Removed by the owner - of the service. Known values are: "Pending", "Approved", and "Rejected". - :vartype status: str or - ~azure.mgmt.postgresqlflexibleservers.models.PrivateEndpointServiceConnectionStatus - :ivar description: The reason for approval/rejection of the connection. - :vartype description: str - :ivar actions_required: A message indicating if changes on the service provider require any - updates on the consumer. - :vartype actions_required: str - """ - - _attribute_map = { - "status": {"key": "status", "type": "str"}, - "description": {"key": "description", "type": "str"}, - "actions_required": {"key": "actionsRequired", "type": "str"}, - } - - def __init__( - self, - *, - status: Optional[Union[str, "_models.PrivateEndpointServiceConnectionStatus"]] = None, - description: Optional[str] = None, - actions_required: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword status: Indicates whether the connection has been Approved/Rejected/Removed by the - owner of the service. Known values are: "Pending", "Approved", and "Rejected". - :paramtype status: str or - ~azure.mgmt.postgresqlflexibleservers.models.PrivateEndpointServiceConnectionStatus - :keyword description: The reason for approval/rejection of the connection. - :paramtype description: str - :keyword actions_required: A message indicating if changes on the service provider require any - updates on the consumer. - :paramtype actions_required: str - """ - super().__init__(**kwargs) - self.status = status - self.description = description - self.actions_required = actions_required - - -class QuotaUsage(_serialization.Model): - """Quota usage for servers. - - :ivar name: Name of quota usage for servers. - :vartype name: ~azure.mgmt.postgresqlflexibleservers.models.NameProperty - :ivar limit: Quota limit. - :vartype limit: int - :ivar unit: Quota unit. - :vartype unit: str - :ivar current_value: Current Quota usage value. - :vartype current_value: int - :ivar id: Fully qualified ARM resource Id. - :vartype id: str - """ - - _attribute_map = { - "name": {"key": "name", "type": "NameProperty"}, - "limit": {"key": "limit", "type": "int"}, - "unit": {"key": "unit", "type": "str"}, - "current_value": {"key": "currentValue", "type": "int"}, - "id": {"key": "id", "type": "str"}, - } - - def __init__( - self, - *, - name: Optional["_models.NameProperty"] = None, - limit: Optional[int] = None, - unit: str = "Count", - current_value: Optional[int] = None, - id: Optional[str] = None, # pylint: disable=redefined-builtin - **kwargs: Any - ) -> None: - """ - :keyword name: Name of quota usage for servers. - :paramtype name: ~azure.mgmt.postgresqlflexibleservers.models.NameProperty - :keyword limit: Quota limit. - :paramtype limit: int - :keyword unit: Quota unit. - :paramtype unit: str - :keyword current_value: Current Quota usage value. - :paramtype current_value: int - :keyword id: Fully qualified ARM resource Id. - :paramtype id: str - """ - super().__init__(**kwargs) - self.name = name - self.limit = limit - self.unit = unit - self.current_value = current_value - self.id = id - - -class QuotaUsageList(_serialization.Model): - """Capability for the PostgreSQL server. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: A list of quota usages. - :vartype value: list[~azure.mgmt.postgresqlflexibleservers.models.QuotaUsage] - :ivar next_link: Link to retrieve next page of results. - :vartype next_link: str - """ - - _validation = { - "value": {"readonly": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[QuotaUsage]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, *, next_link: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword next_link: Link to retrieve next page of results. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value: Optional[list["_models.QuotaUsage"]] = None - self.next_link = next_link - - -class Replica(_serialization.Model): - """Replica properties of a server. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar role: Role of the server in a replication set. Known values are: "None", "Primary", - "AsyncReplica", and "GeoAsyncReplica". - :vartype role: str or ~azure.mgmt.postgresqlflexibleservers.models.ReplicationRole - :ivar capacity: Maximum number of read replicas allowed for a server. - :vartype capacity: int - :ivar replication_state: Indicates the replication state of a read replica. This property is - returned only when the target server is a read replica. Possible values are Active, Broken, - Catchup, Provisioning, Reconfiguring, and Updating. Known values are: "Active", "Catchup", - "Provisioning", "Updating", "Broken", and "Reconfiguring". - :vartype replication_state: str or - ~azure.mgmt.postgresqlflexibleservers.models.ReplicationState - :ivar promote_mode: Type of operation to apply on the read replica. This property is write - only. Standalone means that the read replica will be promoted to a standalone server, and will - become a completely independent entity from the replication set. Switchover means that the read - replica will roles with the primary server. Known values are: "Standalone" and "Switchover". - :vartype promote_mode: str or - ~azure.mgmt.postgresqlflexibleservers.models.ReadReplicaPromoteMode - :ivar promote_option: Data synchronization option to use when processing the operation - specified in the promoteMode property. This property is write only. Known values are: "Planned" - and "Forced". - :vartype promote_option: str or - ~azure.mgmt.postgresqlflexibleservers.models.ReadReplicaPromoteOption - """ - - _validation = { - "capacity": {"readonly": True}, - "replication_state": {"readonly": True}, - } - - _attribute_map = { - "role": {"key": "role", "type": "str"}, - "capacity": {"key": "capacity", "type": "int"}, - "replication_state": {"key": "replicationState", "type": "str"}, - "promote_mode": {"key": "promoteMode", "type": "str"}, - "promote_option": {"key": "promoteOption", "type": "str"}, - } - - def __init__( - self, - *, - role: Optional[Union[str, "_models.ReplicationRole"]] = None, - promote_mode: Optional[Union[str, "_models.ReadReplicaPromoteMode"]] = None, - promote_option: Optional[Union[str, "_models.ReadReplicaPromoteOption"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword role: Role of the server in a replication set. Known values are: "None", "Primary", - "AsyncReplica", and "GeoAsyncReplica". - :paramtype role: str or ~azure.mgmt.postgresqlflexibleservers.models.ReplicationRole - :keyword promote_mode: Type of operation to apply on the read replica. This property is write - only. Standalone means that the read replica will be promoted to a standalone server, and will - become a completely independent entity from the replication set. Switchover means that the read - replica will roles with the primary server. Known values are: "Standalone" and "Switchover". - :paramtype promote_mode: str or - ~azure.mgmt.postgresqlflexibleservers.models.ReadReplicaPromoteMode - :keyword promote_option: Data synchronization option to use when processing the operation - specified in the promoteMode property. This property is write only. Known values are: "Planned" - and "Forced". - :paramtype promote_option: str or - ~azure.mgmt.postgresqlflexibleservers.models.ReadReplicaPromoteOption - """ - super().__init__(**kwargs) - self.role = role - self.capacity: Optional[int] = None - self.replication_state: Optional[Union[str, "_models.ReplicationState"]] = None - self.promote_mode = promote_mode - self.promote_option = promote_option - - -class RestartParameter(_serialization.Model): - """PostgreSQL database engine restart parameters. - - :ivar restart_with_failover: Indicates if restart the PostgreSQL database engine should - failover or switch over from primary to standby. This only works if server has high - availability enabled. - :vartype restart_with_failover: bool - :ivar failover_mode: Failover mode. Known values are: "PlannedFailover", "ForcedFailover", - "PlannedSwitchover", and "ForcedSwitchover". - :vartype failover_mode: str or ~azure.mgmt.postgresqlflexibleservers.models.FailoverMode - """ - - _attribute_map = { - "restart_with_failover": {"key": "restartWithFailover", "type": "bool"}, - "failover_mode": {"key": "failoverMode", "type": "str"}, - } - - def __init__( - self, - *, - restart_with_failover: Optional[bool] = None, - failover_mode: Optional[Union[str, "_models.FailoverMode"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword restart_with_failover: Indicates if restart the PostgreSQL database engine should - failover or switch over from primary to standby. This only works if server has high - availability enabled. - :paramtype restart_with_failover: bool - :keyword failover_mode: Failover mode. Known values are: "PlannedFailover", "ForcedFailover", - "PlannedSwitchover", and "ForcedSwitchover". - :paramtype failover_mode: str or ~azure.mgmt.postgresqlflexibleservers.models.FailoverMode - """ - super().__init__(**kwargs) - self.restart_with_failover = restart_with_failover - self.failover_mode = failover_mode - - -class Server(TrackedResource): - """Properties of a server. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to server. - - :ivar id: Fully qualified resource ID for the resource. E.g. - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}". - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or - "Microsoft.Storage/storageAccounts". - :vartype type: str - :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy - information. - :vartype system_data: ~azure.mgmt.postgresqlflexibleservers.models.SystemData - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - :ivar location: The geo-location where the resource lives. Required. - :vartype location: str - :ivar sku: Compute tier and size of a server. - :vartype sku: ~azure.mgmt.postgresqlflexibleservers.models.Sku - :ivar identity: User assigned managed identities assigned to the server. - :vartype identity: ~azure.mgmt.postgresqlflexibleservers.models.UserAssignedIdentity - :ivar administrator_login: Name of the login designated as the first password based - administrator assigned to your instance of PostgreSQL. Must be specified the first time that - you enable password based authentication on a server. Once set to a given value, it cannot be - changed for the rest of the life of a server. If you disable password based authentication on a - server which had it enabled, this password based role isn't deleted. - :vartype administrator_login: str - :ivar administrator_login_password: Password assigned to the administrator login. As long as - password authentication is enabled, this password can be changed at any time. - :vartype administrator_login_password: str - :ivar version: Major version of PostgreSQL database engine. Known values are: "18", "17", "16", - "15", "14", "13", "12", and "11". - :vartype version: str or ~azure.mgmt.postgresqlflexibleservers.models.PostgresMajorVersion - :ivar minor_version: Minor version of PostgreSQL database engine. - :vartype minor_version: str - :ivar state: Possible states of a server. Known values are: "Ready", "Dropping", "Disabled", - "Starting", "Stopping", "Stopped", "Updating", "Restarting", "Inaccessible", and - "Provisioning". - :vartype state: str or ~azure.mgmt.postgresqlflexibleservers.models.ServerState - :ivar fully_qualified_domain_name: Fully qualified domain name of a server. - :vartype fully_qualified_domain_name: str - :ivar storage: Storage properties of a server. - :vartype storage: ~azure.mgmt.postgresqlflexibleservers.models.Storage - :ivar auth_config: Authentication configuration properties of a server. - :vartype auth_config: ~azure.mgmt.postgresqlflexibleservers.models.AuthConfig - :ivar data_encryption: Data encryption properties of a server. - :vartype data_encryption: ~azure.mgmt.postgresqlflexibleservers.models.DataEncryption - :ivar backup: Backup properties of a server. - :vartype backup: ~azure.mgmt.postgresqlflexibleservers.models.Backup - :ivar network: Network properties of a server. Only required if you want your server to be - integrated into a virtual network provided by customer. - :vartype network: ~azure.mgmt.postgresqlflexibleservers.models.Network - :ivar high_availability: High availability properties of a server. - :vartype high_availability: ~azure.mgmt.postgresqlflexibleservers.models.HighAvailability - :ivar maintenance_window: Maintenance window properties of a server. - :vartype maintenance_window: ~azure.mgmt.postgresqlflexibleservers.models.MaintenanceWindow - :ivar source_server_resource_id: Identifier of the server to be used as the source of the new - server. Required when 'createMode' is 'PointInTimeRestore', 'GeoRestore', 'Replica', or - 'ReviveDropped'. This property is returned only when the target server is a read replica. - :vartype source_server_resource_id: str - :ivar point_in_time_utc: Creation time (in ISO8601 format) of the backup which you want to - restore in the new server. It's required when 'createMode' is 'PointInTimeRestore', - 'GeoRestore', or 'ReviveDropped'. - :vartype point_in_time_utc: ~datetime.datetime - :ivar availability_zone: Availability zone of a server. - :vartype availability_zone: str - :ivar replication_role: Role of the server in a replication set. Known values are: "None", - "Primary", "AsyncReplica", and "GeoAsyncReplica". - :vartype replication_role: str or ~azure.mgmt.postgresqlflexibleservers.models.ReplicationRole - :ivar replica_capacity: Maximum number of read replicas allowed for a server. - :vartype replica_capacity: int - :ivar replica: Read replica properties of a server. Required only in case that you want to - promote a server. - :vartype replica: ~azure.mgmt.postgresqlflexibleservers.models.Replica - :ivar create_mode: Creation mode of a new server. Known values are: "Default", "Create", - "Update", "PointInTimeRestore", "GeoRestore", "Replica", and "ReviveDropped". - :vartype create_mode: str or ~azure.mgmt.postgresqlflexibleservers.models.CreateMode - :ivar private_endpoint_connections: List of private endpoint connections associated with the - specified server. - :vartype private_endpoint_connections: - list[~azure.mgmt.postgresqlflexibleservers.models.PrivateEndpointConnection] - :ivar cluster: Cluster properties of a server. - :vartype cluster: ~azure.mgmt.postgresqlflexibleservers.models.Cluster - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "system_data": {"readonly": True}, - "location": {"required": True}, - "minor_version": {"readonly": True}, - "state": {"readonly": True}, - "fully_qualified_domain_name": {"readonly": True}, - "replica_capacity": {"readonly": True}, - "private_endpoint_connections": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "system_data": {"key": "systemData", "type": "SystemData"}, - "tags": {"key": "tags", "type": "{str}"}, - "location": {"key": "location", "type": "str"}, - "sku": {"key": "sku", "type": "Sku"}, - "identity": {"key": "identity", "type": "UserAssignedIdentity"}, - "administrator_login": {"key": "properties.administratorLogin", "type": "str"}, - "administrator_login_password": {"key": "properties.administratorLoginPassword", "type": "str"}, - "version": {"key": "properties.version", "type": "str"}, - "minor_version": {"key": "properties.minorVersion", "type": "str"}, - "state": {"key": "properties.state", "type": "str"}, - "fully_qualified_domain_name": {"key": "properties.fullyQualifiedDomainName", "type": "str"}, - "storage": {"key": "properties.storage", "type": "Storage"}, - "auth_config": {"key": "properties.authConfig", "type": "AuthConfig"}, - "data_encryption": {"key": "properties.dataEncryption", "type": "DataEncryption"}, - "backup": {"key": "properties.backup", "type": "Backup"}, - "network": {"key": "properties.network", "type": "Network"}, - "high_availability": {"key": "properties.highAvailability", "type": "HighAvailability"}, - "maintenance_window": {"key": "properties.maintenanceWindow", "type": "MaintenanceWindow"}, - "source_server_resource_id": {"key": "properties.sourceServerResourceId", "type": "str"}, - "point_in_time_utc": {"key": "properties.pointInTimeUTC", "type": "iso-8601"}, - "availability_zone": {"key": "properties.availabilityZone", "type": "str"}, - "replication_role": {"key": "properties.replicationRole", "type": "str"}, - "replica_capacity": {"key": "properties.replicaCapacity", "type": "int"}, - "replica": {"key": "properties.replica", "type": "Replica"}, - "create_mode": {"key": "properties.createMode", "type": "str"}, - "private_endpoint_connections": { - "key": "properties.privateEndpointConnections", - "type": "[PrivateEndpointConnection]", - }, - "cluster": {"key": "properties.cluster", "type": "Cluster"}, - } - - def __init__( # pylint: disable=too-many-locals - self, - *, - location: str, - tags: Optional[dict[str, str]] = None, - sku: Optional["_models.Sku"] = None, - identity: Optional["_models.UserAssignedIdentity"] = None, - administrator_login: Optional[str] = None, - administrator_login_password: Optional[str] = None, - version: Optional[Union[str, "_models.PostgresMajorVersion"]] = None, - storage: Optional["_models.Storage"] = None, - auth_config: Optional["_models.AuthConfig"] = None, - data_encryption: Optional["_models.DataEncryption"] = None, - backup: Optional["_models.Backup"] = None, - network: Optional["_models.Network"] = None, - high_availability: Optional["_models.HighAvailability"] = None, - maintenance_window: Optional["_models.MaintenanceWindow"] = None, - source_server_resource_id: Optional[str] = None, - point_in_time_utc: Optional[datetime.datetime] = None, - availability_zone: str = "", - replication_role: Optional[Union[str, "_models.ReplicationRole"]] = None, - replica: Optional["_models.Replica"] = None, - create_mode: Optional[Union[str, "_models.CreateMode"]] = None, - cluster: Optional["_models.Cluster"] = None, - **kwargs: Any - ) -> None: - """ - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword location: The geo-location where the resource lives. Required. - :paramtype location: str - :keyword sku: Compute tier and size of a server. - :paramtype sku: ~azure.mgmt.postgresqlflexibleservers.models.Sku - :keyword identity: User assigned managed identities assigned to the server. - :paramtype identity: ~azure.mgmt.postgresqlflexibleservers.models.UserAssignedIdentity - :keyword administrator_login: Name of the login designated as the first password based - administrator assigned to your instance of PostgreSQL. Must be specified the first time that - you enable password based authentication on a server. Once set to a given value, it cannot be - changed for the rest of the life of a server. If you disable password based authentication on a - server which had it enabled, this password based role isn't deleted. - :paramtype administrator_login: str - :keyword administrator_login_password: Password assigned to the administrator login. As long as - password authentication is enabled, this password can be changed at any time. - :paramtype administrator_login_password: str - :keyword version: Major version of PostgreSQL database engine. Known values are: "18", "17", - "16", "15", "14", "13", "12", and "11". - :paramtype version: str or ~azure.mgmt.postgresqlflexibleservers.models.PostgresMajorVersion - :keyword storage: Storage properties of a server. - :paramtype storage: ~azure.mgmt.postgresqlflexibleservers.models.Storage - :keyword auth_config: Authentication configuration properties of a server. - :paramtype auth_config: ~azure.mgmt.postgresqlflexibleservers.models.AuthConfig - :keyword data_encryption: Data encryption properties of a server. - :paramtype data_encryption: ~azure.mgmt.postgresqlflexibleservers.models.DataEncryption - :keyword backup: Backup properties of a server. - :paramtype backup: ~azure.mgmt.postgresqlflexibleservers.models.Backup - :keyword network: Network properties of a server. Only required if you want your server to be - integrated into a virtual network provided by customer. - :paramtype network: ~azure.mgmt.postgresqlflexibleservers.models.Network - :keyword high_availability: High availability properties of a server. - :paramtype high_availability: ~azure.mgmt.postgresqlflexibleservers.models.HighAvailability - :keyword maintenance_window: Maintenance window properties of a server. - :paramtype maintenance_window: ~azure.mgmt.postgresqlflexibleservers.models.MaintenanceWindow - :keyword source_server_resource_id: Identifier of the server to be used as the source of the - new server. Required when 'createMode' is 'PointInTimeRestore', 'GeoRestore', 'Replica', or - 'ReviveDropped'. This property is returned only when the target server is a read replica. - :paramtype source_server_resource_id: str - :keyword point_in_time_utc: Creation time (in ISO8601 format) of the backup which you want to - restore in the new server. It's required when 'createMode' is 'PointInTimeRestore', - 'GeoRestore', or 'ReviveDropped'. - :paramtype point_in_time_utc: ~datetime.datetime - :keyword availability_zone: Availability zone of a server. - :paramtype availability_zone: str - :keyword replication_role: Role of the server in a replication set. Known values are: "None", - "Primary", "AsyncReplica", and "GeoAsyncReplica". - :paramtype replication_role: str or - ~azure.mgmt.postgresqlflexibleservers.models.ReplicationRole - :keyword replica: Read replica properties of a server. Required only in case that you want to - promote a server. - :paramtype replica: ~azure.mgmt.postgresqlflexibleservers.models.Replica - :keyword create_mode: Creation mode of a new server. Known values are: "Default", "Create", - "Update", "PointInTimeRestore", "GeoRestore", "Replica", and "ReviveDropped". - :paramtype create_mode: str or ~azure.mgmt.postgresqlflexibleservers.models.CreateMode - :keyword cluster: Cluster properties of a server. - :paramtype cluster: ~azure.mgmt.postgresqlflexibleservers.models.Cluster - """ - super().__init__(tags=tags, location=location, **kwargs) - self.sku = sku - self.identity = identity - self.administrator_login = administrator_login - self.administrator_login_password = administrator_login_password - self.version = version - self.minor_version: Optional[str] = None - self.state: Optional[Union[str, "_models.ServerState"]] = None - self.fully_qualified_domain_name: Optional[str] = None - self.storage = storage - self.auth_config = auth_config - self.data_encryption = data_encryption - self.backup = backup - self.network = network - self.high_availability = high_availability - self.maintenance_window = maintenance_window - self.source_server_resource_id = source_server_resource_id - self.point_in_time_utc = point_in_time_utc - self.availability_zone = availability_zone - self.replication_role = replication_role - self.replica_capacity: Optional[int] = None - self.replica = replica - self.create_mode = create_mode - self.private_endpoint_connections: Optional[list["_models.PrivateEndpointConnection"]] = None - self.cluster = cluster - - -class ServerEditionCapability(CapabilityBase): - """Capabilities in terms of compute tier. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar status: The status of the capability. Known values are: "Visible", "Available", - "Default", and "Disabled". - :vartype status: str or ~azure.mgmt.postgresqlflexibleservers.models.CapabilityStatus - :ivar reason: The reason for the capability not being available. - :vartype reason: str - :ivar name: Name of compute tier. - :vartype name: str - :ivar default_sku_name: Default compute name (SKU) for this computer tier. - :vartype default_sku_name: str - :ivar supported_storage_editions: List of storage editions supported by this compute tier and - compute name. - :vartype supported_storage_editions: - list[~azure.mgmt.postgresqlflexibleservers.models.StorageEditionCapability] - :ivar supported_server_skus: List of supported compute names (SKUs). - :vartype supported_server_skus: - list[~azure.mgmt.postgresqlflexibleservers.models.ServerSkuCapability] - """ - - _validation = { - "status": {"readonly": True}, - "reason": {"readonly": True}, - "name": {"readonly": True}, - "default_sku_name": {"readonly": True}, - "supported_storage_editions": {"readonly": True}, - "supported_server_skus": {"readonly": True}, - } - - _attribute_map = { - "status": {"key": "status", "type": "str"}, - "reason": {"key": "reason", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "default_sku_name": {"key": "defaultSkuName", "type": "str"}, - "supported_storage_editions": {"key": "supportedStorageEditions", "type": "[StorageEditionCapability]"}, - "supported_server_skus": {"key": "supportedServerSkus", "type": "[ServerSkuCapability]"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.name: Optional[str] = None - self.default_sku_name: Optional[str] = None - self.supported_storage_editions: Optional[list["_models.StorageEditionCapability"]] = None - self.supported_server_skus: Optional[list["_models.ServerSkuCapability"]] = None - - -class ServerForPatch(_serialization.Model): - """Represents a server to be updated. - - :ivar sku: Compute tier and size of a server. - :vartype sku: ~azure.mgmt.postgresqlflexibleservers.models.SkuForPatch - :ivar identity: Describes the identity of the application. - :vartype identity: ~azure.mgmt.postgresqlflexibleservers.models.UserAssignedIdentity - :ivar tags: Application-specific metadata in the form of key-value pairs. - :vartype tags: dict[str, str] - :ivar administrator_login: Name of the login designated as the first password based - administrator assigned to your instance of PostgreSQL. Must be specified the first time that - you enable password based authentication on a server. Once set to a given value, it cannot be - changed for the rest of the life of a server. If you disable password based authentication on a - server which had it enabled, this password based role isn't deleted. - :vartype administrator_login: str - :ivar administrator_login_password: Password assigned to the administrator login. As long as - password authentication is enabled, this password can be changed at any time. - :vartype administrator_login_password: str - :ivar version: Major version of PostgreSQL database engine. Known values are: "18", "17", "16", - "15", "14", "13", "12", and "11". - :vartype version: str or ~azure.mgmt.postgresqlflexibleservers.models.PostgresMajorVersion - :ivar storage: Storage properties of a server. - :vartype storage: ~azure.mgmt.postgresqlflexibleservers.models.Storage - :ivar backup: Backup properties of a server. - :vartype backup: ~azure.mgmt.postgresqlflexibleservers.models.BackupForPatch - :ivar high_availability: High availability properties of a server. - :vartype high_availability: - ~azure.mgmt.postgresqlflexibleservers.models.HighAvailabilityForPatch - :ivar maintenance_window: Maintenance window properties of a server. - :vartype maintenance_window: - ~azure.mgmt.postgresqlflexibleservers.models.MaintenanceWindowForPatch - :ivar auth_config: Authentication configuration properties of a server. - :vartype auth_config: ~azure.mgmt.postgresqlflexibleservers.models.AuthConfigForPatch - :ivar data_encryption: Data encryption properties of a server. - :vartype data_encryption: ~azure.mgmt.postgresqlflexibleservers.models.DataEncryption - :ivar availability_zone: Availability zone of a server. - :vartype availability_zone: str - :ivar create_mode: Update mode of an existing server. Known values are: "Default" and "Update". - :vartype create_mode: str or ~azure.mgmt.postgresqlflexibleservers.models.CreateModeForPatch - :ivar replication_role: Role of the server in a replication set. Known values are: "None", - "Primary", "AsyncReplica", and "GeoAsyncReplica". - :vartype replication_role: str or ~azure.mgmt.postgresqlflexibleservers.models.ReplicationRole - :ivar replica: Read replica properties of a server. Required only in case that you want to - promote a server. - :vartype replica: ~azure.mgmt.postgresqlflexibleservers.models.Replica - :ivar network: Network properties of a server. Only required if you want your server to be - integrated into a virtual network provided by customer. - :vartype network: ~azure.mgmt.postgresqlflexibleservers.models.Network - :ivar cluster: Cluster properties of a server. - :vartype cluster: ~azure.mgmt.postgresqlflexibleservers.models.Cluster - """ - - _attribute_map = { - "sku": {"key": "sku", "type": "SkuForPatch"}, - "identity": {"key": "identity", "type": "UserAssignedIdentity"}, - "tags": {"key": "tags", "type": "{str}"}, - "administrator_login": {"key": "properties.administratorLogin", "type": "str"}, - "administrator_login_password": {"key": "properties.administratorLoginPassword", "type": "str"}, - "version": {"key": "properties.version", "type": "str"}, - "storage": {"key": "properties.storage", "type": "Storage"}, - "backup": {"key": "properties.backup", "type": "BackupForPatch"}, - "high_availability": {"key": "properties.highAvailability", "type": "HighAvailabilityForPatch"}, - "maintenance_window": {"key": "properties.maintenanceWindow", "type": "MaintenanceWindowForPatch"}, - "auth_config": {"key": "properties.authConfig", "type": "AuthConfigForPatch"}, - "data_encryption": {"key": "properties.dataEncryption", "type": "DataEncryption"}, - "availability_zone": {"key": "properties.availabilityZone", "type": "str"}, - "create_mode": {"key": "properties.createMode", "type": "str"}, - "replication_role": {"key": "properties.replicationRole", "type": "str"}, - "replica": {"key": "properties.replica", "type": "Replica"}, - "network": {"key": "properties.network", "type": "Network"}, - "cluster": {"key": "properties.cluster", "type": "Cluster"}, - } - - def __init__( - self, - *, - sku: Optional["_models.SkuForPatch"] = None, - identity: Optional["_models.UserAssignedIdentity"] = None, - tags: Optional[dict[str, str]] = None, - administrator_login: Optional[str] = None, - administrator_login_password: Optional[str] = None, - version: Optional[Union[str, "_models.PostgresMajorVersion"]] = None, - storage: Optional["_models.Storage"] = None, - backup: Optional["_models.BackupForPatch"] = None, - high_availability: Optional["_models.HighAvailabilityForPatch"] = None, - maintenance_window: Optional["_models.MaintenanceWindowForPatch"] = None, - auth_config: Optional["_models.AuthConfigForPatch"] = None, - data_encryption: Optional["_models.DataEncryption"] = None, - availability_zone: str = "", - create_mode: Optional[Union[str, "_models.CreateModeForPatch"]] = None, - replication_role: Optional[Union[str, "_models.ReplicationRole"]] = None, - replica: Optional["_models.Replica"] = None, - network: Optional["_models.Network"] = None, - cluster: Optional["_models.Cluster"] = None, - **kwargs: Any - ) -> None: - """ - :keyword sku: Compute tier and size of a server. - :paramtype sku: ~azure.mgmt.postgresqlflexibleservers.models.SkuForPatch - :keyword identity: Describes the identity of the application. - :paramtype identity: ~azure.mgmt.postgresqlflexibleservers.models.UserAssignedIdentity - :keyword tags: Application-specific metadata in the form of key-value pairs. - :paramtype tags: dict[str, str] - :keyword administrator_login: Name of the login designated as the first password based - administrator assigned to your instance of PostgreSQL. Must be specified the first time that - you enable password based authentication on a server. Once set to a given value, it cannot be - changed for the rest of the life of a server. If you disable password based authentication on a - server which had it enabled, this password based role isn't deleted. - :paramtype administrator_login: str - :keyword administrator_login_password: Password assigned to the administrator login. As long as - password authentication is enabled, this password can be changed at any time. - :paramtype administrator_login_password: str - :keyword version: Major version of PostgreSQL database engine. Known values are: "18", "17", - "16", "15", "14", "13", "12", and "11". - :paramtype version: str or ~azure.mgmt.postgresqlflexibleservers.models.PostgresMajorVersion - :keyword storage: Storage properties of a server. - :paramtype storage: ~azure.mgmt.postgresqlflexibleservers.models.Storage - :keyword backup: Backup properties of a server. - :paramtype backup: ~azure.mgmt.postgresqlflexibleservers.models.BackupForPatch - :keyword high_availability: High availability properties of a server. - :paramtype high_availability: - ~azure.mgmt.postgresqlflexibleservers.models.HighAvailabilityForPatch - :keyword maintenance_window: Maintenance window properties of a server. - :paramtype maintenance_window: - ~azure.mgmt.postgresqlflexibleservers.models.MaintenanceWindowForPatch - :keyword auth_config: Authentication configuration properties of a server. - :paramtype auth_config: ~azure.mgmt.postgresqlflexibleservers.models.AuthConfigForPatch - :keyword data_encryption: Data encryption properties of a server. - :paramtype data_encryption: ~azure.mgmt.postgresqlflexibleservers.models.DataEncryption - :keyword availability_zone: Availability zone of a server. - :paramtype availability_zone: str - :keyword create_mode: Update mode of an existing server. Known values are: "Default" and - "Update". - :paramtype create_mode: str or ~azure.mgmt.postgresqlflexibleservers.models.CreateModeForPatch - :keyword replication_role: Role of the server in a replication set. Known values are: "None", - "Primary", "AsyncReplica", and "GeoAsyncReplica". - :paramtype replication_role: str or - ~azure.mgmt.postgresqlflexibleservers.models.ReplicationRole - :keyword replica: Read replica properties of a server. Required only in case that you want to - promote a server. - :paramtype replica: ~azure.mgmt.postgresqlflexibleservers.models.Replica - :keyword network: Network properties of a server. Only required if you want your server to be - integrated into a virtual network provided by customer. - :paramtype network: ~azure.mgmt.postgresqlflexibleservers.models.Network - :keyword cluster: Cluster properties of a server. - :paramtype cluster: ~azure.mgmt.postgresqlflexibleservers.models.Cluster - """ - super().__init__(**kwargs) - self.sku = sku - self.identity = identity - self.tags = tags - self.administrator_login = administrator_login - self.administrator_login_password = administrator_login_password - self.version = version - self.storage = storage - self.backup = backup - self.high_availability = high_availability - self.maintenance_window = maintenance_window - self.auth_config = auth_config - self.data_encryption = data_encryption - self.availability_zone = availability_zone - self.create_mode = create_mode - self.replication_role = replication_role - self.replica = replica - self.network = network - self.cluster = cluster - - -class ServerList(_serialization.Model): - """A list of servers. - - :ivar value: The list of servers. - :vartype value: list[~azure.mgmt.postgresqlflexibleservers.models.Server] - :ivar next_link: The link used to get the next page of operations. - :vartype next_link: str - """ - - _attribute_map = { - "value": {"key": "value", "type": "[Server]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, *, value: Optional[list["_models.Server"]] = None, next_link: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword value: The list of servers. - :paramtype value: list[~azure.mgmt.postgresqlflexibleservers.models.Server] - :keyword next_link: The link used to get the next page of operations. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class ServerSku(_serialization.Model): - """Compute information of a server. - - :ivar name: Compute tier and size of the database server. This object is empty for an Azure - Database for PostgreSQL single server. - :vartype name: str - :ivar tier: Tier of the compute assigned to a server. Known values are: "Burstable", - "GeneralPurpose", and "MemoryOptimized". - :vartype tier: str or ~azure.mgmt.postgresqlflexibleservers.models.SkuTier - """ - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "tier": {"key": "tier", "type": "str"}, - } - - def __init__( - self, *, name: Optional[str] = None, tier: Optional[Union[str, "_models.SkuTier"]] = None, **kwargs: Any - ) -> None: - """ - :keyword name: Compute tier and size of the database server. This object is empty for an Azure - Database for PostgreSQL single server. - :paramtype name: str - :keyword tier: Tier of the compute assigned to a server. Known values are: "Burstable", - "GeneralPurpose", and "MemoryOptimized". - :paramtype tier: str or ~azure.mgmt.postgresqlflexibleservers.models.SkuTier - """ - super().__init__(**kwargs) - self.name = name - self.tier = tier - - -class ServerSkuCapability(CapabilityBase): - """Capabilities in terms of compute. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar status: The status of the capability. Known values are: "Visible", "Available", - "Default", and "Disabled". - :vartype status: str or ~azure.mgmt.postgresqlflexibleservers.models.CapabilityStatus - :ivar reason: The reason for the capability not being available. - :vartype reason: str - :ivar name: Name of the compute (SKU). - :vartype name: str - :ivar v_cores: vCores available for this compute. - :vartype v_cores: int - :ivar supported_iops: Maximum IOPS supported by this compute. - :vartype supported_iops: int - :ivar supported_memory_per_vcore_mb: Supported memory (in MB) per virtual core assigned to this - compute. - :vartype supported_memory_per_vcore_mb: int - :ivar supported_zones: List of supported availability zones. E.g. '1', '2', '3'. - :vartype supported_zones: list[str] - :ivar supported_ha_mode: Modes of high availability supported for this compute. - :vartype supported_ha_mode: list[str or - ~azure.mgmt.postgresqlflexibleservers.models.HighAvailabilityMode] - :ivar supported_features: Features supported. - :vartype supported_features: - list[~azure.mgmt.postgresqlflexibleservers.models.SupportedFeature] - :ivar security_profile: Security profile of the compute. Indicates if it's a Confidential - Compute virtual machine. - :vartype security_profile: str - """ - - _validation = { - "status": {"readonly": True}, - "reason": {"readonly": True}, - "name": {"readonly": True}, - "v_cores": {"readonly": True}, - "supported_iops": {"readonly": True}, - "supported_memory_per_vcore_mb": {"readonly": True}, - "supported_zones": {"readonly": True}, - "supported_ha_mode": {"readonly": True}, - "supported_features": {"readonly": True}, - "security_profile": {"readonly": True}, - } - - _attribute_map = { - "status": {"key": "status", "type": "str"}, - "reason": {"key": "reason", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "v_cores": {"key": "vCores", "type": "int"}, - "supported_iops": {"key": "supportedIops", "type": "int"}, - "supported_memory_per_vcore_mb": {"key": "supportedMemoryPerVcoreMb", "type": "int"}, - "supported_zones": {"key": "supportedZones", "type": "[str]"}, - "supported_ha_mode": {"key": "supportedHaMode", "type": "[str]"}, - "supported_features": {"key": "supportedFeatures", "type": "[SupportedFeature]"}, - "security_profile": {"key": "securityProfile", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.name: Optional[str] = None - self.v_cores: Optional[int] = None - self.supported_iops: Optional[int] = None - self.supported_memory_per_vcore_mb: Optional[int] = None - self.supported_zones: Optional[list[str]] = None - self.supported_ha_mode: Optional[list[Union[str, "_models.HighAvailabilityMode"]]] = None - self.supported_features: Optional[list["_models.SupportedFeature"]] = None - self.security_profile: Optional[str] = None - - -class ServerVersionCapability(CapabilityBase): - """Capabilities in terms of major versions of PostgreSQL database engine. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar status: The status of the capability. Known values are: "Visible", "Available", - "Default", and "Disabled". - :vartype status: str or ~azure.mgmt.postgresqlflexibleservers.models.CapabilityStatus - :ivar reason: The reason for the capability not being available. - :vartype reason: str - :ivar name: Major version of PostgreSQL database engine. - :vartype name: str - :ivar supported_versions_to_upgrade: Major versions of PostgreSQL database engine to which this - version can be automatically upgraded. - :vartype supported_versions_to_upgrade: list[str] - :ivar supported_features: Features supported. - :vartype supported_features: - list[~azure.mgmt.postgresqlflexibleservers.models.SupportedFeature] - """ - - _validation = { - "status": {"readonly": True}, - "reason": {"readonly": True}, - "name": {"readonly": True}, - "supported_versions_to_upgrade": {"readonly": True}, - "supported_features": {"readonly": True}, - } - - _attribute_map = { - "status": {"key": "status", "type": "str"}, - "reason": {"key": "reason", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "supported_versions_to_upgrade": {"key": "supportedVersionsToUpgrade", "type": "[str]"}, - "supported_features": {"key": "supportedFeatures", "type": "[SupportedFeature]"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.name: Optional[str] = None - self.supported_versions_to_upgrade: Optional[list[str]] = None - self.supported_features: Optional[list["_models.SupportedFeature"]] = None - - -class Sku(_serialization.Model): - """Compute information of a server. - - All required parameters must be populated in order to send to server. - - :ivar name: Name by which is known a given compute size assigned to a server. Required. - :vartype name: str - :ivar tier: Tier of the compute assigned to a server. Required. Known values are: "Burstable", - "GeneralPurpose", and "MemoryOptimized". - :vartype tier: str or ~azure.mgmt.postgresqlflexibleservers.models.SkuTier - """ - - _validation = { - "name": {"required": True}, - "tier": {"required": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "tier": {"key": "tier", "type": "str"}, - } - - def __init__(self, *, name: str, tier: Union[str, "_models.SkuTier"], **kwargs: Any) -> None: - """ - :keyword name: Name by which is known a given compute size assigned to a server. Required. - :paramtype name: str - :keyword tier: Tier of the compute assigned to a server. Required. Known values are: - "Burstable", "GeneralPurpose", and "MemoryOptimized". - :paramtype tier: str or ~azure.mgmt.postgresqlflexibleservers.models.SkuTier - """ - super().__init__(**kwargs) - self.name = name - self.tier = tier - - -class SkuForPatch(_serialization.Model): - """Compute information of a server. - - :ivar name: Name by which is known a given compute size assigned to a server. - :vartype name: str - :ivar tier: Tier of the compute assigned to a server. Known values are: "Burstable", - "GeneralPurpose", and "MemoryOptimized". - :vartype tier: str or ~azure.mgmt.postgresqlflexibleservers.models.SkuTier - """ - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "tier": {"key": "tier", "type": "str"}, - } - - def __init__( - self, *, name: Optional[str] = None, tier: Optional[Union[str, "_models.SkuTier"]] = None, **kwargs: Any - ) -> None: - """ - :keyword name: Name by which is known a given compute size assigned to a server. - :paramtype name: str - :keyword tier: Tier of the compute assigned to a server. Known values are: "Burstable", - "GeneralPurpose", and "MemoryOptimized". - :paramtype tier: str or ~azure.mgmt.postgresqlflexibleservers.models.SkuTier - """ - super().__init__(**kwargs) - self.name = name - self.tier = tier - - -class Storage(_serialization.Model): - """Storage properties of a server. - - :ivar storage_size_gb: Size of storage assigned to a server. - :vartype storage_size_gb: int - :ivar auto_grow: Flag to enable or disable the automatic growth of storage size of a server - when available space is nearing zero and conditions allow for automatically growing storage - size. Known values are: "Enabled" and "Disabled". - :vartype auto_grow: str or ~azure.mgmt.postgresqlflexibleservers.models.StorageAutoGrow - :ivar tier: Storage tier of a server. Known values are: "P1", "P2", "P3", "P4", "P6", "P10", - "P15", "P20", "P30", "P40", "P50", "P60", "P70", and "P80". - :vartype tier: str or - ~azure.mgmt.postgresqlflexibleservers.models.AzureManagedDiskPerformanceTier - :ivar iops: Maximum IOPS supported for storage. Required when type of storage is PremiumV2_LRS - or UltraSSD_LRS. - :vartype iops: int - :ivar throughput: Maximum throughput supported for storage. Required when type of storage is - PremiumV2_LRS or UltraSSD_LRS. - :vartype throughput: int - :ivar type: Type of storage assigned to a server. Allowed values are Premium_LRS, - PremiumV2_LRS, or UltraSSD_LRS. If not specified, it defaults to Premium_LRS. Known values are: - "Premium_LRS", "PremiumV2_LRS", and "UltraSSD_LRS". - :vartype type: str or ~azure.mgmt.postgresqlflexibleservers.models.StorageType - """ - - _attribute_map = { - "storage_size_gb": {"key": "storageSizeGB", "type": "int"}, - "auto_grow": {"key": "autoGrow", "type": "str"}, - "tier": {"key": "tier", "type": "str"}, - "iops": {"key": "iops", "type": "int"}, - "throughput": {"key": "throughput", "type": "int"}, - "type": {"key": "type", "type": "str"}, - } - - def __init__( - self, - *, - storage_size_gb: Optional[int] = None, - auto_grow: Optional[Union[str, "_models.StorageAutoGrow"]] = None, - tier: Optional[Union[str, "_models.AzureManagedDiskPerformanceTier"]] = None, - iops: Optional[int] = None, - throughput: Optional[int] = None, - type: Optional[Union[str, "_models.StorageType"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword storage_size_gb: Size of storage assigned to a server. - :paramtype storage_size_gb: int - :keyword auto_grow: Flag to enable or disable the automatic growth of storage size of a server - when available space is nearing zero and conditions allow for automatically growing storage - size. Known values are: "Enabled" and "Disabled". - :paramtype auto_grow: str or ~azure.mgmt.postgresqlflexibleservers.models.StorageAutoGrow - :keyword tier: Storage tier of a server. Known values are: "P1", "P2", "P3", "P4", "P6", "P10", - "P15", "P20", "P30", "P40", "P50", "P60", "P70", and "P80". - :paramtype tier: str or - ~azure.mgmt.postgresqlflexibleservers.models.AzureManagedDiskPerformanceTier - :keyword iops: Maximum IOPS supported for storage. Required when type of storage is - PremiumV2_LRS or UltraSSD_LRS. - :paramtype iops: int - :keyword throughput: Maximum throughput supported for storage. Required when type of storage is - PremiumV2_LRS or UltraSSD_LRS. - :paramtype throughput: int - :keyword type: Type of storage assigned to a server. Allowed values are Premium_LRS, - PremiumV2_LRS, or UltraSSD_LRS. If not specified, it defaults to Premium_LRS. Known values are: - "Premium_LRS", "PremiumV2_LRS", and "UltraSSD_LRS". - :paramtype type: str or ~azure.mgmt.postgresqlflexibleservers.models.StorageType - """ - super().__init__(**kwargs) - self.storage_size_gb = storage_size_gb - self.auto_grow = auto_grow - self.tier = tier - self.iops = iops - self.throughput = throughput - self.type = type - - -class StorageEditionCapability(CapabilityBase): - """Capabilities in terms of storage tier. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar status: The status of the capability. Known values are: "Visible", "Available", - "Default", and "Disabled". - :vartype status: str or ~azure.mgmt.postgresqlflexibleservers.models.CapabilityStatus - :ivar reason: The reason for the capability not being available. - :vartype reason: str - :ivar name: Name of storage tier. - :vartype name: str - :ivar default_storage_size_mb: Default storage size (in MB) for this storage tier. - :vartype default_storage_size_mb: int - :ivar supported_storage_mb: Configurations of storage supported for this storage tier. - :vartype supported_storage_mb: - list[~azure.mgmt.postgresqlflexibleservers.models.StorageMbCapability] - """ - - _validation = { - "status": {"readonly": True}, - "reason": {"readonly": True}, - "name": {"readonly": True}, - "default_storage_size_mb": {"readonly": True}, - "supported_storage_mb": {"readonly": True}, - } - - _attribute_map = { - "status": {"key": "status", "type": "str"}, - "reason": {"key": "reason", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "default_storage_size_mb": {"key": "defaultStorageSizeMb", "type": "int"}, - "supported_storage_mb": {"key": "supportedStorageMb", "type": "[StorageMbCapability]"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.name: Optional[str] = None - self.default_storage_size_mb: Optional[int] = None - self.supported_storage_mb: Optional[list["_models.StorageMbCapability"]] = None - - -class StorageMbCapability(CapabilityBase): - """Storage size (in MB) capability. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar status: The status of the capability. Known values are: "Visible", "Available", - "Default", and "Disabled". - :vartype status: str or ~azure.mgmt.postgresqlflexibleservers.models.CapabilityStatus - :ivar reason: The reason for the capability not being available. - :vartype reason: str - :ivar supported_iops: Minimum IOPS supported by the storage size. - :vartype supported_iops: int - :ivar supported_maximum_iops: Maximum IOPS supported by the storage size. - :vartype supported_maximum_iops: int - :ivar storage_size_mb: Minimum supported size (in MB) of storage. - :vartype storage_size_mb: int - :ivar maximum_storage_size_mb: Maximum supported size (in MB) of storage. - :vartype maximum_storage_size_mb: int - :ivar supported_throughput: Minimum supported throughput (in MB/s) of storage. - :vartype supported_throughput: int - :ivar supported_maximum_throughput: Maximum supported throughput (in MB/s) of storage. - :vartype supported_maximum_throughput: int - :ivar default_iops_tier: Default IOPS for this tier and storage size. - :vartype default_iops_tier: str - :ivar supported_iops_tiers: List of all supported storage tiers for this tier and storage size. - :vartype supported_iops_tiers: - list[~azure.mgmt.postgresqlflexibleservers.models.StorageTierCapability] - """ - - _validation = { - "status": {"readonly": True}, - "reason": {"readonly": True}, - "supported_iops": {"readonly": True}, - "supported_maximum_iops": {"readonly": True}, - "storage_size_mb": {"readonly": True}, - "maximum_storage_size_mb": {"readonly": True}, - "supported_throughput": {"readonly": True}, - "supported_maximum_throughput": {"readonly": True}, - "default_iops_tier": {"readonly": True}, - "supported_iops_tiers": {"readonly": True}, - } - - _attribute_map = { - "status": {"key": "status", "type": "str"}, - "reason": {"key": "reason", "type": "str"}, - "supported_iops": {"key": "supportedIops", "type": "int"}, - "supported_maximum_iops": {"key": "supportedMaximumIops", "type": "int"}, - "storage_size_mb": {"key": "storageSizeMb", "type": "int"}, - "maximum_storage_size_mb": {"key": "maximumStorageSizeMb", "type": "int"}, - "supported_throughput": {"key": "supportedThroughput", "type": "int"}, - "supported_maximum_throughput": {"key": "supportedMaximumThroughput", "type": "int"}, - "default_iops_tier": {"key": "defaultIopsTier", "type": "str"}, - "supported_iops_tiers": {"key": "supportedIopsTiers", "type": "[StorageTierCapability]"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.supported_iops: Optional[int] = None - self.supported_maximum_iops: Optional[int] = None - self.storage_size_mb: Optional[int] = None - self.maximum_storage_size_mb: Optional[int] = None - self.supported_throughput: Optional[int] = None - self.supported_maximum_throughput: Optional[int] = None - self.default_iops_tier: Optional[str] = None - self.supported_iops_tiers: Optional[list["_models.StorageTierCapability"]] = None - - -class StorageTierCapability(CapabilityBase): - """Capability of a storage tier. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar status: The status of the capability. Known values are: "Visible", "Available", - "Default", and "Disabled". - :vartype status: str or ~azure.mgmt.postgresqlflexibleservers.models.CapabilityStatus - :ivar reason: The reason for the capability not being available. - :vartype reason: str - :ivar name: Name of the storage tier. - :vartype name: str - :ivar iops: Supported IOPS for the storage tier. - :vartype iops: int - """ - - _validation = { - "status": {"readonly": True}, - "reason": {"readonly": True}, - "name": {"readonly": True}, - "iops": {"readonly": True}, - } - - _attribute_map = { - "status": {"key": "status", "type": "str"}, - "reason": {"key": "reason", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "iops": {"key": "iops", "type": "int"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.name: Optional[str] = None - self.iops: Optional[int] = None - - -class SupportedFeature(_serialization.Model): - """Features supported. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar name: Name of the feature. - :vartype name: str - :ivar status: Status of the feature. Indicates if the feature is enabled or not. Known values - are: "Enabled" and "Disabled". - :vartype status: str or ~azure.mgmt.postgresqlflexibleservers.models.FeatureStatus - """ - - _validation = { - "name": {"readonly": True}, - "status": {"readonly": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "status": {"key": "status", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.name: Optional[str] = None - self.status: Optional[Union[str, "_models.FeatureStatus"]] = None - - -class SystemData(_serialization.Model): - """Metadata pertaining to creation and last modification of the resource. - - :ivar created_by: The identity that created the resource. - :vartype created_by: str - :ivar created_by_type: The type of identity that created the resource. Known values are: - "User", "Application", "ManagedIdentity", and "Key". - :vartype created_by_type: str or ~azure.mgmt.postgresqlflexibleservers.models.CreatedByType - :ivar created_at: The timestamp of resource creation (UTC). - :vartype created_at: ~datetime.datetime - :ivar last_modified_by: The identity that last modified the resource. - :vartype last_modified_by: str - :ivar last_modified_by_type: The type of identity that last modified the resource. Known values - are: "User", "Application", "ManagedIdentity", and "Key". - :vartype last_modified_by_type: str or - ~azure.mgmt.postgresqlflexibleservers.models.CreatedByType - :ivar last_modified_at: The timestamp of resource last modification (UTC). - :vartype last_modified_at: ~datetime.datetime - """ - - _attribute_map = { - "created_by": {"key": "createdBy", "type": "str"}, - "created_by_type": {"key": "createdByType", "type": "str"}, - "created_at": {"key": "createdAt", "type": "iso-8601"}, - "last_modified_by": {"key": "lastModifiedBy", "type": "str"}, - "last_modified_by_type": {"key": "lastModifiedByType", "type": "str"}, - "last_modified_at": {"key": "lastModifiedAt", "type": "iso-8601"}, - } - - def __init__( - self, - *, - created_by: Optional[str] = None, - created_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, - created_at: Optional[datetime.datetime] = None, - last_modified_by: Optional[str] = None, - last_modified_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, - last_modified_at: Optional[datetime.datetime] = None, - **kwargs: Any - ) -> None: - """ - :keyword created_by: The identity that created the resource. - :paramtype created_by: str - :keyword created_by_type: The type of identity that created the resource. Known values are: - "User", "Application", "ManagedIdentity", and "Key". - :paramtype created_by_type: str or ~azure.mgmt.postgresqlflexibleservers.models.CreatedByType - :keyword created_at: The timestamp of resource creation (UTC). - :paramtype created_at: ~datetime.datetime - :keyword last_modified_by: The identity that last modified the resource. - :paramtype last_modified_by: str - :keyword last_modified_by_type: The type of identity that last modified the resource. Known - values are: "User", "Application", "ManagedIdentity", and "Key". - :paramtype last_modified_by_type: str or - ~azure.mgmt.postgresqlflexibleservers.models.CreatedByType - :keyword last_modified_at: The timestamp of resource last modification (UTC). - :paramtype last_modified_at: ~datetime.datetime - """ - super().__init__(**kwargs) - self.created_by = created_by - self.created_by_type = created_by_type - self.created_at = created_at - self.last_modified_by = last_modified_by - self.last_modified_by_type = last_modified_by_type - self.last_modified_at = last_modified_at - - -class TuningOptions(ProxyResource): - """Impact on some metric if this recommended action is applied. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Fully qualified resource ID for the resource. E.g. - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}". - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or - "Microsoft.Storage/storageAccounts". - :vartype type: str - :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy - information. - :vartype system_data: ~azure.mgmt.postgresqlflexibleservers.models.SystemData - """ - - -class TuningOptionsList(_serialization.Model): - """List of server tuning options. - - :ivar value: List of available tuning options. - :vartype value: list[~azure.mgmt.postgresqlflexibleservers.models.TuningOptions] - :ivar next_link: Link used to get the next page of results. - :vartype next_link: str - """ - - _attribute_map = { - "value": {"key": "value", "type": "[TuningOptions]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, *, value: Optional[list["_models.TuningOptions"]] = None, next_link: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword value: List of available tuning options. - :paramtype value: list[~azure.mgmt.postgresqlflexibleservers.models.TuningOptions] - :keyword next_link: Link used to get the next page of results. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class UserAssignedIdentity(_serialization.Model): - """Identities associated with a server. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to server. - - :ivar user_assigned_identities: Map of user assigned managed identities. - :vartype user_assigned_identities: dict[str, - ~azure.mgmt.postgresqlflexibleservers.models.UserIdentity] - :ivar principal_id: Identifier of the object of the service principal associated to the user - assigned managed identity. - :vartype principal_id: str - :ivar type: Types of identities associated with a server. Required. Known values are: "None", - "UserAssigned", "SystemAssigned", and "SystemAssigned,UserAssigned". - :vartype type: str or ~azure.mgmt.postgresqlflexibleservers.models.IdentityType - :ivar tenant_id: Identifier of the tenant of a server. - :vartype tenant_id: str - """ - - _validation = { - "type": {"required": True}, - "tenant_id": {"readonly": True}, - } - - _attribute_map = { - "user_assigned_identities": {"key": "userAssignedIdentities", "type": "{UserIdentity}"}, - "principal_id": {"key": "principalId", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "tenant_id": {"key": "tenantId", "type": "str"}, - } - - def __init__( - self, - *, - type: Union[str, "_models.IdentityType"], - user_assigned_identities: Optional[dict[str, "_models.UserIdentity"]] = None, - principal_id: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword user_assigned_identities: Map of user assigned managed identities. - :paramtype user_assigned_identities: dict[str, - ~azure.mgmt.postgresqlflexibleservers.models.UserIdentity] - :keyword principal_id: Identifier of the object of the service principal associated to the user - assigned managed identity. - :paramtype principal_id: str - :keyword type: Types of identities associated with a server. Required. Known values are: - "None", "UserAssigned", "SystemAssigned", and "SystemAssigned,UserAssigned". - :paramtype type: str or ~azure.mgmt.postgresqlflexibleservers.models.IdentityType - """ - super().__init__(**kwargs) - self.user_assigned_identities = user_assigned_identities - self.principal_id = principal_id - self.type = type - self.tenant_id: Optional[str] = None - - -class UserIdentity(_serialization.Model): - """User assigned managed identity associated with a server. - - :ivar principal_id: Identifier of the object of the service principal associated to the user - assigned managed identity. - :vartype principal_id: str - :ivar client_id: Identifier of the client of the service principal associated to the user - assigned managed identity. - :vartype client_id: str - """ - - _attribute_map = { - "principal_id": {"key": "principalId", "type": "str"}, - "client_id": {"key": "clientId", "type": "str"}, - } - - def __init__(self, *, principal_id: Optional[str] = None, client_id: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword principal_id: Identifier of the object of the service principal associated to the user - assigned managed identity. - :paramtype principal_id: str - :keyword client_id: Identifier of the client of the service principal associated to the user - assigned managed identity. - :paramtype client_id: str - """ - super().__init__(**kwargs) - self.principal_id = principal_id - self.client_id = client_id - - -class ValidationDetails(_serialization.Model): - """Details for the validation for migration. - - :ivar status: Validation status for migration. Known values are: "Failed", "Succeeded", and - "Warning". - :vartype status: str or ~azure.mgmt.postgresqlflexibleservers.models.ValidationState - :ivar validation_start_time_in_utc: Start time (UTC) for validation. - :vartype validation_start_time_in_utc: ~datetime.datetime - :ivar validation_end_time_in_utc: End time (UTC) for validation. - :vartype validation_end_time_in_utc: ~datetime.datetime - :ivar server_level_validation_details: Details of server level validations. - :vartype server_level_validation_details: - list[~azure.mgmt.postgresqlflexibleservers.models.ValidationSummaryItem] - :ivar db_level_validation_details: Details of server level validations. - :vartype db_level_validation_details: - list[~azure.mgmt.postgresqlflexibleservers.models.DbLevelValidationStatus] - """ - - _attribute_map = { - "status": {"key": "status", "type": "str"}, - "validation_start_time_in_utc": {"key": "validationStartTimeInUtc", "type": "iso-8601"}, - "validation_end_time_in_utc": {"key": "validationEndTimeInUtc", "type": "iso-8601"}, - "server_level_validation_details": {"key": "serverLevelValidationDetails", "type": "[ValidationSummaryItem]"}, - "db_level_validation_details": {"key": "dbLevelValidationDetails", "type": "[DbLevelValidationStatus]"}, - } - - def __init__( - self, - *, - status: Optional[Union[str, "_models.ValidationState"]] = None, - validation_start_time_in_utc: Optional[datetime.datetime] = None, - validation_end_time_in_utc: Optional[datetime.datetime] = None, - server_level_validation_details: Optional[list["_models.ValidationSummaryItem"]] = None, - db_level_validation_details: Optional[list["_models.DbLevelValidationStatus"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword status: Validation status for migration. Known values are: "Failed", "Succeeded", and - "Warning". - :paramtype status: str or ~azure.mgmt.postgresqlflexibleservers.models.ValidationState - :keyword validation_start_time_in_utc: Start time (UTC) for validation. - :paramtype validation_start_time_in_utc: ~datetime.datetime - :keyword validation_end_time_in_utc: End time (UTC) for validation. - :paramtype validation_end_time_in_utc: ~datetime.datetime - :keyword server_level_validation_details: Details of server level validations. - :paramtype server_level_validation_details: - list[~azure.mgmt.postgresqlflexibleservers.models.ValidationSummaryItem] - :keyword db_level_validation_details: Details of server level validations. - :paramtype db_level_validation_details: - list[~azure.mgmt.postgresqlflexibleservers.models.DbLevelValidationStatus] - """ - super().__init__(**kwargs) - self.status = status - self.validation_start_time_in_utc = validation_start_time_in_utc - self.validation_end_time_in_utc = validation_end_time_in_utc - self.server_level_validation_details = server_level_validation_details - self.db_level_validation_details = db_level_validation_details - - -class ValidationMessage(_serialization.Model): - """Validation message object. - - :ivar state: Severity of validation message. Known values are: "Failed", "Succeeded", and - "Warning". - :vartype state: str or ~azure.mgmt.postgresqlflexibleservers.models.ValidationState - :ivar message: Validation message string. - :vartype message: str - """ - - _attribute_map = { - "state": {"key": "state", "type": "str"}, - "message": {"key": "message", "type": "str"}, - } - - def __init__( - self, - *, - state: Optional[Union[str, "_models.ValidationState"]] = None, - message: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword state: Severity of validation message. Known values are: "Failed", "Succeeded", and - "Warning". - :paramtype state: str or ~azure.mgmt.postgresqlflexibleservers.models.ValidationState - :keyword message: Validation message string. - :paramtype message: str - """ - super().__init__(**kwargs) - self.state = state - self.message = message - - -class ValidationSummaryItem(_serialization.Model): - """Validation summary object. - - :ivar type: Validation type. - :vartype type: str - :ivar state: Validation status for migration. Known values are: "Failed", "Succeeded", and - "Warning". - :vartype state: str or ~azure.mgmt.postgresqlflexibleservers.models.ValidationState - :ivar messages: Validation messages. - :vartype messages: list[~azure.mgmt.postgresqlflexibleservers.models.ValidationMessage] - """ - - _attribute_map = { - "type": {"key": "type", "type": "str"}, - "state": {"key": "state", "type": "str"}, - "messages": {"key": "messages", "type": "[ValidationMessage]"}, - } - - def __init__( - self, - *, - type: Optional[str] = None, - state: Optional[Union[str, "_models.ValidationState"]] = None, - messages: Optional[list["_models.ValidationMessage"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword type: Validation type. - :paramtype type: str - :keyword state: Validation status for migration. Known values are: "Failed", "Succeeded", and - "Warning". - :paramtype state: str or ~azure.mgmt.postgresqlflexibleservers.models.ValidationState - :keyword messages: Validation messages. - :paramtype messages: list[~azure.mgmt.postgresqlflexibleservers.models.ValidationMessage] - """ - super().__init__(**kwargs) - self.type = type - self.state = state - self.messages = messages - - -class VirtualEndpointResourceForPatch(_serialization.Model): - """Pair of virtual endpoints for a server. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar endpoint_type: Type of endpoint for the virtual endpoints. "ReadWrite" - :vartype endpoint_type: str or ~azure.mgmt.postgresqlflexibleservers.models.VirtualEndpointType - :ivar members: List of servers that one of the virtual endpoints can refer to. - :vartype members: list[str] - :ivar virtual_endpoints: List of virtual endpoints for a server. - :vartype virtual_endpoints: list[str] - """ - - _validation = { - "virtual_endpoints": {"readonly": True}, - } - - _attribute_map = { - "endpoint_type": {"key": "properties.endpointType", "type": "str"}, - "members": {"key": "properties.members", "type": "[str]"}, - "virtual_endpoints": {"key": "properties.virtualEndpoints", "type": "[str]"}, - } - - def __init__( - self, - *, - endpoint_type: Optional[Union[str, "_models.VirtualEndpointType"]] = None, - members: Optional[list[str]] = None, - **kwargs: Any - ) -> None: - """ - :keyword endpoint_type: Type of endpoint for the virtual endpoints. "ReadWrite" - :paramtype endpoint_type: str or - ~azure.mgmt.postgresqlflexibleservers.models.VirtualEndpointType - :keyword members: List of servers that one of the virtual endpoints can refer to. - :paramtype members: list[str] - """ - super().__init__(**kwargs) - self.endpoint_type = endpoint_type - self.members = members - self.virtual_endpoints: Optional[list[str]] = None - - -class VirtualEndpoint(VirtualEndpointResourceForPatch, Resource): - """Pair of virtual endpoints for a server. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Fully qualified resource ID for the resource. E.g. - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}". - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or - "Microsoft.Storage/storageAccounts". - :vartype type: str - :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy - information. - :vartype system_data: ~azure.mgmt.postgresqlflexibleservers.models.SystemData - :ivar endpoint_type: Type of endpoint for the virtual endpoints. "ReadWrite" - :vartype endpoint_type: str or ~azure.mgmt.postgresqlflexibleservers.models.VirtualEndpointType - :ivar members: List of servers that one of the virtual endpoints can refer to. - :vartype members: list[str] - :ivar virtual_endpoints: List of virtual endpoints for a server. - :vartype virtual_endpoints: list[str] - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "system_data": {"readonly": True}, - "virtual_endpoints": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "system_data": {"key": "systemData", "type": "SystemData"}, - "endpoint_type": {"key": "properties.endpointType", "type": "str"}, - "members": {"key": "properties.members", "type": "[str]"}, - "virtual_endpoints": {"key": "properties.virtualEndpoints", "type": "[str]"}, - } - - def __init__( - self, - *, - endpoint_type: Optional[Union[str, "_models.VirtualEndpointType"]] = None, - members: Optional[list[str]] = None, - **kwargs: Any - ) -> None: - """ - :keyword endpoint_type: Type of endpoint for the virtual endpoints. "ReadWrite" - :paramtype endpoint_type: str or - ~azure.mgmt.postgresqlflexibleservers.models.VirtualEndpointType - :keyword members: List of servers that one of the virtual endpoints can refer to. - :paramtype members: list[str] - """ - super().__init__(endpoint_type=endpoint_type, members=members, **kwargs) - self.id: Optional[str] = None - self.name: Optional[str] = None - self.type: Optional[str] = None - self.system_data: Optional["_models.SystemData"] = None - self.endpoint_type = endpoint_type - self.members = members - self.virtual_endpoints: Optional[list[str]] = None - - -class VirtualEndpointsList(_serialization.Model): - """List of virtual endpoints. - - :ivar value: List of virtual endpoints. - :vartype value: list[~azure.mgmt.postgresqlflexibleservers.models.VirtualEndpoint] - :ivar next_link: Link used to get the next page of results. - :vartype next_link: str - """ - - _attribute_map = { - "value": {"key": "value", "type": "[VirtualEndpoint]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, *, value: Optional[list["_models.VirtualEndpoint"]] = None, next_link: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword value: List of virtual endpoints. - :paramtype value: list[~azure.mgmt.postgresqlflexibleservers.models.VirtualEndpoint] - :keyword next_link: Link used to get the next page of results. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class VirtualNetworkSubnetUsageModel(_serialization.Model): - """Virtual network subnet usage data. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar delegated_subnets_usage: - :vartype delegated_subnets_usage: - list[~azure.mgmt.postgresqlflexibleservers.models.DelegatedSubnetUsage] - :ivar location: location of the delegated subnet usage. - :vartype location: str - :ivar subscription_id: subscriptionId of the delegated subnet usage. - :vartype subscription_id: str - """ - - _validation = { - "delegated_subnets_usage": {"readonly": True}, - "location": {"readonly": True}, - "subscription_id": {"readonly": True}, - } - - _attribute_map = { - "delegated_subnets_usage": {"key": "delegatedSubnetsUsage", "type": "[DelegatedSubnetUsage]"}, - "location": {"key": "location", "type": "str"}, - "subscription_id": {"key": "subscriptionId", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.delegated_subnets_usage: Optional[list["_models.DelegatedSubnetUsage"]] = None - self.location: Optional[str] = None - self.subscription_id: Optional[str] = None - - -class VirtualNetworkSubnetUsageParameter(_serialization.Model): - """Virtual network subnet usage parameter. - - :ivar virtual_network_arm_resource_id: Virtual network resource id. - :vartype virtual_network_arm_resource_id: str - """ - - _attribute_map = { - "virtual_network_arm_resource_id": {"key": "virtualNetworkArmResourceId", "type": "str"}, - } - - def __init__(self, *, virtual_network_arm_resource_id: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword virtual_network_arm_resource_id: Virtual network resource id. - :paramtype virtual_network_arm_resource_id: str - """ - super().__init__(**kwargs) - self.virtual_network_arm_resource_id = virtual_network_arm_resource_id diff --git a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/azure/mgmt/postgresqlflexibleservers/models/_patch.py b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/azure/mgmt/postgresqlflexibleservers/models/_patch.py index f7dd32510333..87676c65a8f0 100644 --- a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/azure/mgmt/postgresqlflexibleservers/models/_patch.py +++ b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/azure/mgmt/postgresqlflexibleservers/models/_patch.py @@ -1,14 +1,15 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------- """Customize generated code here. Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize """ -from typing import List -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +__all__: list[str] = [] # Add all objects you want publicly available to users at this package level def patch_sdk(): diff --git a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/azure/mgmt/postgresqlflexibleservers/operations/__init__.py b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/azure/mgmt/postgresqlflexibleservers/operations/__init__.py index e3f2cc110001..ec5ea57d4214 100644 --- a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/azure/mgmt/postgresqlflexibleservers/operations/__init__.py +++ b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/azure/mgmt/postgresqlflexibleservers/operations/__init__.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- # pylint: disable=wrong-import-position @@ -12,57 +12,57 @@ if TYPE_CHECKING: from ._patch import * # pylint: disable=unused-wildcard-import -from ._administrators_microsoft_entra_operations import AdministratorsMicrosoftEntraOperations # type: ignore -from ._advanced_threat_protection_settings_operations import AdvancedThreatProtectionSettingsOperations # type: ignore -from ._server_threat_protection_settings_operations import ServerThreatProtectionSettingsOperations # type: ignore -from ._backups_automatic_and_on_demand_operations import BackupsAutomaticAndOnDemandOperations # type: ignore -from ._capabilities_by_location_operations import CapabilitiesByLocationOperations # type: ignore -from ._capabilities_by_server_operations import CapabilitiesByServerOperations # type: ignore -from ._captured_logs_operations import CapturedLogsOperations # type: ignore -from ._configurations_operations import ConfigurationsOperations # type: ignore -from ._databases_operations import DatabasesOperations # type: ignore -from ._firewall_rules_operations import FirewallRulesOperations # type: ignore -from ._backups_long_term_retention_operations import BackupsLongTermRetentionOperations # type: ignore -from ._migrations_operations import MigrationsOperations # type: ignore -from ._name_availability_operations import NameAvailabilityOperations # type: ignore from ._operations import Operations # type: ignore -from ._private_dns_zone_suffix_operations import PrivateDnsZoneSuffixOperations # type: ignore -from ._private_endpoint_connections_operations import PrivateEndpointConnectionsOperations # type: ignore -from ._private_link_resources_operations import PrivateLinkResourcesOperations # type: ignore -from ._quota_usages_operations import QuotaUsagesOperations # type: ignore -from ._replicas_operations import ReplicasOperations # type: ignore -from ._servers_operations import ServersOperations # type: ignore -from ._tuning_options_operations import TuningOptionsOperations # type: ignore -from ._virtual_endpoints_operations import VirtualEndpointsOperations # type: ignore -from ._virtual_network_subnet_usage_operations import VirtualNetworkSubnetUsageOperations # type: ignore +from ._operations import MigrationsOperations # type: ignore +from ._operations import ServersOperations # type: ignore +from ._operations import ConfigurationsOperations # type: ignore +from ._operations import DatabasesOperations # type: ignore +from ._operations import FirewallRulesOperations # type: ignore +from ._operations import PrivateEndpointConnectionsOperations # type: ignore +from ._operations import PrivateLinkResourcesOperations # type: ignore +from ._operations import VirtualEndpointsOperations # type: ignore +from ._operations import AdministratorsMicrosoftEntraOperations # type: ignore +from ._operations import CapabilitiesByServerOperations # type: ignore +from ._operations import CapturedLogsOperations # type: ignore +from ._operations import BackupsLongTermRetentionOperations # type: ignore +from ._operations import ReplicasOperations # type: ignore +from ._operations import AdvancedThreatProtectionSettingsOperations # type: ignore +from ._operations import ServerThreatProtectionSettingsOperations # type: ignore +from ._operations import BackupsAutomaticAndOnDemandOperations # type: ignore +from ._operations import TuningOptionsOperations # type: ignore +from ._operations import CapabilitiesByLocationOperations # type: ignore +from ._operations import NameAvailabilityOperations # type: ignore +from ._operations import PrivateDnsZoneSuffixOperations # type: ignore +from ._operations import QuotaUsagesOperations # type: ignore +from ._operations import VirtualNetworkSubnetUsageOperations # type: ignore from ._patch import __all__ as _patch_all from ._patch import * from ._patch import patch_sdk as _patch_sdk __all__ = [ + "Operations", + "MigrationsOperations", + "ServersOperations", + "ConfigurationsOperations", + "DatabasesOperations", + "FirewallRulesOperations", + "PrivateEndpointConnectionsOperations", + "PrivateLinkResourcesOperations", + "VirtualEndpointsOperations", "AdministratorsMicrosoftEntraOperations", + "CapabilitiesByServerOperations", + "CapturedLogsOperations", + "BackupsLongTermRetentionOperations", + "ReplicasOperations", "AdvancedThreatProtectionSettingsOperations", "ServerThreatProtectionSettingsOperations", "BackupsAutomaticAndOnDemandOperations", + "TuningOptionsOperations", "CapabilitiesByLocationOperations", - "CapabilitiesByServerOperations", - "CapturedLogsOperations", - "ConfigurationsOperations", - "DatabasesOperations", - "FirewallRulesOperations", - "BackupsLongTermRetentionOperations", - "MigrationsOperations", "NameAvailabilityOperations", - "Operations", "PrivateDnsZoneSuffixOperations", - "PrivateEndpointConnectionsOperations", - "PrivateLinkResourcesOperations", "QuotaUsagesOperations", - "ReplicasOperations", - "ServersOperations", - "TuningOptionsOperations", - "VirtualEndpointsOperations", "VirtualNetworkSubnetUsageOperations", ] __all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore diff --git a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/azure/mgmt/postgresqlflexibleservers/operations/_administrators_microsoft_entra_operations.py b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/azure/mgmt/postgresqlflexibleservers/operations/_administrators_microsoft_entra_operations.py deleted file mode 100644 index d36b7b94861a..000000000000 --- a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/azure/mgmt/postgresqlflexibleservers/operations/_administrators_microsoft_entra_operations.py +++ /dev/null @@ -1,710 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from collections.abc import MutableMapping -from io import IOBase -from typing import Any, Callable, IO, Iterator, Optional, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core import PipelineClient -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest, HttpResponse -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.arm_polling import ARMPolling - -from .. import models as _models -from .._configuration import PostgreSQLManagementClientConfiguration -from .._utils.serialization import Deserializer, Serializer - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, dict[str, Any]], Any]] -List = list - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_create_or_update_request( - resource_group_name: str, server_name: str, object_id: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-08-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}/administrators/{objectId}", - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "serverName": _SERIALIZER.url( - "server_name", server_name, "str", max_length=63, min_length=3, pattern=r"^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*" - ), - "objectId": _SERIALIZER.url("object_id", object_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_delete_request( - resource_group_name: str, server_name: str, object_id: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-08-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}/administrators/{objectId}", - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "serverName": _SERIALIZER.url( - "server_name", server_name, "str", max_length=63, min_length=3, pattern=r"^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*" - ), - "objectId": _SERIALIZER.url("object_id", object_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_get_request( - resource_group_name: str, server_name: str, object_id: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-08-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}/administrators/{objectId}", - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "serverName": _SERIALIZER.url( - "server_name", server_name, "str", max_length=63, min_length=3, pattern=r"^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*" - ), - "objectId": _SERIALIZER.url("object_id", object_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_list_by_server_request( - resource_group_name: str, server_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-08-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}/administrators", - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "serverName": _SERIALIZER.url( - "server_name", server_name, "str", max_length=63, min_length=3, pattern=r"^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*" - ), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -class AdministratorsMicrosoftEntraOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.postgresqlflexibleservers.PostgreSQLManagementClient`'s - :attr:`administrators_microsoft_entra` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: PostgreSQLManagementClientConfiguration = ( - input_args.pop(0) if input_args else kwargs.pop("config") - ) - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - def _create_or_update_initial( - self, - resource_group_name: str, - server_name: str, - object_id: str, - parameters: Union[_models.AdministratorMicrosoftEntraAdd, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "AdministratorMicrosoftEntraAdd") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - server_name=server_name, - object_id=object_id, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize( - _models.ErrorResponse, - pipeline_response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - response_headers = {} - if response.status_code == 202: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - server_name: str, - object_id: str, - parameters: _models.AdministratorMicrosoftEntraAdd, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.AdministratorMicrosoftEntra]: - """Creates a new server administrator associated to a Microsoft Entra principal. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param object_id: Object identifier of the Microsoft Entra principal. Required. - :type object_id: str - :param parameters: Required parameters for adding a server administrator associated to a - Microsoft Entra principal. Required. - :type parameters: ~azure.mgmt.postgresqlflexibleservers.models.AdministratorMicrosoftEntraAdd - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either AdministratorMicrosoftEntra or the result - of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.postgresqlflexibleservers.models.AdministratorMicrosoftEntra] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - server_name: str, - object_id: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.AdministratorMicrosoftEntra]: - """Creates a new server administrator associated to a Microsoft Entra principal. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param object_id: Object identifier of the Microsoft Entra principal. Required. - :type object_id: str - :param parameters: Required parameters for adding a server administrator associated to a - Microsoft Entra principal. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either AdministratorMicrosoftEntra or the result - of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.postgresqlflexibleservers.models.AdministratorMicrosoftEntra] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_create_or_update( - self, - resource_group_name: str, - server_name: str, - object_id: str, - parameters: Union[_models.AdministratorMicrosoftEntraAdd, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.AdministratorMicrosoftEntra]: - """Creates a new server administrator associated to a Microsoft Entra principal. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param object_id: Object identifier of the Microsoft Entra principal. Required. - :type object_id: str - :param parameters: Required parameters for adding a server administrator associated to a - Microsoft Entra principal. Is either a AdministratorMicrosoftEntraAdd type or a IO[bytes] type. - Required. - :type parameters: ~azure.mgmt.postgresqlflexibleservers.models.AdministratorMicrosoftEntraAdd - or IO[bytes] - :return: An instance of LROPoller that returns either AdministratorMicrosoftEntra or the result - of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.postgresqlflexibleservers.models.AdministratorMicrosoftEntra] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.AdministratorMicrosoftEntra] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._create_or_update_initial( - resource_group_name=resource_group_name, - server_name=server_name, - object_id=object_id, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("AdministratorMicrosoftEntra", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - if polling is True: - polling_method: PollingMethod = cast( - PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) - ) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[_models.AdministratorMicrosoftEntra].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.AdministratorMicrosoftEntra]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _delete_initial( - self, resource_group_name: str, server_name: str, object_id: str, **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_delete_request( - resource_group_name=resource_group_name, - server_name=server_name, - object_id=object_id, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [202, 204]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize( - _models.ErrorResponse, - pipeline_response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - response_headers = {} - if response.status_code == 202: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def begin_delete( - self, resource_group_name: str, server_name: str, object_id: str, **kwargs: Any - ) -> LROPoller[None]: - """Deletes an existing server administrator associated to a Microsoft Entra principal. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param object_id: Object identifier of the Microsoft Entra principal. Required. - :type object_id: str - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._delete_initial( - resource_group_name=resource_group_name, - server_name=server_name, - object_id=object_id, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: PollingMethod = cast( - PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) - ) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - @distributed_trace - def get( - self, resource_group_name: str, server_name: str, object_id: str, **kwargs: Any - ) -> _models.AdministratorMicrosoftEntra: - """Gets information about a server administrator associated to a Microsoft Entra principal. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param object_id: Object identifier of the Microsoft Entra principal. Required. - :type object_id: str - :return: AdministratorMicrosoftEntra or the result of cls(response) - :rtype: ~azure.mgmt.postgresqlflexibleservers.models.AdministratorMicrosoftEntra - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.AdministratorMicrosoftEntra] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - server_name=server_name, - object_id=object_id, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize( - _models.ErrorResponse, - pipeline_response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("AdministratorMicrosoftEntra", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def list_by_server( - self, resource_group_name: str, server_name: str, **kwargs: Any - ) -> ItemPaged["_models.AdministratorMicrosoftEntra"]: - """List all server administrators associated to a Microsoft Entra principal. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :return: An iterator like instance of either AdministratorMicrosoftEntra or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.postgresqlflexibleservers.models.AdministratorMicrosoftEntra] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.AdministratorMicrosoftEntraList] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_by_server_request( - resource_group_name=resource_group_name, - server_name=server_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("AdministratorMicrosoftEntraList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize( - _models.ErrorResponse, - pipeline_response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) diff --git a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/azure/mgmt/postgresqlflexibleservers/operations/_advanced_threat_protection_settings_operations.py b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/azure/mgmt/postgresqlflexibleservers/operations/_advanced_threat_protection_settings_operations.py deleted file mode 100644 index 042cda8f8d84..000000000000 --- a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/azure/mgmt/postgresqlflexibleservers/operations/_advanced_threat_protection_settings_operations.py +++ /dev/null @@ -1,294 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from collections.abc import MutableMapping -from typing import Any, Callable, Optional, TypeVar, Union -import urllib.parse - -from azure.core import PipelineClient -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.rest import HttpRequest, HttpResponse -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from .._configuration import PostgreSQLManagementClientConfiguration -from .._utils.serialization import Deserializer, Serializer - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, dict[str, Any]], Any]] -List = list - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_by_server_request( - resource_group_name: str, server_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-08-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}/advancedThreatProtectionSettings", - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "serverName": _SERIALIZER.url( - "server_name", server_name, "str", max_length=63, min_length=3, pattern=r"^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*" - ), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_get_request( - resource_group_name: str, - server_name: str, - threat_protection_name: Union[str, _models.ThreatProtectionName], - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-08-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}/advancedThreatProtectionSettings/{threatProtectionName}", - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "serverName": _SERIALIZER.url( - "server_name", server_name, "str", max_length=63, min_length=3, pattern=r"^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*" - ), - "threatProtectionName": _SERIALIZER.url("threat_protection_name", threat_protection_name, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -class AdvancedThreatProtectionSettingsOperations: # pylint: disable=name-too-long - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.postgresqlflexibleservers.PostgreSQLManagementClient`'s - :attr:`advanced_threat_protection_settings` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: PostgreSQLManagementClientConfiguration = ( - input_args.pop(0) if input_args else kwargs.pop("config") - ) - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def list_by_server( - self, resource_group_name: str, server_name: str, **kwargs: Any - ) -> ItemPaged["_models.AdvancedThreatProtectionSettingsModel"]: - """Lists state of advanced threat protection settings for a server. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :return: An iterator like instance of either AdvancedThreatProtectionSettingsModel or the - result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.postgresqlflexibleservers.models.AdvancedThreatProtectionSettingsModel] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.AdvancedThreatProtectionSettingsList] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_by_server_request( - resource_group_name=resource_group_name, - server_name=server_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("AdvancedThreatProtectionSettingsList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize( - _models.ErrorResponse, - pipeline_response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def get( - self, - resource_group_name: str, - server_name: str, - threat_protection_name: Union[str, _models.ThreatProtectionName], - **kwargs: Any - ) -> _models.AdvancedThreatProtectionSettingsModel: - """Gets state of advanced threat protection settings for a server. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param threat_protection_name: Name of the advanced threat protection settings. "Default" - Required. - :type threat_protection_name: str or - ~azure.mgmt.postgresqlflexibleservers.models.ThreatProtectionName - :return: AdvancedThreatProtectionSettingsModel or the result of cls(response) - :rtype: ~azure.mgmt.postgresqlflexibleservers.models.AdvancedThreatProtectionSettingsModel - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.AdvancedThreatProtectionSettingsModel] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - server_name=server_name, - threat_protection_name=threat_protection_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize( - _models.ErrorResponse, - pipeline_response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("AdvancedThreatProtectionSettingsModel", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/azure/mgmt/postgresqlflexibleservers/operations/_backups_automatic_and_on_demand_operations.py b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/azure/mgmt/postgresqlflexibleservers/operations/_backups_automatic_and_on_demand_operations.py deleted file mode 100644 index d9e5a9ff60b9..000000000000 --- a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/azure/mgmt/postgresqlflexibleservers/operations/_backups_automatic_and_on_demand_operations.py +++ /dev/null @@ -1,616 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from collections.abc import MutableMapping -from typing import Any, Callable, Iterator, Optional, TypeVar, Union, cast -import urllib.parse - -from azure.core import PipelineClient -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest, HttpResponse -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.arm_polling import ARMPolling - -from .. import models as _models -from .._configuration import PostgreSQLManagementClientConfiguration -from .._utils.serialization import Deserializer, Serializer - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, dict[str, Any]], Any]] -List = list - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_create_request( - resource_group_name: str, server_name: str, backup_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-08-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}/backups/{backupName}", - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "serverName": _SERIALIZER.url( - "server_name", server_name, "str", max_length=63, min_length=3, pattern=r"^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*" - ), - "backupName": _SERIALIZER.url( - "backup_name", backup_name, "str", max_length=128, min_length=1, pattern=r"^[-\w\._]+$" - ), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_delete_request( - resource_group_name: str, server_name: str, backup_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-08-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}/backups/{backupName}", - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "serverName": _SERIALIZER.url( - "server_name", server_name, "str", max_length=63, min_length=3, pattern=r"^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*" - ), - "backupName": _SERIALIZER.url( - "backup_name", backup_name, "str", max_length=128, min_length=1, pattern=r"^[-\w\._]+$" - ), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_get_request( - resource_group_name: str, server_name: str, backup_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-08-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}/backups/{backupName}", - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "serverName": _SERIALIZER.url( - "server_name", server_name, "str", max_length=63, min_length=3, pattern=r"^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*" - ), - "backupName": _SERIALIZER.url( - "backup_name", backup_name, "str", max_length=128, min_length=1, pattern=r"^[-\w\._]+$" - ), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_list_by_server_request( - resource_group_name: str, server_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-08-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}/backups", - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "serverName": _SERIALIZER.url( - "server_name", server_name, "str", max_length=63, min_length=3, pattern=r"^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*" - ), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -class BackupsAutomaticAndOnDemandOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.postgresqlflexibleservers.PostgreSQLManagementClient`'s - :attr:`backups_automatic_and_on_demand` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: PostgreSQLManagementClientConfiguration = ( - input_args.pop(0) if input_args else kwargs.pop("config") - ) - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - def _create_initial( - self, resource_group_name: str, server_name: str, backup_name: str, **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_create_request( - resource_group_name=resource_group_name, - server_name=server_name, - backup_name=backup_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize( - _models.ErrorResponse, - pipeline_response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - response_headers = {} - if response.status_code == 202: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def begin_create( - self, resource_group_name: str, server_name: str, backup_name: str, **kwargs: Any - ) -> LROPoller[_models.BackupAutomaticAndOnDemand]: - """Creates an on demand backup of a server. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param backup_name: Name of the backup. Required. - :type backup_name: str - :return: An instance of LROPoller that returns either BackupAutomaticAndOnDemand or the result - of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.postgresqlflexibleservers.models.BackupAutomaticAndOnDemand] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.BackupAutomaticAndOnDemand] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._create_initial( - resource_group_name=resource_group_name, - server_name=server_name, - backup_name=backup_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("BackupAutomaticAndOnDemand", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - if polling is True: - polling_method: PollingMethod = cast( - PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) - ) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[_models.BackupAutomaticAndOnDemand].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.BackupAutomaticAndOnDemand]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _delete_initial( - self, resource_group_name: str, server_name: str, backup_name: str, **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_delete_request( - resource_group_name=resource_group_name, - server_name=server_name, - backup_name=backup_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [202, 204]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize( - _models.ErrorResponse, - pipeline_response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - response_headers = {} - if response.status_code == 202: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def begin_delete( - self, resource_group_name: str, server_name: str, backup_name: str, **kwargs: Any - ) -> LROPoller[None]: - """Deletes a specific backup, given its name. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param backup_name: Name of the backup. Required. - :type backup_name: str - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._delete_initial( - resource_group_name=resource_group_name, - server_name=server_name, - backup_name=backup_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: PollingMethod = cast( - PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) - ) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - @distributed_trace - def get( - self, resource_group_name: str, server_name: str, backup_name: str, **kwargs: Any - ) -> _models.BackupAutomaticAndOnDemand: - """Gets information of an on demand backup, given its name. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param backup_name: Name of the backup. Required. - :type backup_name: str - :return: BackupAutomaticAndOnDemand or the result of cls(response) - :rtype: ~azure.mgmt.postgresqlflexibleservers.models.BackupAutomaticAndOnDemand - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.BackupAutomaticAndOnDemand] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - server_name=server_name, - backup_name=backup_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize( - _models.ErrorResponse, - pipeline_response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("BackupAutomaticAndOnDemand", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def list_by_server( - self, resource_group_name: str, server_name: str, **kwargs: Any - ) -> ItemPaged["_models.BackupAutomaticAndOnDemand"]: - """Lists all available backups of a server. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :return: An iterator like instance of either BackupAutomaticAndOnDemand or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.postgresqlflexibleservers.models.BackupAutomaticAndOnDemand] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.BackupAutomaticAndOnDemandList] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_by_server_request( - resource_group_name=resource_group_name, - server_name=server_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("BackupAutomaticAndOnDemandList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize( - _models.ErrorResponse, - pipeline_response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) diff --git a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/azure/mgmt/postgresqlflexibleservers/operations/_backups_long_term_retention_operations.py b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/azure/mgmt/postgresqlflexibleservers/operations/_backups_long_term_retention_operations.py deleted file mode 100644 index 2c8134f6c087..000000000000 --- a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/azure/mgmt/postgresqlflexibleservers/operations/_backups_long_term_retention_operations.py +++ /dev/null @@ -1,718 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from collections.abc import MutableMapping -from io import IOBase -from typing import Any, Callable, IO, Iterator, Optional, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core import PipelineClient -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest, HttpResponse -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.arm_polling import ARMPolling - -from .. import models as _models -from .._configuration import PostgreSQLManagementClientConfiguration -from .._utils.serialization import Deserializer, Serializer - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, dict[str, Any]], Any]] -List = list - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_check_prerequisites_request( - resource_group_name: str, server_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-08-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}/ltrPreBackup", - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "serverName": _SERIALIZER.url( - "server_name", server_name, "str", max_length=63, min_length=3, pattern=r"^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*" - ), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_start_request(resource_group_name: str, server_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-08-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}/startLtrBackup", - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "serverName": _SERIALIZER.url( - "server_name", server_name, "str", max_length=63, min_length=3, pattern=r"^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*" - ), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_get_request( - resource_group_name: str, server_name: str, backup_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-08-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}/ltrBackupOperations/{backupName}", - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "serverName": _SERIALIZER.url( - "server_name", server_name, "str", max_length=63, min_length=3, pattern=r"^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*" - ), - "backupName": _SERIALIZER.url("backup_name", backup_name, "str", pattern=r"^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_list_by_server_request( - resource_group_name: str, server_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-08-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}/ltrBackupOperations", - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "serverName": _SERIALIZER.url( - "server_name", server_name, "str", max_length=63, min_length=3, pattern=r"^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*" - ), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -class BackupsLongTermRetentionOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.postgresqlflexibleservers.PostgreSQLManagementClient`'s - :attr:`backups_long_term_retention` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: PostgreSQLManagementClientConfiguration = ( - input_args.pop(0) if input_args else kwargs.pop("config") - ) - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @overload - def check_prerequisites( - self, - resource_group_name: str, - server_name: str, - parameters: _models.LtrPreBackupRequest, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.LtrPreBackupResponse: - """Performs all checks required for a long term retention backup operation to succeed. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param parameters: Request body for operation. Required. - :type parameters: ~azure.mgmt.postgresqlflexibleservers.models.LtrPreBackupRequest - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: LtrPreBackupResponse or the result of cls(response) - :rtype: ~azure.mgmt.postgresqlflexibleservers.models.LtrPreBackupResponse - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def check_prerequisites( - self, - resource_group_name: str, - server_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.LtrPreBackupResponse: - """Performs all checks required for a long term retention backup operation to succeed. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param parameters: Request body for operation. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: LtrPreBackupResponse or the result of cls(response) - :rtype: ~azure.mgmt.postgresqlflexibleservers.models.LtrPreBackupResponse - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def check_prerequisites( - self, - resource_group_name: str, - server_name: str, - parameters: Union[_models.LtrPreBackupRequest, IO[bytes]], - **kwargs: Any - ) -> _models.LtrPreBackupResponse: - """Performs all checks required for a long term retention backup operation to succeed. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param parameters: Request body for operation. Is either a LtrPreBackupRequest type or a - IO[bytes] type. Required. - :type parameters: ~azure.mgmt.postgresqlflexibleservers.models.LtrPreBackupRequest or IO[bytes] - :return: LtrPreBackupResponse or the result of cls(response) - :rtype: ~azure.mgmt.postgresqlflexibleservers.models.LtrPreBackupResponse - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.LtrPreBackupResponse] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "LtrPreBackupRequest") - - _request = build_check_prerequisites_request( - resource_group_name=resource_group_name, - server_name=server_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize( - _models.ErrorResponse, - pipeline_response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - response_headers = {} - response_headers["x-ms-request-id"] = self._deserialize("str", response.headers.get("x-ms-request-id")) - - deserialized = self._deserialize("LtrPreBackupResponse", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - def _start_initial( - self, - resource_group_name: str, - server_name: str, - parameters: Union[_models.BackupsLongTermRetentionRequest, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "BackupsLongTermRetentionRequest") - - _request = build_start_request( - resource_group_name=resource_group_name, - server_name=server_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize( - _models.ErrorResponse, - pipeline_response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - response_headers = {} - if response.status_code == 200: - response_headers["x-ms-request-id"] = self._deserialize("str", response.headers.get("x-ms-request-id")) - - if response.status_code == 202: - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - response_headers["x-ms-request-id"] = self._deserialize("str", response.headers.get("x-ms-request-id")) - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_start( - self, - resource_group_name: str, - server_name: str, - parameters: _models.BackupsLongTermRetentionRequest, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.BackupsLongTermRetentionResponse]: - """Initiates a long term retention backup. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param parameters: Request body for operation. Required. - :type parameters: ~azure.mgmt.postgresqlflexibleservers.models.BackupsLongTermRetentionRequest - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either BackupsLongTermRetentionResponse or the - result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.postgresqlflexibleservers.models.BackupsLongTermRetentionResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_start( - self, - resource_group_name: str, - server_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.BackupsLongTermRetentionResponse]: - """Initiates a long term retention backup. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param parameters: Request body for operation. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either BackupsLongTermRetentionResponse or the - result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.postgresqlflexibleservers.models.BackupsLongTermRetentionResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_start( - self, - resource_group_name: str, - server_name: str, - parameters: Union[_models.BackupsLongTermRetentionRequest, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.BackupsLongTermRetentionResponse]: - """Initiates a long term retention backup. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param parameters: Request body for operation. Is either a BackupsLongTermRetentionRequest type - or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.postgresqlflexibleservers.models.BackupsLongTermRetentionRequest - or IO[bytes] - :return: An instance of LROPoller that returns either BackupsLongTermRetentionResponse or the - result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.postgresqlflexibleservers.models.BackupsLongTermRetentionResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.BackupsLongTermRetentionResponse] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._start_initial( - resource_group_name=resource_group_name, - server_name=server_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - response_headers = {} - response = pipeline_response.http_response - response_headers["x-ms-request-id"] = self._deserialize("str", response.headers.get("x-ms-request-id")) - - deserialized = self._deserialize("BackupsLongTermRetentionResponse", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - return deserialized - - if polling is True: - polling_method: PollingMethod = cast( - PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) - ) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[_models.BackupsLongTermRetentionResponse].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.BackupsLongTermRetentionResponse]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - @distributed_trace - def get( - self, resource_group_name: str, server_name: str, backup_name: str, **kwargs: Any - ) -> _models.BackupsLongTermRetentionOperation: - """Gets the results of a long retention backup operation for a server. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param backup_name: The name of the backup. Required. - :type backup_name: str - :return: BackupsLongTermRetentionOperation or the result of cls(response) - :rtype: ~azure.mgmt.postgresqlflexibleservers.models.BackupsLongTermRetentionOperation - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.BackupsLongTermRetentionOperation] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - server_name=server_name, - backup_name=backup_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize( - _models.ErrorResponse, - pipeline_response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("BackupsLongTermRetentionOperation", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def list_by_server( - self, resource_group_name: str, server_name: str, **kwargs: Any - ) -> ItemPaged["_models.BackupsLongTermRetentionOperation"]: - """Lists the results of the long term retention backup operations for a server. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :return: An iterator like instance of either BackupsLongTermRetentionOperation or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.postgresqlflexibleservers.models.BackupsLongTermRetentionOperation] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.LtrServerBackupOperationList] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_by_server_request( - resource_group_name=resource_group_name, - server_name=server_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("LtrServerBackupOperationList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize( - _models.ErrorResponse, - pipeline_response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) diff --git a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/azure/mgmt/postgresqlflexibleservers/operations/_capabilities_by_location_operations.py b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/azure/mgmt/postgresqlflexibleservers/operations/_capabilities_by_location_operations.py deleted file mode 100644 index bafa1f4b187e..000000000000 --- a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/azure/mgmt/postgresqlflexibleservers/operations/_capabilities_by_location_operations.py +++ /dev/null @@ -1,168 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from collections.abc import MutableMapping -from typing import Any, Callable, Optional, TypeVar -import urllib.parse - -from azure.core import PipelineClient -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.rest import HttpRequest, HttpResponse -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from .._configuration import PostgreSQLManagementClientConfiguration -from .._utils.serialization import Deserializer, Serializer - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, dict[str, Any]], Any]] -List = list - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_request(location_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-08-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.DBforPostgreSQL/locations/{locationName}/capabilities", - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "locationName": _SERIALIZER.url("location_name", location_name, "str", min_length=1, pattern=r"^[-\w\._]+$"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -class CapabilitiesByLocationOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.postgresqlflexibleservers.PostgreSQLManagementClient`'s - :attr:`capabilities_by_location` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: PostgreSQLManagementClientConfiguration = ( - input_args.pop(0) if input_args else kwargs.pop("config") - ) - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def list(self, location_name: str, **kwargs: Any) -> ItemPaged["_models.Capability"]: - """Lists the capabilities available in a given location for a specific subscription. - - :param location_name: The name of the location. Required. - :type location_name: str - :return: An iterator like instance of either Capability or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.postgresqlflexibleservers.models.Capability] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.CapabilityList] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_request( - location_name=location_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("CapabilityList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize( - _models.ErrorResponse, - pipeline_response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) diff --git a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/azure/mgmt/postgresqlflexibleservers/operations/_capabilities_by_server_operations.py b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/azure/mgmt/postgresqlflexibleservers/operations/_capabilities_by_server_operations.py deleted file mode 100644 index 8994ff217aec..000000000000 --- a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/azure/mgmt/postgresqlflexibleservers/operations/_capabilities_by_server_operations.py +++ /dev/null @@ -1,178 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from collections.abc import MutableMapping -from typing import Any, Callable, Optional, TypeVar -import urllib.parse - -from azure.core import PipelineClient -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.rest import HttpRequest, HttpResponse -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from .._configuration import PostgreSQLManagementClientConfiguration -from .._utils.serialization import Deserializer, Serializer - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, dict[str, Any]], Any]] -List = list - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_request(resource_group_name: str, server_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-08-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}/capabilities", - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "serverName": _SERIALIZER.url( - "server_name", server_name, "str", max_length=63, min_length=3, pattern=r"^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*" - ), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -class CapabilitiesByServerOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.postgresqlflexibleservers.PostgreSQLManagementClient`'s - :attr:`capabilities_by_server` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: PostgreSQLManagementClientConfiguration = ( - input_args.pop(0) if input_args else kwargs.pop("config") - ) - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def list(self, resource_group_name: str, server_name: str, **kwargs: Any) -> ItemPaged["_models.Capability"]: - """Lists the capabilities available for a given server. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :return: An iterator like instance of either Capability or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.postgresqlflexibleservers.models.Capability] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.CapabilityList] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_request( - resource_group_name=resource_group_name, - server_name=server_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("CapabilityList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize( - _models.ErrorResponse, - pipeline_response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) diff --git a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/azure/mgmt/postgresqlflexibleservers/operations/_captured_logs_operations.py b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/azure/mgmt/postgresqlflexibleservers/operations/_captured_logs_operations.py deleted file mode 100644 index b40474dc332f..000000000000 --- a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/azure/mgmt/postgresqlflexibleservers/operations/_captured_logs_operations.py +++ /dev/null @@ -1,182 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from collections.abc import MutableMapping -from typing import Any, Callable, Optional, TypeVar -import urllib.parse - -from azure.core import PipelineClient -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.rest import HttpRequest, HttpResponse -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from .._configuration import PostgreSQLManagementClientConfiguration -from .._utils.serialization import Deserializer, Serializer - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, dict[str, Any]], Any]] -List = list - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_by_server_request( - resource_group_name: str, server_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-08-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}/logFiles", - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "serverName": _SERIALIZER.url( - "server_name", server_name, "str", max_length=63, min_length=3, pattern=r"^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*" - ), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -class CapturedLogsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.postgresqlflexibleservers.PostgreSQLManagementClient`'s - :attr:`captured_logs` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: PostgreSQLManagementClientConfiguration = ( - input_args.pop(0) if input_args else kwargs.pop("config") - ) - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def list_by_server( - self, resource_group_name: str, server_name: str, **kwargs: Any - ) -> ItemPaged["_models.CapturedLog"]: - """Lists all captured logs for download in a server. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :return: An iterator like instance of either CapturedLog or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.postgresqlflexibleservers.models.CapturedLog] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.CapturedLogList] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_by_server_request( - resource_group_name=resource_group_name, - server_name=server_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("CapturedLogList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize( - _models.ErrorResponse, - pipeline_response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) diff --git a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/azure/mgmt/postgresqlflexibleservers/operations/_configurations_operations.py b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/azure/mgmt/postgresqlflexibleservers/operations/_configurations_operations.py deleted file mode 100644 index 7e6f15fbb6ba..000000000000 --- a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/azure/mgmt/postgresqlflexibleservers/operations/_configurations_operations.py +++ /dev/null @@ -1,833 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from collections.abc import MutableMapping -from io import IOBase -from typing import Any, Callable, IO, Iterator, Optional, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core import PipelineClient -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest, HttpResponse -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.arm_polling import ARMPolling - -from .. import models as _models -from .._configuration import PostgreSQLManagementClientConfiguration -from .._utils.serialization import Deserializer, Serializer - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, dict[str, Any]], Any]] -List = list - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_by_server_request( - resource_group_name: str, server_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-08-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}/configurations", - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "serverName": _SERIALIZER.url( - "server_name", server_name, "str", max_length=63, min_length=3, pattern=r"^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*" - ), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_get_request( - resource_group_name: str, server_name: str, configuration_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-08-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}/configurations/{configurationName}", - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "serverName": _SERIALIZER.url( - "server_name", server_name, "str", max_length=63, min_length=3, pattern=r"^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*" - ), - "configurationName": _SERIALIZER.url( - "configuration_name", configuration_name, "str", max_length=256, min_length=1, pattern=r"^[-\w\._]+$" - ), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_update_request( - resource_group_name: str, server_name: str, configuration_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-08-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}/configurations/{configurationName}", - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "serverName": _SERIALIZER.url( - "server_name", server_name, "str", max_length=63, min_length=3, pattern=r"^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*" - ), - "configurationName": _SERIALIZER.url( - "configuration_name", configuration_name, "str", max_length=256, min_length=1, pattern=r"^[-\w\._]+$" - ), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_put_request( - resource_group_name: str, server_name: str, configuration_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-08-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}/configurations/{configurationName}", - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "serverName": _SERIALIZER.url( - "server_name", server_name, "str", max_length=63, min_length=3, pattern=r"^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*" - ), - "configurationName": _SERIALIZER.url( - "configuration_name", configuration_name, "str", max_length=256, min_length=1, pattern=r"^[-\w\._]+$" - ), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -class ConfigurationsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.postgresqlflexibleservers.PostgreSQLManagementClient`'s - :attr:`configurations` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: PostgreSQLManagementClientConfiguration = ( - input_args.pop(0) if input_args else kwargs.pop("config") - ) - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def list_by_server( - self, resource_group_name: str, server_name: str, **kwargs: Any - ) -> ItemPaged["_models.Configuration"]: - """Lists all configurations (also known as server parameters) of a server. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :return: An iterator like instance of either Configuration or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.postgresqlflexibleservers.models.Configuration] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.ConfigurationList] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_by_server_request( - resource_group_name=resource_group_name, - server_name=server_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("ConfigurationList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize( - _models.ErrorResponse, - pipeline_response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def get( - self, resource_group_name: str, server_name: str, configuration_name: str, **kwargs: Any - ) -> _models.Configuration: - """Gets information about a specific configuration (also known as server parameter) of a server. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param configuration_name: Name of the configuration (also known as server parameter). - Required. - :type configuration_name: str - :return: Configuration or the result of cls(response) - :rtype: ~azure.mgmt.postgresqlflexibleservers.models.Configuration - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.Configuration] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - server_name=server_name, - configuration_name=configuration_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize( - _models.ErrorResponse, - pipeline_response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("Configuration", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - def _update_initial( - self, - resource_group_name: str, - server_name: str, - configuration_name: str, - parameters: Union[_models.ConfigurationForUpdate, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "ConfigurationForUpdate") - - _request = build_update_request( - resource_group_name=resource_group_name, - server_name=server_name, - configuration_name=configuration_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize( - _models.ErrorResponse, - pipeline_response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - response_headers = {} - if response.status_code == 202: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_update( - self, - resource_group_name: str, - server_name: str, - configuration_name: str, - parameters: _models.ConfigurationForUpdate, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.Configuration]: - """Updates the value assigned to a specific modifiable configuration (also known as server - parameter) of a server. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param configuration_name: Name of the configuration (also known as server parameter). - Required. - :type configuration_name: str - :param parameters: Parameters required to update the value of a specific modifiable - configuration (also known as server parameter). Required. - :type parameters: ~azure.mgmt.postgresqlflexibleservers.models.ConfigurationForUpdate - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either Configuration or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.postgresqlflexibleservers.models.Configuration] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_update( - self, - resource_group_name: str, - server_name: str, - configuration_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.Configuration]: - """Updates the value assigned to a specific modifiable configuration (also known as server - parameter) of a server. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param configuration_name: Name of the configuration (also known as server parameter). - Required. - :type configuration_name: str - :param parameters: Parameters required to update the value of a specific modifiable - configuration (also known as server parameter). Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either Configuration or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.postgresqlflexibleservers.models.Configuration] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_update( - self, - resource_group_name: str, - server_name: str, - configuration_name: str, - parameters: Union[_models.ConfigurationForUpdate, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.Configuration]: - """Updates the value assigned to a specific modifiable configuration (also known as server - parameter) of a server. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param configuration_name: Name of the configuration (also known as server parameter). - Required. - :type configuration_name: str - :param parameters: Parameters required to update the value of a specific modifiable - configuration (also known as server parameter). Is either a ConfigurationForUpdate type or a - IO[bytes] type. Required. - :type parameters: ~azure.mgmt.postgresqlflexibleservers.models.ConfigurationForUpdate or - IO[bytes] - :return: An instance of LROPoller that returns either Configuration or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.postgresqlflexibleservers.models.Configuration] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.Configuration] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._update_initial( - resource_group_name=resource_group_name, - server_name=server_name, - configuration_name=configuration_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Configuration", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - if polling is True: - polling_method: PollingMethod = cast( - PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) - ) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[_models.Configuration].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.Configuration]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _put_initial( - self, - resource_group_name: str, - server_name: str, - configuration_name: str, - parameters: Union[_models.ConfigurationForUpdate, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "ConfigurationForUpdate") - - _request = build_put_request( - resource_group_name=resource_group_name, - server_name=server_name, - configuration_name=configuration_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize( - _models.ErrorResponse, - pipeline_response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - response_headers = {} - if response.status_code == 202: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_put( - self, - resource_group_name: str, - server_name: str, - configuration_name: str, - parameters: _models.ConfigurationForUpdate, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.Configuration]: - """Updates, using Put verb, the value assigned to a specific modifiable configuration (also known - as server parameter) of a server. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param configuration_name: Name of the configuration (also known as server parameter). - Required. - :type configuration_name: str - :param parameters: Parameters required to update the value of a specific modifiable - configuration (also known as server parameter). Required. - :type parameters: ~azure.mgmt.postgresqlflexibleservers.models.ConfigurationForUpdate - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either Configuration or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.postgresqlflexibleservers.models.Configuration] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_put( - self, - resource_group_name: str, - server_name: str, - configuration_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.Configuration]: - """Updates, using Put verb, the value assigned to a specific modifiable configuration (also known - as server parameter) of a server. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param configuration_name: Name of the configuration (also known as server parameter). - Required. - :type configuration_name: str - :param parameters: Parameters required to update the value of a specific modifiable - configuration (also known as server parameter). Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either Configuration or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.postgresqlflexibleservers.models.Configuration] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_put( - self, - resource_group_name: str, - server_name: str, - configuration_name: str, - parameters: Union[_models.ConfigurationForUpdate, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.Configuration]: - """Updates, using Put verb, the value assigned to a specific modifiable configuration (also known - as server parameter) of a server. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param configuration_name: Name of the configuration (also known as server parameter). - Required. - :type configuration_name: str - :param parameters: Parameters required to update the value of a specific modifiable - configuration (also known as server parameter). Is either a ConfigurationForUpdate type or a - IO[bytes] type. Required. - :type parameters: ~azure.mgmt.postgresqlflexibleservers.models.ConfigurationForUpdate or - IO[bytes] - :return: An instance of LROPoller that returns either Configuration or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.postgresqlflexibleservers.models.Configuration] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.Configuration] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._put_initial( - resource_group_name=resource_group_name, - server_name=server_name, - configuration_name=configuration_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Configuration", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - if polling is True: - polling_method: PollingMethod = cast( - PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) - ) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[_models.Configuration].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.Configuration]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) diff --git a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/azure/mgmt/postgresqlflexibleservers/operations/_databases_operations.py b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/azure/mgmt/postgresqlflexibleservers/operations/_databases_operations.py deleted file mode 100644 index 2cf55f8e35c3..000000000000 --- a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/azure/mgmt/postgresqlflexibleservers/operations/_databases_operations.py +++ /dev/null @@ -1,707 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from collections.abc import MutableMapping -from io import IOBase -from typing import Any, Callable, IO, Iterator, Optional, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core import PipelineClient -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest, HttpResponse -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.arm_polling import ARMPolling - -from .. import models as _models -from .._configuration import PostgreSQLManagementClientConfiguration -from .._utils.serialization import Deserializer, Serializer - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, dict[str, Any]], Any]] -List = list - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_create_request( - resource_group_name: str, server_name: str, database_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-08-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}/databases/{databaseName}", - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "serverName": _SERIALIZER.url( - "server_name", server_name, "str", max_length=63, min_length=3, pattern=r"^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*" - ), - "databaseName": _SERIALIZER.url( - "database_name", database_name, "str", max_length=63, min_length=1, pattern=r"^[a-zA-Z_][\w\-]{0,62}$" - ), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_delete_request( - resource_group_name: str, server_name: str, database_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-08-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}/databases/{databaseName}", - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "serverName": _SERIALIZER.url( - "server_name", server_name, "str", max_length=63, min_length=3, pattern=r"^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*" - ), - "databaseName": _SERIALIZER.url( - "database_name", database_name, "str", max_length=63, min_length=1, pattern=r"^[a-zA-Z_][\w\-]{0,62}$" - ), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_get_request( - resource_group_name: str, server_name: str, database_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-08-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}/databases/{databaseName}", - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "serverName": _SERIALIZER.url( - "server_name", server_name, "str", max_length=63, min_length=3, pattern=r"^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*" - ), - "databaseName": _SERIALIZER.url( - "database_name", database_name, "str", max_length=63, min_length=1, pattern=r"^[a-zA-Z_][\w\-]{0,62}$" - ), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_list_by_server_request( - resource_group_name: str, server_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-08-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}/databases", - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "serverName": _SERIALIZER.url( - "server_name", server_name, "str", max_length=63, min_length=3, pattern=r"^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*" - ), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -class DatabasesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.postgresqlflexibleservers.PostgreSQLManagementClient`'s - :attr:`databases` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: PostgreSQLManagementClientConfiguration = ( - input_args.pop(0) if input_args else kwargs.pop("config") - ) - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - def _create_initial( - self, - resource_group_name: str, - server_name: str, - database_name: str, - parameters: Union[_models.Database, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "Database") - - _request = build_create_request( - resource_group_name=resource_group_name, - server_name=server_name, - database_name=database_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize( - _models.ErrorResponse, - pipeline_response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - response_headers = {} - if response.status_code == 202: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_create( - self, - resource_group_name: str, - server_name: str, - database_name: str, - parameters: _models.Database, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.Database]: - """Creates a new database. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param database_name: Name of the database (case-sensitive). Exact database names can be - retrieved by getting the list of all existing databases in a server. Required. - :type database_name: str - :param parameters: Parameters required to create a new database. Required. - :type parameters: ~azure.mgmt.postgresqlflexibleservers.models.Database - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either Database or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.postgresqlflexibleservers.models.Database] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_create( - self, - resource_group_name: str, - server_name: str, - database_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.Database]: - """Creates a new database. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param database_name: Name of the database (case-sensitive). Exact database names can be - retrieved by getting the list of all existing databases in a server. Required. - :type database_name: str - :param parameters: Parameters required to create a new database. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either Database or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.postgresqlflexibleservers.models.Database] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_create( - self, - resource_group_name: str, - server_name: str, - database_name: str, - parameters: Union[_models.Database, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.Database]: - """Creates a new database. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param database_name: Name of the database (case-sensitive). Exact database names can be - retrieved by getting the list of all existing databases in a server. Required. - :type database_name: str - :param parameters: Parameters required to create a new database. Is either a Database type or a - IO[bytes] type. Required. - :type parameters: ~azure.mgmt.postgresqlflexibleservers.models.Database or IO[bytes] - :return: An instance of LROPoller that returns either Database or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.postgresqlflexibleservers.models.Database] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.Database] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._create_initial( - resource_group_name=resource_group_name, - server_name=server_name, - database_name=database_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Database", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - if polling is True: - polling_method: PollingMethod = cast( - PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) - ) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[_models.Database].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.Database]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _delete_initial( - self, resource_group_name: str, server_name: str, database_name: str, **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_delete_request( - resource_group_name=resource_group_name, - server_name=server_name, - database_name=database_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [202, 204]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize( - _models.ErrorResponse, - pipeline_response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - response_headers = {} - if response.status_code == 202: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def begin_delete( - self, resource_group_name: str, server_name: str, database_name: str, **kwargs: Any - ) -> LROPoller[None]: - """Deletes an existing database. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param database_name: Name of the database (case-sensitive). Exact database names can be - retrieved by getting the list of all existing databases in a server. Required. - :type database_name: str - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._delete_initial( - resource_group_name=resource_group_name, - server_name=server_name, - database_name=database_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: PollingMethod = cast( - PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) - ) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - @distributed_trace - def get(self, resource_group_name: str, server_name: str, database_name: str, **kwargs: Any) -> _models.Database: - """Gets information about an existing database. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param database_name: Name of the database (case-sensitive). Exact database names can be - retrieved by getting the list of all existing databases in a server. Required. - :type database_name: str - :return: Database or the result of cls(response) - :rtype: ~azure.mgmt.postgresqlflexibleservers.models.Database - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.Database] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - server_name=server_name, - database_name=database_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize( - _models.ErrorResponse, - pipeline_response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("Database", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def list_by_server( - self, resource_group_name: str, server_name: str, **kwargs: Any - ) -> ItemPaged["_models.Database"]: - """Lists all databases in a server. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :return: An iterator like instance of either Database or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.postgresqlflexibleservers.models.Database] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.DatabaseList] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_by_server_request( - resource_group_name=resource_group_name, - server_name=server_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("DatabaseList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize( - _models.ErrorResponse, - pipeline_response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) diff --git a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/azure/mgmt/postgresqlflexibleservers/operations/_firewall_rules_operations.py b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/azure/mgmt/postgresqlflexibleservers/operations/_firewall_rules_operations.py deleted file mode 100644 index 6b5bc7e6c509..000000000000 --- a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/azure/mgmt/postgresqlflexibleservers/operations/_firewall_rules_operations.py +++ /dev/null @@ -1,725 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from collections.abc import MutableMapping -from io import IOBase -from typing import Any, Callable, IO, Iterator, Optional, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core import PipelineClient -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest, HttpResponse -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.arm_polling import ARMPolling - -from .. import models as _models -from .._configuration import PostgreSQLManagementClientConfiguration -from .._utils.serialization import Deserializer, Serializer - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, dict[str, Any]], Any]] -List = list - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_create_or_update_request( - resource_group_name: str, server_name: str, firewall_rule_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-08-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}/firewallRules/{firewallRuleName}", - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "serverName": _SERIALIZER.url( - "server_name", server_name, "str", max_length=63, min_length=3, pattern=r"^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*" - ), - "firewallRuleName": _SERIALIZER.url( - "firewall_rule_name", - firewall_rule_name, - "str", - max_length=80, - min_length=1, - pattern=r"^[a-zA-Z0-9][-_a-zA-Z0-9]{0,79}(? HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-08-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}/firewallRules/{firewallRuleName}", - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "serverName": _SERIALIZER.url( - "server_name", server_name, "str", max_length=63, min_length=3, pattern=r"^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*" - ), - "firewallRuleName": _SERIALIZER.url( - "firewall_rule_name", - firewall_rule_name, - "str", - max_length=80, - min_length=1, - pattern=r"^[a-zA-Z0-9][-_a-zA-Z0-9]{0,79}(? HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-08-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}/firewallRules/{firewallRuleName}", - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "serverName": _SERIALIZER.url( - "server_name", server_name, "str", max_length=63, min_length=3, pattern=r"^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*" - ), - "firewallRuleName": _SERIALIZER.url( - "firewall_rule_name", - firewall_rule_name, - "str", - max_length=80, - min_length=1, - pattern=r"^[a-zA-Z0-9][-_a-zA-Z0-9]{0,79}(? HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-08-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}/firewallRules", - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "serverName": _SERIALIZER.url( - "server_name", server_name, "str", max_length=63, min_length=3, pattern=r"^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*" - ), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -class FirewallRulesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.postgresqlflexibleservers.PostgreSQLManagementClient`'s - :attr:`firewall_rules` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: PostgreSQLManagementClientConfiguration = ( - input_args.pop(0) if input_args else kwargs.pop("config") - ) - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - def _create_or_update_initial( - self, - resource_group_name: str, - server_name: str, - firewall_rule_name: str, - parameters: Union[_models.FirewallRule, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "FirewallRule") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - server_name=server_name, - firewall_rule_name=firewall_rule_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize( - _models.ErrorResponse, - pipeline_response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - response_headers = {} - if response.status_code == 202: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - server_name: str, - firewall_rule_name: str, - parameters: _models.FirewallRule, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.FirewallRule]: - """Creates a new firewall rule or updates an existing firewall rule. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param firewall_rule_name: Name of the firewall rule. Required. - :type firewall_rule_name: str - :param parameters: Parameters required for creating or updating a firewall rule. Required. - :type parameters: ~azure.mgmt.postgresqlflexibleservers.models.FirewallRule - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either FirewallRule or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.postgresqlflexibleservers.models.FirewallRule] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - server_name: str, - firewall_rule_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.FirewallRule]: - """Creates a new firewall rule or updates an existing firewall rule. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param firewall_rule_name: Name of the firewall rule. Required. - :type firewall_rule_name: str - :param parameters: Parameters required for creating or updating a firewall rule. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either FirewallRule or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.postgresqlflexibleservers.models.FirewallRule] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_create_or_update( - self, - resource_group_name: str, - server_name: str, - firewall_rule_name: str, - parameters: Union[_models.FirewallRule, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.FirewallRule]: - """Creates a new firewall rule or updates an existing firewall rule. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param firewall_rule_name: Name of the firewall rule. Required. - :type firewall_rule_name: str - :param parameters: Parameters required for creating or updating a firewall rule. Is either a - FirewallRule type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.postgresqlflexibleservers.models.FirewallRule or IO[bytes] - :return: An instance of LROPoller that returns either FirewallRule or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.postgresqlflexibleservers.models.FirewallRule] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.FirewallRule] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._create_or_update_initial( - resource_group_name=resource_group_name, - server_name=server_name, - firewall_rule_name=firewall_rule_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("FirewallRule", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - if polling is True: - polling_method: PollingMethod = cast( - PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) - ) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[_models.FirewallRule].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.FirewallRule]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _delete_initial( - self, resource_group_name: str, server_name: str, firewall_rule_name: str, **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_delete_request( - resource_group_name=resource_group_name, - server_name=server_name, - firewall_rule_name=firewall_rule_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [202, 204]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize( - _models.ErrorResponse, - pipeline_response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - response_headers = {} - if response.status_code == 202: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def begin_delete( - self, resource_group_name: str, server_name: str, firewall_rule_name: str, **kwargs: Any - ) -> LROPoller[None]: - """Deletes an existing firewall rule. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param firewall_rule_name: Name of the firewall rule. Required. - :type firewall_rule_name: str - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._delete_initial( - resource_group_name=resource_group_name, - server_name=server_name, - firewall_rule_name=firewall_rule_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: PollingMethod = cast( - PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) - ) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - @distributed_trace - def get( - self, resource_group_name: str, server_name: str, firewall_rule_name: str, **kwargs: Any - ) -> _models.FirewallRule: - """Gets information about a firewall rule in a server. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param firewall_rule_name: Name of the firewall rule. Required. - :type firewall_rule_name: str - :return: FirewallRule or the result of cls(response) - :rtype: ~azure.mgmt.postgresqlflexibleservers.models.FirewallRule - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.FirewallRule] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - server_name=server_name, - firewall_rule_name=firewall_rule_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize( - _models.ErrorResponse, - pipeline_response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("FirewallRule", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def list_by_server( - self, resource_group_name: str, server_name: str, **kwargs: Any - ) -> ItemPaged["_models.FirewallRule"]: - """Lists information about all firewall rules in a server. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :return: An iterator like instance of either FirewallRule or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.postgresqlflexibleservers.models.FirewallRule] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.FirewallRuleList] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_by_server_request( - resource_group_name=resource_group_name, - server_name=server_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("FirewallRuleList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize( - _models.ErrorResponse, - pipeline_response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) diff --git a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/azure/mgmt/postgresqlflexibleservers/operations/_migrations_operations.py b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/azure/mgmt/postgresqlflexibleservers/operations/_migrations_operations.py deleted file mode 100644 index 71fb14f574bc..000000000000 --- a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/azure/mgmt/postgresqlflexibleservers/operations/_migrations_operations.py +++ /dev/null @@ -1,954 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from collections.abc import MutableMapping -from io import IOBase -from typing import Any, Callable, IO, Optional, TypeVar, Union, overload -import urllib.parse - -from azure.core import PipelineClient -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.rest import HttpRequest, HttpResponse -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from .._configuration import PostgreSQLManagementClientConfiguration -from .._utils.serialization import Deserializer, Serializer - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, dict[str, Any]], Any]] -List = list - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_create_request( - resource_group_name: str, server_name: str, migration_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-08-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}/migrations/{migrationName}", - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "serverName": _SERIALIZER.url( - "server_name", server_name, "str", max_length=63, min_length=3, pattern=r"^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*" - ), - "migrationName": _SERIALIZER.url("migration_name", migration_name, "str", pattern=r"^[a-z][a-z0-9]*$"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_get_request( - resource_group_name: str, server_name: str, migration_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-08-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}/migrations/{migrationName}", - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "serverName": _SERIALIZER.url( - "server_name", server_name, "str", max_length=63, min_length=3, pattern=r"^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*" - ), - "migrationName": _SERIALIZER.url("migration_name", migration_name, "str", pattern=r"^[a-z][a-z0-9]*$"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_update_request( - resource_group_name: str, server_name: str, migration_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-08-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}/migrations/{migrationName}", - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "serverName": _SERIALIZER.url( - "server_name", server_name, "str", max_length=63, min_length=3, pattern=r"^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*" - ), - "migrationName": _SERIALIZER.url("migration_name", migration_name, "str", pattern=r"^[a-z][a-z0-9]*$"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_cancel_request( - resource_group_name: str, server_name: str, migration_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-08-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}/migrations/{migrationName}", - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "serverName": _SERIALIZER.url( - "server_name", server_name, "str", max_length=63, min_length=3, pattern=r"^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*" - ), - "migrationName": _SERIALIZER.url("migration_name", migration_name, "str", pattern=r"^[a-z][a-z0-9]*$"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_list_by_target_server_request( - resource_group_name: str, - server_name: str, - subscription_id: str, - *, - migration_list_filter: Optional[Union[str, _models.MigrationListFilter]] = None, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-08-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}/migrations", - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "serverName": _SERIALIZER.url( - "server_name", server_name, "str", max_length=63, min_length=3, pattern=r"^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*" - ), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - if migration_list_filter is not None: - _params["migrationListFilter"] = _SERIALIZER.query("migration_list_filter", migration_list_filter, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_check_name_availability_request( - resource_group_name: str, server_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-08-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}/checkMigrationNameAvailability", - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "serverName": _SERIALIZER.url( - "server_name", server_name, "str", max_length=63, min_length=3, pattern=r"^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*" - ), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -class MigrationsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.postgresqlflexibleservers.PostgreSQLManagementClient`'s - :attr:`migrations` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: PostgreSQLManagementClientConfiguration = ( - input_args.pop(0) if input_args else kwargs.pop("config") - ) - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @overload - def create( - self, - resource_group_name: str, - server_name: str, - migration_name: str, - parameters: _models.Migration, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.Migration: - """Creates a new migration. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param migration_name: Name of migration. Required. - :type migration_name: str - :param parameters: Parameters required for creating a migration. Required. - :type parameters: ~azure.mgmt.postgresqlflexibleservers.models.Migration - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: Migration or the result of cls(response) - :rtype: ~azure.mgmt.postgresqlflexibleservers.models.Migration - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def create( - self, - resource_group_name: str, - server_name: str, - migration_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.Migration: - """Creates a new migration. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param migration_name: Name of migration. Required. - :type migration_name: str - :param parameters: Parameters required for creating a migration. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: Migration or the result of cls(response) - :rtype: ~azure.mgmt.postgresqlflexibleservers.models.Migration - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def create( - self, - resource_group_name: str, - server_name: str, - migration_name: str, - parameters: Union[_models.Migration, IO[bytes]], - **kwargs: Any - ) -> _models.Migration: - """Creates a new migration. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param migration_name: Name of migration. Required. - :type migration_name: str - :param parameters: Parameters required for creating a migration. Is either a Migration type or - a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.postgresqlflexibleservers.models.Migration or IO[bytes] - :return: Migration or the result of cls(response) - :rtype: ~azure.mgmt.postgresqlflexibleservers.models.Migration - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.Migration] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "Migration") - - _request = build_create_request( - resource_group_name=resource_group_name, - server_name=server_name, - migration_name=migration_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize( - _models.ErrorResponse, - pipeline_response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("Migration", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def get(self, resource_group_name: str, server_name: str, migration_name: str, **kwargs: Any) -> _models.Migration: - """Gets information about a migration. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param migration_name: Name of migration. Required. - :type migration_name: str - :return: Migration or the result of cls(response) - :rtype: ~azure.mgmt.postgresqlflexibleservers.models.Migration - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.Migration] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - server_name=server_name, - migration_name=migration_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize( - _models.ErrorResponse, - pipeline_response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("Migration", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def update( - self, - resource_group_name: str, - server_name: str, - migration_name: str, - parameters: _models.MigrationResourceForPatch, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.Migration: - """Updates an existing migration. The request body can contain one to many of the mutable - properties present in the migration definition. Certain property updates initiate migration - state transitions. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param migration_name: Name of migration. Required. - :type migration_name: str - :param parameters: Parameters required to update an existing migration. Required. - :type parameters: ~azure.mgmt.postgresqlflexibleservers.models.MigrationResourceForPatch - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: Migration or the result of cls(response) - :rtype: ~azure.mgmt.postgresqlflexibleservers.models.Migration - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def update( - self, - resource_group_name: str, - server_name: str, - migration_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.Migration: - """Updates an existing migration. The request body can contain one to many of the mutable - properties present in the migration definition. Certain property updates initiate migration - state transitions. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param migration_name: Name of migration. Required. - :type migration_name: str - :param parameters: Parameters required to update an existing migration. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: Migration or the result of cls(response) - :rtype: ~azure.mgmt.postgresqlflexibleservers.models.Migration - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def update( - self, - resource_group_name: str, - server_name: str, - migration_name: str, - parameters: Union[_models.MigrationResourceForPatch, IO[bytes]], - **kwargs: Any - ) -> _models.Migration: - """Updates an existing migration. The request body can contain one to many of the mutable - properties present in the migration definition. Certain property updates initiate migration - state transitions. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param migration_name: Name of migration. Required. - :type migration_name: str - :param parameters: Parameters required to update an existing migration. Is either a - MigrationResourceForPatch type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.postgresqlflexibleservers.models.MigrationResourceForPatch or - IO[bytes] - :return: Migration or the result of cls(response) - :rtype: ~azure.mgmt.postgresqlflexibleservers.models.Migration - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.Migration] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "MigrationResourceForPatch") - - _request = build_update_request( - resource_group_name=resource_group_name, - server_name=server_name, - migration_name=migration_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize( - _models.ErrorResponse, - pipeline_response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("Migration", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def cancel( - self, resource_group_name: str, server_name: str, migration_name: str, **kwargs: Any - ) -> Optional[_models.Migration]: - """Cancels an active migration. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param migration_name: Name of migration. Required. - :type migration_name: str - :return: Migration or None or the result of cls(response) - :rtype: ~azure.mgmt.postgresqlflexibleservers.models.Migration or None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[Optional[_models.Migration]] = kwargs.pop("cls", None) - - _request = build_cancel_request( - resource_group_name=resource_group_name, - server_name=server_name, - migration_name=migration_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize( - _models.ErrorResponse, - pipeline_response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize("Migration", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def list_by_target_server( - self, - resource_group_name: str, - server_name: str, - migration_list_filter: Optional[Union[str, _models.MigrationListFilter]] = None, - **kwargs: Any - ) -> ItemPaged["_models.Migration"]: - """Lists all migrations of a target flexible server. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param migration_list_filter: Migration list filter. Indicates if the request should retrieve - only active migrations or all migrations. Defaults to Active. Known values are: "Active" and - "All". Default value is None. - :type migration_list_filter: str or - ~azure.mgmt.postgresqlflexibleservers.models.MigrationListFilter - :return: An iterator like instance of either Migration or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.postgresqlflexibleservers.models.Migration] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.MigrationList] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_by_target_server_request( - resource_group_name=resource_group_name, - server_name=server_name, - subscription_id=self._config.subscription_id, - migration_list_filter=migration_list_filter, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("MigrationList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize( - _models.ErrorResponse, - pipeline_response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @overload - def check_name_availability( - self, - resource_group_name: str, - server_name: str, - parameters: _models.MigrationNameAvailability, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.MigrationNameAvailability: - """Check the validity and availability of the given name, to assign it to a new migration. - - Checks if a proposed migration name is valid and available. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param parameters: Parameters required to check if a migration name is valid and available. - Required. - :type parameters: ~azure.mgmt.postgresqlflexibleservers.models.MigrationNameAvailability - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: MigrationNameAvailability or the result of cls(response) - :rtype: ~azure.mgmt.postgresqlflexibleservers.models.MigrationNameAvailability - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def check_name_availability( - self, - resource_group_name: str, - server_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.MigrationNameAvailability: - """Check the validity and availability of the given name, to assign it to a new migration. - - Checks if a proposed migration name is valid and available. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param parameters: Parameters required to check if a migration name is valid and available. - Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: MigrationNameAvailability or the result of cls(response) - :rtype: ~azure.mgmt.postgresqlflexibleservers.models.MigrationNameAvailability - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def check_name_availability( - self, - resource_group_name: str, - server_name: str, - parameters: Union[_models.MigrationNameAvailability, IO[bytes]], - **kwargs: Any - ) -> _models.MigrationNameAvailability: - """Check the validity and availability of the given name, to assign it to a new migration. - - Checks if a proposed migration name is valid and available. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param parameters: Parameters required to check if a migration name is valid and available. Is - either a MigrationNameAvailability type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.postgresqlflexibleservers.models.MigrationNameAvailability or - IO[bytes] - :return: MigrationNameAvailability or the result of cls(response) - :rtype: ~azure.mgmt.postgresqlflexibleservers.models.MigrationNameAvailability - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.MigrationNameAvailability] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "MigrationNameAvailability") - - _request = build_check_name_availability_request( - resource_group_name=resource_group_name, - server_name=server_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize( - _models.ErrorResponse, - pipeline_response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("MigrationNameAvailability", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/azure/mgmt/postgresqlflexibleservers/operations/_name_availability_operations.py b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/azure/mgmt/postgresqlflexibleservers/operations/_name_availability_operations.py deleted file mode 100644 index 3c539f175333..000000000000 --- a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/azure/mgmt/postgresqlflexibleservers/operations/_name_availability_operations.py +++ /dev/null @@ -1,348 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from collections.abc import MutableMapping -from io import IOBase -from typing import Any, Callable, IO, Optional, TypeVar, Union, overload - -from azure.core import PipelineClient -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.rest import HttpRequest, HttpResponse -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from .._configuration import PostgreSQLManagementClientConfiguration -from .._utils.serialization import Deserializer, Serializer - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, dict[str, Any]], Any]] -List = list - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_check_globally_request(subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-08-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.DBforPostgreSQL/checkNameAvailability" - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_check_with_location_request(location_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-08-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.DBforPostgreSQL/locations/{locationName}/checkNameAvailability", - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "locationName": _SERIALIZER.url("location_name", location_name, "str", min_length=1, pattern=r"^[-\w\._]+$"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -class NameAvailabilityOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.postgresqlflexibleservers.PostgreSQLManagementClient`'s - :attr:`name_availability` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: PostgreSQLManagementClientConfiguration = ( - input_args.pop(0) if input_args else kwargs.pop("config") - ) - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @overload - def check_globally( - self, parameters: _models.CheckNameAvailabilityRequest, *, content_type: str = "application/json", **kwargs: Any - ) -> _models.NameAvailabilityModel: - """Checks the validity and availability of the given name, to assign it to a new server or to use - it as the base name of a new pair of virtual endpoints. - - :param parameters: Parameters required to check if a given name is valid and available to - assign it to a new server or to use it as the base name of a new pair of virtual endpoints. - Required. - :type parameters: ~azure.mgmt.postgresqlflexibleservers.models.CheckNameAvailabilityRequest - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: NameAvailabilityModel or the result of cls(response) - :rtype: ~azure.mgmt.postgresqlflexibleservers.models.NameAvailabilityModel - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def check_globally( - self, parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> _models.NameAvailabilityModel: - """Checks the validity and availability of the given name, to assign it to a new server or to use - it as the base name of a new pair of virtual endpoints. - - :param parameters: Parameters required to check if a given name is valid and available to - assign it to a new server or to use it as the base name of a new pair of virtual endpoints. - Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: NameAvailabilityModel or the result of cls(response) - :rtype: ~azure.mgmt.postgresqlflexibleservers.models.NameAvailabilityModel - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def check_globally( - self, parameters: Union[_models.CheckNameAvailabilityRequest, IO[bytes]], **kwargs: Any - ) -> _models.NameAvailabilityModel: - """Checks the validity and availability of the given name, to assign it to a new server or to use - it as the base name of a new pair of virtual endpoints. - - :param parameters: Parameters required to check if a given name is valid and available to - assign it to a new server or to use it as the base name of a new pair of virtual endpoints. Is - either a CheckNameAvailabilityRequest type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.postgresqlflexibleservers.models.CheckNameAvailabilityRequest or - IO[bytes] - :return: NameAvailabilityModel or the result of cls(response) - :rtype: ~azure.mgmt.postgresqlflexibleservers.models.NameAvailabilityModel - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.NameAvailabilityModel] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "CheckNameAvailabilityRequest") - - _request = build_check_globally_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize( - _models.ErrorResponse, - pipeline_response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("NameAvailabilityModel", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def check_with_location( - self, - location_name: str, - parameters: _models.CheckNameAvailabilityRequest, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.NameAvailabilityModel: - """Check the availability of name for resource. - - :param location_name: The name of the location. Required. - :type location_name: str - :param parameters: Parameters required to check if a given name is valid and available to - assign it to a new server or to use it as the base name of a new pair of virtual endpoints. - Required. - :type parameters: ~azure.mgmt.postgresqlflexibleservers.models.CheckNameAvailabilityRequest - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: NameAvailabilityModel or the result of cls(response) - :rtype: ~azure.mgmt.postgresqlflexibleservers.models.NameAvailabilityModel - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def check_with_location( - self, location_name: str, parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> _models.NameAvailabilityModel: - """Check the availability of name for resource. - - :param location_name: The name of the location. Required. - :type location_name: str - :param parameters: Parameters required to check if a given name is valid and available to - assign it to a new server or to use it as the base name of a new pair of virtual endpoints. - Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: NameAvailabilityModel or the result of cls(response) - :rtype: ~azure.mgmt.postgresqlflexibleservers.models.NameAvailabilityModel - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def check_with_location( - self, location_name: str, parameters: Union[_models.CheckNameAvailabilityRequest, IO[bytes]], **kwargs: Any - ) -> _models.NameAvailabilityModel: - """Check the availability of name for resource. - - :param location_name: The name of the location. Required. - :type location_name: str - :param parameters: Parameters required to check if a given name is valid and available to - assign it to a new server or to use it as the base name of a new pair of virtual endpoints. Is - either a CheckNameAvailabilityRequest type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.postgresqlflexibleservers.models.CheckNameAvailabilityRequest or - IO[bytes] - :return: NameAvailabilityModel or the result of cls(response) - :rtype: ~azure.mgmt.postgresqlflexibleservers.models.NameAvailabilityModel - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.NameAvailabilityModel] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "CheckNameAvailabilityRequest") - - _request = build_check_with_location_request( - location_name=location_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize( - _models.ErrorResponse, - pipeline_response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("NameAvailabilityModel", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/azure/mgmt/postgresqlflexibleservers/operations/_operations.py b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/azure/mgmt/postgresqlflexibleservers/operations/_operations.py index 373d35f9d8f3..778519de6997 100644 --- a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/azure/mgmt/postgresqlflexibleservers/operations/_operations.py +++ b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/azure/mgmt/postgresqlflexibleservers/operations/_operations.py @@ -1,12 +1,15 @@ +# pylint: disable=line-too-long,useless-suppression,too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from collections.abc import MutableMapping -from typing import Any, Callable, Optional, TypeVar +from io import IOBase +import json +from typing import Any, Callable, IO, Iterator, Optional, TypeVar, Union, cast, overload import urllib.parse from azure.core import PipelineClient @@ -16,36 +19,43 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models from .._configuration import PostgreSQLManagementClientConfiguration +from .._utils.model_base import SdkJSONEncoder, _deserialize, _failsafe_deserialize from .._utils.serialization import Deserializer, Serializer +from .._validation import api_version_validation T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, dict[str, Any]], Any]] +JSON = MutableMapping[str, Any] List = list _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_list_request(**kwargs: Any) -> HttpRequest: +def build_operations_list_request(**kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-01-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.DBforPostgreSQL/operations") + _url = "/providers/Microsoft.DBforPostgreSQL/operations" # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -56,6 +66,1875 @@ def build_list_request(**kwargs: Any) -> HttpRequest: return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) +def build_migrations_get_request( + resource_group_name: str, server_name: str, migration_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-01-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}/migrations/{migrationName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serverName": _SERIALIZER.url("server_name", server_name, "str"), + "migrationName": _SERIALIZER.url("migration_name", migration_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_migrations_create_request( + resource_group_name: str, server_name: str, migration_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-01-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}/migrations/{migrationName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serverName": _SERIALIZER.url("server_name", server_name, "str"), + "migrationName": _SERIALIZER.url("migration_name", migration_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_migrations_update_request( + resource_group_name: str, server_name: str, migration_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-01-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}/migrations/{migrationName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serverName": _SERIALIZER.url("server_name", server_name, "str"), + "migrationName": _SERIALIZER.url("migration_name", migration_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_migrations_cancel_request( + resource_group_name: str, server_name: str, migration_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-01-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}/migrations/{migrationName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serverName": _SERIALIZER.url("server_name", server_name, "str"), + "migrationName": _SERIALIZER.url("migration_name", migration_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_migrations_list_by_target_server_request( # pylint: disable=name-too-long + resource_group_name: str, + server_name: str, + subscription_id: str, + *, + migration_list_filter: Optional[Union[str, _models.MigrationListFilter]] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-01-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}/migrations" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serverName": _SERIALIZER.url("server_name", server_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if migration_list_filter is not None: + _params["migrationListFilter"] = _SERIALIZER.query("migration_list_filter", migration_list_filter, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_migrations_check_name_availability_request( # pylint: disable=name-too-long + resource_group_name: str, server_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-01-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}/checkMigrationNameAvailability" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serverName": _SERIALIZER.url("server_name", server_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_servers_get_request( + resource_group_name: str, server_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-01-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serverName": _SERIALIZER.url("server_name", server_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_servers_create_or_update_request( + resource_group_name: str, server_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-01-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serverName": _SERIALIZER.url("server_name", server_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_servers_update_request( + resource_group_name: str, server_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-01-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serverName": _SERIALIZER.url("server_name", server_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_servers_delete_request( + resource_group_name: str, server_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-01-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serverName": _SERIALIZER.url("server_name", server_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) + + +def build_servers_list_by_resource_group_request( # pylint: disable=name-too-long + resource_group_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-01-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_servers_list_by_subscription_request( # pylint: disable=name-too-long + subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-01-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/providers/Microsoft.DBforPostgreSQL/flexibleServers" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_servers_restart_request( + resource_group_name: str, server_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-01-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}/restart" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serverName": _SERIALIZER.url("server_name", server_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_servers_start_request( + resource_group_name: str, server_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-01-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}/start" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serverName": _SERIALIZER.url("server_name", server_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="POST", url=_url, params=_params, **kwargs) + + +def build_servers_stop_request( + resource_group_name: str, server_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-01-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}/stop" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serverName": _SERIALIZER.url("server_name", server_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="POST", url=_url, params=_params, **kwargs) + + +def build_servers_migrate_network_mode_request( # pylint: disable=name-too-long + resource_group_name: str, server_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-01-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}/migrateNetwork" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serverName": _SERIALIZER.url("server_name", server_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_configurations_get_request( + resource_group_name: str, server_name: str, configuration_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-01-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}/configurations/{configurationName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serverName": _SERIALIZER.url("server_name", server_name, "str"), + "configurationName": _SERIALIZER.url("configuration_name", configuration_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_configurations_put_request( + resource_group_name: str, server_name: str, configuration_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-01-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}/configurations/{configurationName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serverName": _SERIALIZER.url("server_name", server_name, "str"), + "configurationName": _SERIALIZER.url("configuration_name", configuration_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_configurations_update_request( + resource_group_name: str, server_name: str, configuration_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-01-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}/configurations/{configurationName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serverName": _SERIALIZER.url("server_name", server_name, "str"), + "configurationName": _SERIALIZER.url("configuration_name", configuration_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_configurations_list_by_server_request( # pylint: disable=name-too-long + resource_group_name: str, server_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-01-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}/configurations" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serverName": _SERIALIZER.url("server_name", server_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_databases_get_request( + resource_group_name: str, server_name: str, database_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-01-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}/databases/{databaseName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serverName": _SERIALIZER.url("server_name", server_name, "str"), + "databaseName": _SERIALIZER.url("database_name", database_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_databases_create_request( + resource_group_name: str, server_name: str, database_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-01-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}/databases/{databaseName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serverName": _SERIALIZER.url("server_name", server_name, "str"), + "databaseName": _SERIALIZER.url("database_name", database_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_databases_delete_request( + resource_group_name: str, server_name: str, database_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-01-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}/databases/{databaseName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serverName": _SERIALIZER.url("server_name", server_name, "str"), + "databaseName": _SERIALIZER.url("database_name", database_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) + + +def build_databases_list_by_server_request( + resource_group_name: str, server_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-01-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}/databases" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serverName": _SERIALIZER.url("server_name", server_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_firewall_rules_get_request( + resource_group_name: str, server_name: str, firewall_rule_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-01-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}/firewallRules/{firewallRuleName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serverName": _SERIALIZER.url("server_name", server_name, "str"), + "firewallRuleName": _SERIALIZER.url("firewall_rule_name", firewall_rule_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_firewall_rules_create_or_update_request( # pylint: disable=name-too-long + resource_group_name: str, server_name: str, firewall_rule_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-01-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}/firewallRules/{firewallRuleName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serverName": _SERIALIZER.url("server_name", server_name, "str"), + "firewallRuleName": _SERIALIZER.url("firewall_rule_name", firewall_rule_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_firewall_rules_delete_request( + resource_group_name: str, server_name: str, firewall_rule_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-01-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}/firewallRules/{firewallRuleName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serverName": _SERIALIZER.url("server_name", server_name, "str"), + "firewallRuleName": _SERIALIZER.url("firewall_rule_name", firewall_rule_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) + + +def build_firewall_rules_list_by_server_request( # pylint: disable=name-too-long + resource_group_name: str, server_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-01-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}/firewallRules" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serverName": _SERIALIZER.url("server_name", server_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_private_endpoint_connections_get_request( # pylint: disable=name-too-long + resource_group_name: str, + server_name: str, + private_endpoint_connection_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-01-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}/privateEndpointConnections/{privateEndpointConnectionName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serverName": _SERIALIZER.url("server_name", server_name, "str"), + "privateEndpointConnectionName": _SERIALIZER.url( + "private_endpoint_connection_name", private_endpoint_connection_name, "str" + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_private_endpoint_connections_update_request( # pylint: disable=name-too-long + resource_group_name: str, + server_name: str, + private_endpoint_connection_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-01-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}/privateEndpointConnections/{privateEndpointConnectionName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serverName": _SERIALIZER.url("server_name", server_name, "str"), + "privateEndpointConnectionName": _SERIALIZER.url( + "private_endpoint_connection_name", private_endpoint_connection_name, "str" + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_private_endpoint_connections_delete_request( # pylint: disable=name-too-long + resource_group_name: str, + server_name: str, + private_endpoint_connection_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-01-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}/privateEndpointConnections/{privateEndpointConnectionName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serverName": _SERIALIZER.url("server_name", server_name, "str"), + "privateEndpointConnectionName": _SERIALIZER.url( + "private_endpoint_connection_name", private_endpoint_connection_name, "str" + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) + + +def build_private_endpoint_connections_list_by_server_request( # pylint: disable=name-too-long + resource_group_name: str, server_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-01-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}/privateEndpointConnections" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serverName": _SERIALIZER.url("server_name", server_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_private_link_resources_get_request( + resource_group_name: str, server_name: str, group_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-01-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}/privateLinkResources/{groupName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serverName": _SERIALIZER.url("server_name", server_name, "str"), + "groupName": _SERIALIZER.url("group_name", group_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_private_link_resources_list_by_server_request( # pylint: disable=name-too-long + resource_group_name: str, server_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-01-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}/privateLinkResources" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serverName": _SERIALIZER.url("server_name", server_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_virtual_endpoints_get_request( + resource_group_name: str, server_name: str, virtual_endpoint_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-01-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}/virtualendpoints/{virtualEndpointName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serverName": _SERIALIZER.url("server_name", server_name, "str"), + "virtualEndpointName": _SERIALIZER.url("virtual_endpoint_name", virtual_endpoint_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_virtual_endpoints_create_request( + resource_group_name: str, server_name: str, virtual_endpoint_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-01-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}/virtualendpoints/{virtualEndpointName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serverName": _SERIALIZER.url("server_name", server_name, "str"), + "virtualEndpointName": _SERIALIZER.url("virtual_endpoint_name", virtual_endpoint_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_virtual_endpoints_update_request( + resource_group_name: str, server_name: str, virtual_endpoint_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-01-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}/virtualendpoints/{virtualEndpointName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serverName": _SERIALIZER.url("server_name", server_name, "str"), + "virtualEndpointName": _SERIALIZER.url("virtual_endpoint_name", virtual_endpoint_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_virtual_endpoints_delete_request( + resource_group_name: str, server_name: str, virtual_endpoint_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-01-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}/virtualendpoints/{virtualEndpointName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serverName": _SERIALIZER.url("server_name", server_name, "str"), + "virtualEndpointName": _SERIALIZER.url("virtual_endpoint_name", virtual_endpoint_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) + + +def build_virtual_endpoints_list_by_server_request( # pylint: disable=name-too-long + resource_group_name: str, server_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-01-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}/virtualendpoints" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serverName": _SERIALIZER.url("server_name", server_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_administrators_microsoft_entra_get_request( # pylint: disable=name-too-long + resource_group_name: str, server_name: str, object_id: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-01-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}/administrators/{objectId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serverName": _SERIALIZER.url("server_name", server_name, "str"), + "objectId": _SERIALIZER.url("object_id", object_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_administrators_microsoft_entra_create_or_update_request( # pylint: disable=name-too-long + resource_group_name: str, server_name: str, object_id: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-01-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}/administrators/{objectId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serverName": _SERIALIZER.url("server_name", server_name, "str"), + "objectId": _SERIALIZER.url("object_id", object_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_administrators_microsoft_entra_delete_request( # pylint: disable=name-too-long + resource_group_name: str, server_name: str, object_id: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-01-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}/administrators/{objectId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serverName": _SERIALIZER.url("server_name", server_name, "str"), + "objectId": _SERIALIZER.url("object_id", object_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) + + +def build_administrators_microsoft_entra_list_by_server_request( # pylint: disable=name-too-long + resource_group_name: str, server_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-01-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}/administrators" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serverName": _SERIALIZER.url("server_name", server_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_capabilities_by_server_list_request( # pylint: disable=name-too-long + resource_group_name: str, server_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-01-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}/capabilities" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serverName": _SERIALIZER.url("server_name", server_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_captured_logs_list_by_server_request( # pylint: disable=name-too-long + resource_group_name: str, server_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-01-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}/logFiles" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serverName": _SERIALIZER.url("server_name", server_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_backups_long_term_retention_check_prerequisites_request( # pylint: disable=name-too-long + resource_group_name: str, server_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-01-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}/ltrPreBackup" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serverName": _SERIALIZER.url("server_name", server_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_backups_long_term_retention_start_request( # pylint: disable=name-too-long + resource_group_name: str, server_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-01-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}/startLtrBackup" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serverName": _SERIALIZER.url("server_name", server_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_backups_long_term_retention_get_request( # pylint: disable=name-too-long + resource_group_name: str, server_name: str, backup_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-01-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}/ltrBackupOperations/{backupName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serverName": _SERIALIZER.url("server_name", server_name, "str"), + "backupName": _SERIALIZER.url("backup_name", backup_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_backups_long_term_retention_list_by_server_request( # pylint: disable=name-too-long + resource_group_name: str, server_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-01-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}/ltrBackupOperations" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serverName": _SERIALIZER.url("server_name", server_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_replicas_list_by_server_request( + resource_group_name: str, server_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-01-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}/replicas" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serverName": _SERIALIZER.url("server_name", server_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_advanced_threat_protection_settings_get_request( # pylint: disable=name-too-long + resource_group_name: str, + server_name: str, + threat_protection_name: Union[str, _models.ThreatProtectionName], + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-01-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}/advancedThreatProtectionSettings/{threatProtectionName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serverName": _SERIALIZER.url("server_name", server_name, "str"), + "threatProtectionName": _SERIALIZER.url("threat_protection_name", threat_protection_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_advanced_threat_protection_settings_list_by_server_request( # pylint: disable=name-too-long + resource_group_name: str, server_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-01-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}/advancedThreatProtectionSettings" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serverName": _SERIALIZER.url("server_name", server_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_server_threat_protection_settings_create_or_update_request( # pylint: disable=name-too-long + resource_group_name: str, + server_name: str, + threat_protection_name: Union[str, _models.ThreatProtectionName], + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-01-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}/advancedThreatProtectionSettings/{threatProtectionName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serverName": _SERIALIZER.url("server_name", server_name, "str"), + "threatProtectionName": _SERIALIZER.url("threat_protection_name", threat_protection_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_backups_automatic_and_on_demand_get_request( # pylint: disable=name-too-long + resource_group_name: str, server_name: str, backup_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-01-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}/backups/{backupName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serverName": _SERIALIZER.url("server_name", server_name, "str"), + "backupName": _SERIALIZER.url("backup_name", backup_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_backups_automatic_and_on_demand_create_request( # pylint: disable=name-too-long + resource_group_name: str, server_name: str, backup_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-01-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}/backups/{backupName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serverName": _SERIALIZER.url("server_name", server_name, "str"), + "backupName": _SERIALIZER.url("backup_name", backup_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, **kwargs) + + +def build_backups_automatic_and_on_demand_delete_request( # pylint: disable=name-too-long + resource_group_name: str, server_name: str, backup_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-01-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}/backups/{backupName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serverName": _SERIALIZER.url("server_name", server_name, "str"), + "backupName": _SERIALIZER.url("backup_name", backup_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) + + +def build_backups_automatic_and_on_demand_list_by_server_request( # pylint: disable=name-too-long + resource_group_name: str, server_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-01-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}/backups" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serverName": _SERIALIZER.url("server_name", server_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_tuning_options_get_request( + resource_group_name: str, + server_name: str, + tuning_option: Union[str, _models.TuningOptionParameterEnum], + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-01-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}/tuningOptions/{tuningOption}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serverName": _SERIALIZER.url("server_name", server_name, "str"), + "tuningOption": _SERIALIZER.url("tuning_option", tuning_option, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_tuning_options_list_by_server_request( # pylint: disable=name-too-long + resource_group_name: str, server_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-01-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}/tuningOptions" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serverName": _SERIALIZER.url("server_name", server_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_tuning_options_list_recommendations_request( # pylint: disable=name-too-long + resource_group_name: str, + server_name: str, + tuning_option: Union[str, _models.TuningOptionParameterEnum], + subscription_id: str, + *, + recommendation_type: Optional[Union[str, _models.RecommendationTypeParameterEnum]] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-01-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}/tuningOptions/{tuningOption}/recommendations" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serverName": _SERIALIZER.url("server_name", server_name, "str"), + "tuningOption": _SERIALIZER.url("tuning_option", tuning_option, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if recommendation_type is not None: + _params["recommendationType"] = _SERIALIZER.query("recommendation_type", recommendation_type, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_capabilities_by_location_list_request( # pylint: disable=name-too-long + location_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-01-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/providers/Microsoft.DBforPostgreSQL/locations/{locationName}/capabilities" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "locationName": _SERIALIZER.url("location_name", location_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_name_availability_check_globally_request( # pylint: disable=name-too-long + subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-01-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/providers/Microsoft.DBforPostgreSQL/checkNameAvailability" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_name_availability_check_with_location_request( # pylint: disable=name-too-long + location_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-01-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/providers/Microsoft.DBforPostgreSQL/locations/{locationName}/checkNameAvailability" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "locationName": _SERIALIZER.url("location_name", location_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_private_dns_zone_suffix_get_request(**kwargs: Any) -> HttpRequest: # pylint: disable=name-too-long + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-01-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/providers/Microsoft.DBforPostgreSQL/getPrivateDnsZoneSuffix" + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_quota_usages_list_request(location_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-01-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/providers/Microsoft.DBforPostgreSQL/locations/{locationName}/resourceType/flexibleServers/usages" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "locationName": _SERIALIZER.url("location_name", location_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_virtual_network_subnet_usage_list_request( # pylint: disable=name-too-long + location_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-01-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/providers/Microsoft.DBforPostgreSQL/locations/{locationName}/checkVirtualNetworkSubnetUsage" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "locationName": _SERIALIZER.url("location_name", location_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + class Operations: """ .. warning:: @@ -63,10 +1942,9162 @@ class Operations: Instead, you should access the following operations through :class:`~azure.mgmt.postgresqlflexibleservers.PostgreSQLManagementClient`'s - :attr:`operations` attribute. + :attr:`operations` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: PostgreSQLManagementClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list(self, **kwargs: Any) -> ItemPaged["_models.Operation"]: + """Lists all available REST API operations. + + :return: An iterator like instance of Operation + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.postgresqlflexibleservers.models.Operation] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.Operation]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_operations_list_request( + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize(List[_models.Operation], deserialized.get("value", [])) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class MigrationsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.postgresqlflexibleservers.PostgreSQLManagementClient`'s + :attr:`migrations` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: PostgreSQLManagementClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get(self, resource_group_name: str, server_name: str, migration_name: str, **kwargs: Any) -> _models.Migration: + """Gets information about a migration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param migration_name: Name of migration. Required. + :type migration_name: str + :return: Migration. The Migration is compatible with MutableMapping + :rtype: ~azure.mgmt.postgresqlflexibleservers.models.Migration + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.Migration] = kwargs.pop("cls", None) + + _request = build_migrations_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + migration_name=migration_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() + else: + deserialized = _deserialize(_models.Migration, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def create( + self, + resource_group_name: str, + server_name: str, + migration_name: str, + parameters: _models.Migration, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Migration: + """Creates a new migration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param migration_name: Name of migration. Required. + :type migration_name: str + :param parameters: Parameters required for creating a migration. Required. + :type parameters: ~azure.mgmt.postgresqlflexibleservers.models.Migration + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: Migration. The Migration is compatible with MutableMapping + :rtype: ~azure.mgmt.postgresqlflexibleservers.models.Migration + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create( + self, + resource_group_name: str, + server_name: str, + migration_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Migration: + """Creates a new migration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param migration_name: Name of migration. Required. + :type migration_name: str + :param parameters: Parameters required for creating a migration. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: Migration. The Migration is compatible with MutableMapping + :rtype: ~azure.mgmt.postgresqlflexibleservers.models.Migration + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create( + self, + resource_group_name: str, + server_name: str, + migration_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Migration: + """Creates a new migration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param migration_name: Name of migration. Required. + :type migration_name: str + :param parameters: Parameters required for creating a migration. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: Migration. The Migration is compatible with MutableMapping + :rtype: ~azure.mgmt.postgresqlflexibleservers.models.Migration + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create( + self, + resource_group_name: str, + server_name: str, + migration_name: str, + parameters: Union[_models.Migration, JSON, IO[bytes]], + **kwargs: Any + ) -> _models.Migration: + """Creates a new migration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param migration_name: Name of migration. Required. + :type migration_name: str + :param parameters: Parameters required for creating a migration. Is one of the following types: + Migration, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.postgresqlflexibleservers.models.Migration or JSON or IO[bytes] + :return: Migration. The Migration is compatible with MutableMapping + :rtype: ~azure.mgmt.postgresqlflexibleservers.models.Migration + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Migration] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_migrations_create_request( + resource_group_name=resource_group_name, + server_name=server_name, + migration_name=migration_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() + else: + deserialized = _deserialize(_models.Migration, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def update( + self, + resource_group_name: str, + server_name: str, + migration_name: str, + parameters: _models.MigrationResourceForPatch, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Migration: + """Updates an existing migration. The request body can contain one to many of the mutable + properties present in the migration definition. Certain property updates initiate migration + state transitions. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param migration_name: Name of migration. Required. + :type migration_name: str + :param parameters: Parameters required to update an existing migration. Required. + :type parameters: ~azure.mgmt.postgresqlflexibleservers.models.MigrationResourceForPatch + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: Migration. The Migration is compatible with MutableMapping + :rtype: ~azure.mgmt.postgresqlflexibleservers.models.Migration + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + server_name: str, + migration_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Migration: + """Updates an existing migration. The request body can contain one to many of the mutable + properties present in the migration definition. Certain property updates initiate migration + state transitions. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param migration_name: Name of migration. Required. + :type migration_name: str + :param parameters: Parameters required to update an existing migration. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: Migration. The Migration is compatible with MutableMapping + :rtype: ~azure.mgmt.postgresqlflexibleservers.models.Migration + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + server_name: str, + migration_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Migration: + """Updates an existing migration. The request body can contain one to many of the mutable + properties present in the migration definition. Certain property updates initiate migration + state transitions. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param migration_name: Name of migration. Required. + :type migration_name: str + :param parameters: Parameters required to update an existing migration. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: Migration. The Migration is compatible with MutableMapping + :rtype: ~azure.mgmt.postgresqlflexibleservers.models.Migration + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, + resource_group_name: str, + server_name: str, + migration_name: str, + parameters: Union[_models.MigrationResourceForPatch, JSON, IO[bytes]], + **kwargs: Any + ) -> _models.Migration: + """Updates an existing migration. The request body can contain one to many of the mutable + properties present in the migration definition. Certain property updates initiate migration + state transitions. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param migration_name: Name of migration. Required. + :type migration_name: str + :param parameters: Parameters required to update an existing migration. Is one of the following + types: MigrationResourceForPatch, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.postgresqlflexibleservers.models.MigrationResourceForPatch or + JSON or IO[bytes] + :return: Migration. The Migration is compatible with MutableMapping + :rtype: ~azure.mgmt.postgresqlflexibleservers.models.Migration + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Migration] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_migrations_update_request( + resource_group_name=resource_group_name, + server_name=server_name, + migration_name=migration_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() + else: + deserialized = _deserialize(_models.Migration, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def cancel( + self, resource_group_name: str, server_name: str, migration_name: str, **kwargs: Any + ) -> Optional[_models.Migration]: + """Cancels an active migration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param migration_name: Name of migration. Required. + :type migration_name: str + :return: Migration or None. The Migration is compatible with MutableMapping + :rtype: ~azure.mgmt.postgresqlflexibleservers.models.Migration or None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[Optional[_models.Migration]] = kwargs.pop("cls", None) + + _request = build_migrations_cancel_request( + resource_group_name=resource_group_name, + server_name=server_name, + migration_name=migration_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + if _stream: + deserialized = response.iter_bytes() + else: + deserialized = _deserialize(_models.Migration, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list_by_target_server( + self, + resource_group_name: str, + server_name: str, + *, + migration_list_filter: Optional[Union[str, _models.MigrationListFilter]] = None, + **kwargs: Any + ) -> ItemPaged["_models.Migration"]: + """Lists all migrations of a target flexible server. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :keyword migration_list_filter: Migration list filter. Indicates if the request should retrieve + only active migrations or all migrations. Defaults to Active. Known values are: "Active" and + "All". Default value is None. + :paramtype migration_list_filter: str or + ~azure.mgmt.postgresqlflexibleservers.models.MigrationListFilter + :return: An iterator like instance of Migration + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.postgresqlflexibleservers.models.Migration] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.Migration]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_migrations_list_by_target_server_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + migration_list_filter=migration_list_filter, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize(List[_models.Migration], deserialized.get("value", [])) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @overload + def check_name_availability( + self, + resource_group_name: str, + server_name: str, + parameters: _models.MigrationNameAvailability, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.MigrationNameAvailability: + """Check the validity and availability of the given name, to assign it to a new migration. + + Checks if a proposed migration name is valid and available. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param parameters: Parameters required to check if a migration name is valid and available. + Required. + :type parameters: ~azure.mgmt.postgresqlflexibleservers.models.MigrationNameAvailability + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: MigrationNameAvailability. The MigrationNameAvailability is compatible with + MutableMapping + :rtype: ~azure.mgmt.postgresqlflexibleservers.models.MigrationNameAvailability + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def check_name_availability( + self, + resource_group_name: str, + server_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.MigrationNameAvailability: + """Check the validity and availability of the given name, to assign it to a new migration. + + Checks if a proposed migration name is valid and available. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param parameters: Parameters required to check if a migration name is valid and available. + Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: MigrationNameAvailability. The MigrationNameAvailability is compatible with + MutableMapping + :rtype: ~azure.mgmt.postgresqlflexibleservers.models.MigrationNameAvailability + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def check_name_availability( + self, + resource_group_name: str, + server_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.MigrationNameAvailability: + """Check the validity and availability of the given name, to assign it to a new migration. + + Checks if a proposed migration name is valid and available. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param parameters: Parameters required to check if a migration name is valid and available. + Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: MigrationNameAvailability. The MigrationNameAvailability is compatible with + MutableMapping + :rtype: ~azure.mgmt.postgresqlflexibleservers.models.MigrationNameAvailability + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def check_name_availability( + self, + resource_group_name: str, + server_name: str, + parameters: Union[_models.MigrationNameAvailability, JSON, IO[bytes]], + **kwargs: Any + ) -> _models.MigrationNameAvailability: + """Check the validity and availability of the given name, to assign it to a new migration. + + Checks if a proposed migration name is valid and available. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param parameters: Parameters required to check if a migration name is valid and available. Is + one of the following types: MigrationNameAvailability, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.postgresqlflexibleservers.models.MigrationNameAvailability or + JSON or IO[bytes] + :return: MigrationNameAvailability. The MigrationNameAvailability is compatible with + MutableMapping + :rtype: ~azure.mgmt.postgresqlflexibleservers.models.MigrationNameAvailability + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.MigrationNameAvailability] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_migrations_check_name_availability_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() + else: + deserialized = _deserialize(_models.MigrationNameAvailability, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + +class ServersOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.postgresqlflexibleservers.PostgreSQLManagementClient`'s + :attr:`servers` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: PostgreSQLManagementClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get(self, resource_group_name: str, server_name: str, **kwargs: Any) -> _models.Server: + """Gets information about an existing server. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :return: Server. The Server is compatible with MutableMapping + :rtype: ~azure.mgmt.postgresqlflexibleservers.models.Server + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.Server] = kwargs.pop("cls", None) + + _request = build_servers_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() + else: + deserialized = _deserialize(_models.Server, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + def _create_or_update_initial( + self, + resource_group_name: str, + server_name: str, + parameters: Union[_models.Server, JSON, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_servers_create_or_update_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + parameters: _models.Server, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Server]: + """Creates a new server. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param parameters: Parameters required to create a new server or to update an existing server. + Required. + :type parameters: ~azure.mgmt.postgresqlflexibleservers.models.Server + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns Server. The Server is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.postgresqlflexibleservers.models.Server] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Server]: + """Creates a new server. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param parameters: Parameters required to create a new server or to update an existing server. + Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns Server. The Server is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.postgresqlflexibleservers.models.Server] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Server]: + """Creates a new server. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param parameters: Parameters required to create a new server or to update an existing server. + Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns Server. The Server is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.postgresqlflexibleservers.models.Server] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + parameters: Union[_models.Server, JSON, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.Server]: + """Creates a new server. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param parameters: Parameters required to create a new server or to update an existing server. + Is one of the following types: Server, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.postgresqlflexibleservers.models.Server or JSON or IO[bytes] + :return: An instance of LROPoller that returns Server. The Server is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.postgresqlflexibleservers.models.Server] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Server] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._create_or_update_initial( + resource_group_name=resource_group_name, + server_name=server_name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response_headers = {} + response = pipeline_response.http_response + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = _deserialize(_models.Server, response.json()) + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.Server].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.Server]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + def _update_initial( + self, + resource_group_name: str, + server_name: str, + parameters: Union[_models.ServerForPatch, JSON, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_servers_update_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_update( + self, + resource_group_name: str, + server_name: str, + parameters: _models.ServerForPatch, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Server]: + """Updates an existing server. The request body can contain one or multiple of the properties + present in the normal server definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param parameters: Parameters required to update a server. Required. + :type parameters: ~azure.mgmt.postgresqlflexibleservers.models.ServerForPatch + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns Server. The Server is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.postgresqlflexibleservers.models.Server] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + server_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Server]: + """Updates an existing server. The request body can contain one or multiple of the properties + present in the normal server definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param parameters: Parameters required to update a server. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns Server. The Server is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.postgresqlflexibleservers.models.Server] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + server_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Server]: + """Updates an existing server. The request body can contain one or multiple of the properties + present in the normal server definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param parameters: Parameters required to update a server. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns Server. The Server is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.postgresqlflexibleservers.models.Server] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_update( + self, + resource_group_name: str, + server_name: str, + parameters: Union[_models.ServerForPatch, JSON, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.Server]: + """Updates an existing server. The request body can contain one or multiple of the properties + present in the normal server definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param parameters: Parameters required to update a server. Is one of the following types: + ServerForPatch, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.postgresqlflexibleservers.models.ServerForPatch or JSON or + IO[bytes] + :return: An instance of LROPoller that returns Server. The Server is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.postgresqlflexibleservers.models.Server] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Server] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._update_initial( + resource_group_name=resource_group_name, + server_name=server_name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response_headers = {} + response = pipeline_response.http_response + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = _deserialize(_models.Server, response.json()) + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.Server].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.Server]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + def _delete_initial(self, resource_group_name: str, server_name: str, **kwargs: Any) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_servers_delete_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [202, 204]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def begin_delete(self, resource_group_name: str, server_name: str, **kwargs: Any) -> LROPoller[None]: + """Deletes or drops an existing server. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :return: An instance of LROPoller that returns None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._delete_initial( + resource_group_name=resource_group_name, + server_name=server_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> ItemPaged["_models.Server"]: + """Lists all servers in a resource group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :return: An iterator like instance of Server + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.postgresqlflexibleservers.models.Server] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.Server]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_servers_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize(List[_models.Server], deserialized.get("value", [])) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def list_by_subscription(self, **kwargs: Any) -> ItemPaged["_models.Server"]: + """Lists all servers in a subscription. + + :return: An iterator like instance of Server + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.postgresqlflexibleservers.models.Server] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.Server]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_servers_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize(List[_models.Server], deserialized.get("value", [])) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + def _restart_initial( + self, + resource_group_name: str, + server_name: str, + parameters: Optional[Union[_models.RestartParameter, JSON, IO[bytes]]] = None, + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + content_type = content_type if parameters else None + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" if parameters else None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + if parameters is not None: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + else: + _content = None + + _request = build_servers_restart_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_restart( + self, + resource_group_name: str, + server_name: str, + parameters: Optional[_models.RestartParameter] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Restarts PostgreSQL database engine in a server. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param parameters: Parameters to restart a server. Default value is None. + :type parameters: ~azure.mgmt.postgresqlflexibleservers.models.RestartParameter + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_restart( + self, + resource_group_name: str, + server_name: str, + parameters: Optional[JSON] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Restarts PostgreSQL database engine in a server. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param parameters: Parameters to restart a server. Default value is None. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_restart( + self, + resource_group_name: str, + server_name: str, + parameters: Optional[IO[bytes]] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Restarts PostgreSQL database engine in a server. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param parameters: Parameters to restart a server. Default value is None. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_restart( + self, + resource_group_name: str, + server_name: str, + parameters: Optional[Union[_models.RestartParameter, JSON, IO[bytes]]] = None, + **kwargs: Any + ) -> LROPoller[None]: + """Restarts PostgreSQL database engine in a server. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param parameters: Parameters to restart a server. Is one of the following types: + RestartParameter, JSON, IO[bytes] Default value is None. + :type parameters: ~azure.mgmt.postgresqlflexibleservers.models.RestartParameter or JSON or + IO[bytes] + :return: An instance of LROPoller that returns None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + content_type = content_type if parameters else None + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._restart_initial( + resource_group_name=resource_group_name, + server_name=server_name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + def _start_initial(self, resource_group_name: str, server_name: str, **kwargs: Any) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_servers_start_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def begin_start(self, resource_group_name: str, server_name: str, **kwargs: Any) -> LROPoller[None]: + """Starts a stopped server. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :return: An instance of LROPoller that returns None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._start_initial( + resource_group_name=resource_group_name, + server_name=server_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + def _stop_initial(self, resource_group_name: str, server_name: str, **kwargs: Any) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_servers_stop_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def begin_stop(self, resource_group_name: str, server_name: str, **kwargs: Any) -> LROPoller[None]: + """Stops a server. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :return: An instance of LROPoller that returns None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._stop_initial( + resource_group_name=resource_group_name, + server_name=server_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @api_version_validation( + method_added_on="2026-01-01-preview", + params_added_on={ + "2026-01-01-preview": ["api_version", "subscription_id", "resource_group_name", "server_name", "accept"] + }, + api_versions_list=["2026-01-01-preview"], + ) + def _migrate_network_mode_initial( + self, resource_group_name: str, server_name: str, **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_servers_migrate_network_mode_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 200: + response_headers["x-ms-request-id"] = self._deserialize("str", response.headers.get("x-ms-request-id")) + + if response.status_code == 202: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + response_headers["x-ms-request-id"] = self._deserialize("str", response.headers.get("x-ms-request-id")) + + deserialized = response.iter_bytes() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + @api_version_validation( + method_added_on="2026-01-01-preview", + params_added_on={ + "2026-01-01-preview": ["api_version", "subscription_id", "resource_group_name", "server_name", "accept"] + }, + api_versions_list=["2026-01-01-preview"], + ) + def begin_migrate_network_mode( + self, resource_group_name: str, server_name: str, **kwargs: Any + ) -> LROPoller[_models.MigrateNetworkStatus]: + """Migrates the network configuration of a PostgreSQL flexible server from customer owned VNET to + Microsoft owned VNET with support for private endpoints, or from Microsoft owned VNET with no + support for private endpoints to Microsoft owned VNET with support for private endpoints. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :return: An instance of LROPoller that returns MigrateNetworkStatus. The MigrateNetworkStatus + is compatible with MutableMapping + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.postgresqlflexibleservers.models.MigrateNetworkStatus] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.MigrateNetworkStatus] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._migrate_network_mode_initial( + resource_group_name=resource_group_name, + server_name=server_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response_headers = {} + response = pipeline_response.http_response + response_headers["x-ms-request-id"] = self._deserialize("str", response.headers.get("x-ms-request-id")) + + deserialized = _deserialize(_models.MigrateNetworkStatus, response.json()) + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.MigrateNetworkStatus].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.MigrateNetworkStatus]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + +class ConfigurationsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.postgresqlflexibleservers.PostgreSQLManagementClient`'s + :attr:`configurations` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: PostgreSQLManagementClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get( + self, resource_group_name: str, server_name: str, configuration_name: str, **kwargs: Any + ) -> _models.Configuration: + """Gets information about a specific configuration (also known as server parameter) of a server. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param configuration_name: Name of the configuration (also known as server parameter). + Required. + :type configuration_name: str + :return: Configuration. The Configuration is compatible with MutableMapping + :rtype: ~azure.mgmt.postgresqlflexibleservers.models.Configuration + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.Configuration] = kwargs.pop("cls", None) + + _request = build_configurations_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + configuration_name=configuration_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() + else: + deserialized = _deserialize(_models.Configuration, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + def _put_initial( + self, + resource_group_name: str, + server_name: str, + configuration_name: str, + parameters: Union[_models.ConfigurationForUpdate, JSON, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_configurations_put_request( + resource_group_name=resource_group_name, + server_name=server_name, + configuration_name=configuration_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_put( + self, + resource_group_name: str, + server_name: str, + configuration_name: str, + parameters: _models.ConfigurationForUpdate, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Configuration]: + """Updates, using Put verb, the value assigned to a specific modifiable configuration (also known + as server parameter) of a server. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param configuration_name: Name of the configuration (also known as server parameter). + Required. + :type configuration_name: str + :param parameters: Parameters required to update the value of a specific modifiable + configuration (also known as server parameter). Required. + :type parameters: ~azure.mgmt.postgresqlflexibleservers.models.ConfigurationForUpdate + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns Configuration. The Configuration is compatible + with MutableMapping + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.postgresqlflexibleservers.models.Configuration] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_put( + self, + resource_group_name: str, + server_name: str, + configuration_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Configuration]: + """Updates, using Put verb, the value assigned to a specific modifiable configuration (also known + as server parameter) of a server. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param configuration_name: Name of the configuration (also known as server parameter). + Required. + :type configuration_name: str + :param parameters: Parameters required to update the value of a specific modifiable + configuration (also known as server parameter). Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns Configuration. The Configuration is compatible + with MutableMapping + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.postgresqlflexibleservers.models.Configuration] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_put( + self, + resource_group_name: str, + server_name: str, + configuration_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Configuration]: + """Updates, using Put verb, the value assigned to a specific modifiable configuration (also known + as server parameter) of a server. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param configuration_name: Name of the configuration (also known as server parameter). + Required. + :type configuration_name: str + :param parameters: Parameters required to update the value of a specific modifiable + configuration (also known as server parameter). Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns Configuration. The Configuration is compatible + with MutableMapping + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.postgresqlflexibleservers.models.Configuration] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_put( + self, + resource_group_name: str, + server_name: str, + configuration_name: str, + parameters: Union[_models.ConfigurationForUpdate, JSON, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.Configuration]: + """Updates, using Put verb, the value assigned to a specific modifiable configuration (also known + as server parameter) of a server. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param configuration_name: Name of the configuration (also known as server parameter). + Required. + :type configuration_name: str + :param parameters: Parameters required to update the value of a specific modifiable + configuration (also known as server parameter). Is one of the following types: + ConfigurationForUpdate, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.postgresqlflexibleservers.models.ConfigurationForUpdate or JSON + or IO[bytes] + :return: An instance of LROPoller that returns Configuration. The Configuration is compatible + with MutableMapping + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.postgresqlflexibleservers.models.Configuration] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Configuration] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._put_initial( + resource_group_name=resource_group_name, + server_name=server_name, + configuration_name=configuration_name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response_headers = {} + response = pipeline_response.http_response + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = _deserialize(_models.Configuration, response.json()) + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.Configuration].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.Configuration]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + def _update_initial( + self, + resource_group_name: str, + server_name: str, + configuration_name: str, + parameters: Union[_models.ConfigurationForUpdate, JSON, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_configurations_update_request( + resource_group_name=resource_group_name, + server_name=server_name, + configuration_name=configuration_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_update( + self, + resource_group_name: str, + server_name: str, + configuration_name: str, + parameters: _models.ConfigurationForUpdate, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Configuration]: + """Updates the value assigned to a specific modifiable configuration (also known as server + parameter) of a server. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param configuration_name: Name of the configuration (also known as server parameter). + Required. + :type configuration_name: str + :param parameters: Parameters required to update the value of a specific modifiable + configuration (also known as server parameter). Required. + :type parameters: ~azure.mgmt.postgresqlflexibleservers.models.ConfigurationForUpdate + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns Configuration. The Configuration is compatible + with MutableMapping + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.postgresqlflexibleservers.models.Configuration] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + server_name: str, + configuration_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Configuration]: + """Updates the value assigned to a specific modifiable configuration (also known as server + parameter) of a server. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param configuration_name: Name of the configuration (also known as server parameter). + Required. + :type configuration_name: str + :param parameters: Parameters required to update the value of a specific modifiable + configuration (also known as server parameter). Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns Configuration. The Configuration is compatible + with MutableMapping + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.postgresqlflexibleservers.models.Configuration] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + server_name: str, + configuration_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Configuration]: + """Updates the value assigned to a specific modifiable configuration (also known as server + parameter) of a server. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param configuration_name: Name of the configuration (also known as server parameter). + Required. + :type configuration_name: str + :param parameters: Parameters required to update the value of a specific modifiable + configuration (also known as server parameter). Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns Configuration. The Configuration is compatible + with MutableMapping + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.postgresqlflexibleservers.models.Configuration] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_update( + self, + resource_group_name: str, + server_name: str, + configuration_name: str, + parameters: Union[_models.ConfigurationForUpdate, JSON, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.Configuration]: + """Updates the value assigned to a specific modifiable configuration (also known as server + parameter) of a server. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param configuration_name: Name of the configuration (also known as server parameter). + Required. + :type configuration_name: str + :param parameters: Parameters required to update the value of a specific modifiable + configuration (also known as server parameter). Is one of the following types: + ConfigurationForUpdate, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.postgresqlflexibleservers.models.ConfigurationForUpdate or JSON + or IO[bytes] + :return: An instance of LROPoller that returns Configuration. The Configuration is compatible + with MutableMapping + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.postgresqlflexibleservers.models.Configuration] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Configuration] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._update_initial( + resource_group_name=resource_group_name, + server_name=server_name, + configuration_name=configuration_name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response_headers = {} + response = pipeline_response.http_response + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = _deserialize(_models.Configuration, response.json()) + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.Configuration].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.Configuration]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + @distributed_trace + def list_by_server( + self, resource_group_name: str, server_name: str, **kwargs: Any + ) -> ItemPaged["_models.Configuration"]: + """Lists all configurations (also known as server parameters) of a server. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :return: An iterator like instance of Configuration + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.postgresqlflexibleservers.models.Configuration] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.Configuration]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_configurations_list_by_server_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize(List[_models.Configuration], deserialized.get("value", [])) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class DatabasesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.postgresqlflexibleservers.PostgreSQLManagementClient`'s + :attr:`databases` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: PostgreSQLManagementClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get(self, resource_group_name: str, server_name: str, database_name: str, **kwargs: Any) -> _models.Database: + """Gets information about an existing database. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param database_name: Name of the database (case-sensitive). Exact database names can be + retrieved by getting the list of all existing databases in a server. Required. + :type database_name: str + :return: Database. The Database is compatible with MutableMapping + :rtype: ~azure.mgmt.postgresqlflexibleservers.models.Database + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.Database] = kwargs.pop("cls", None) + + _request = build_databases_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() + else: + deserialized = _deserialize(_models.Database, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + def _create_initial( + self, + resource_group_name: str, + server_name: str, + database_name: str, + parameters: Union[_models.Database, JSON, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_databases_create_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_create( + self, + resource_group_name: str, + server_name: str, + database_name: str, + parameters: _models.Database, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Database]: + """Creates a new database. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param database_name: Name of the database (case-sensitive). Exact database names can be + retrieved by getting the list of all existing databases in a server. Required. + :type database_name: str + :param parameters: Parameters required to create a new database. Required. + :type parameters: ~azure.mgmt.postgresqlflexibleservers.models.Database + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns Database. The Database is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.postgresqlflexibleservers.models.Database] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create( + self, + resource_group_name: str, + server_name: str, + database_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Database]: + """Creates a new database. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param database_name: Name of the database (case-sensitive). Exact database names can be + retrieved by getting the list of all existing databases in a server. Required. + :type database_name: str + :param parameters: Parameters required to create a new database. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns Database. The Database is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.postgresqlflexibleservers.models.Database] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create( + self, + resource_group_name: str, + server_name: str, + database_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Database]: + """Creates a new database. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param database_name: Name of the database (case-sensitive). Exact database names can be + retrieved by getting the list of all existing databases in a server. Required. + :type database_name: str + :param parameters: Parameters required to create a new database. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns Database. The Database is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.postgresqlflexibleservers.models.Database] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create( + self, + resource_group_name: str, + server_name: str, + database_name: str, + parameters: Union[_models.Database, JSON, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.Database]: + """Creates a new database. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param database_name: Name of the database (case-sensitive). Exact database names can be + retrieved by getting the list of all existing databases in a server. Required. + :type database_name: str + :param parameters: Parameters required to create a new database. Is one of the following types: + Database, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.postgresqlflexibleservers.models.Database or JSON or IO[bytes] + :return: An instance of LROPoller that returns Database. The Database is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.postgresqlflexibleservers.models.Database] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Database] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._create_initial( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response_headers = {} + response = pipeline_response.http_response + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = _deserialize(_models.Database, response.json()) + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.Database].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.Database]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + def _delete_initial( + self, resource_group_name: str, server_name: str, database_name: str, **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_databases_delete_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [202, 204]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def begin_delete( + self, resource_group_name: str, server_name: str, database_name: str, **kwargs: Any + ) -> LROPoller[None]: + """Deletes an existing database. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param database_name: Name of the database (case-sensitive). Exact database names can be + retrieved by getting the list of all existing databases in a server. Required. + :type database_name: str + :return: An instance of LROPoller that returns None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._delete_initial( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + def list_by_server( + self, resource_group_name: str, server_name: str, **kwargs: Any + ) -> ItemPaged["_models.Database"]: + """Lists all databases in a server. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :return: An iterator like instance of Database + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.postgresqlflexibleservers.models.Database] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.Database]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_databases_list_by_server_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize(List[_models.Database], deserialized.get("value", [])) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class FirewallRulesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.postgresqlflexibleservers.PostgreSQLManagementClient`'s + :attr:`firewall_rules` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: PostgreSQLManagementClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get( + self, resource_group_name: str, server_name: str, firewall_rule_name: str, **kwargs: Any + ) -> _models.FirewallRule: + """Gets information about a firewall rule in a server. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param firewall_rule_name: Name of the firewall rule. Required. + :type firewall_rule_name: str + :return: FirewallRule. The FirewallRule is compatible with MutableMapping + :rtype: ~azure.mgmt.postgresqlflexibleservers.models.FirewallRule + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.FirewallRule] = kwargs.pop("cls", None) + + _request = build_firewall_rules_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + firewall_rule_name=firewall_rule_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() + else: + deserialized = _deserialize(_models.FirewallRule, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + def _create_or_update_initial( + self, + resource_group_name: str, + server_name: str, + firewall_rule_name: str, + parameters: Union[_models.FirewallRule, JSON, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_firewall_rules_create_or_update_request( + resource_group_name=resource_group_name, + server_name=server_name, + firewall_rule_name=firewall_rule_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + firewall_rule_name: str, + parameters: _models.FirewallRule, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.FirewallRule]: + """Creates a new firewall rule or updates an existing firewall rule. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param firewall_rule_name: Name of the firewall rule. Required. + :type firewall_rule_name: str + :param parameters: Parameters required for creating or updating a firewall rule. Required. + :type parameters: ~azure.mgmt.postgresqlflexibleservers.models.FirewallRule + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns FirewallRule. The FirewallRule is compatible + with MutableMapping + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.postgresqlflexibleservers.models.FirewallRule] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + firewall_rule_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.FirewallRule]: + """Creates a new firewall rule or updates an existing firewall rule. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param firewall_rule_name: Name of the firewall rule. Required. + :type firewall_rule_name: str + :param parameters: Parameters required for creating or updating a firewall rule. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns FirewallRule. The FirewallRule is compatible + with MutableMapping + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.postgresqlflexibleservers.models.FirewallRule] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + firewall_rule_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.FirewallRule]: + """Creates a new firewall rule or updates an existing firewall rule. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param firewall_rule_name: Name of the firewall rule. Required. + :type firewall_rule_name: str + :param parameters: Parameters required for creating or updating a firewall rule. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns FirewallRule. The FirewallRule is compatible + with MutableMapping + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.postgresqlflexibleservers.models.FirewallRule] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + firewall_rule_name: str, + parameters: Union[_models.FirewallRule, JSON, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.FirewallRule]: + """Creates a new firewall rule or updates an existing firewall rule. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param firewall_rule_name: Name of the firewall rule. Required. + :type firewall_rule_name: str + :param parameters: Parameters required for creating or updating a firewall rule. Is one of the + following types: FirewallRule, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.postgresqlflexibleservers.models.FirewallRule or JSON or + IO[bytes] + :return: An instance of LROPoller that returns FirewallRule. The FirewallRule is compatible + with MutableMapping + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.postgresqlflexibleservers.models.FirewallRule] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.FirewallRule] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._create_or_update_initial( + resource_group_name=resource_group_name, + server_name=server_name, + firewall_rule_name=firewall_rule_name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response_headers = {} + response = pipeline_response.http_response + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = _deserialize(_models.FirewallRule, response.json()) + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.FirewallRule].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.FirewallRule]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + def _delete_initial( + self, resource_group_name: str, server_name: str, firewall_rule_name: str, **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_firewall_rules_delete_request( + resource_group_name=resource_group_name, + server_name=server_name, + firewall_rule_name=firewall_rule_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [202, 204]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def begin_delete( + self, resource_group_name: str, server_name: str, firewall_rule_name: str, **kwargs: Any + ) -> LROPoller[None]: + """Deletes an existing firewall rule. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param firewall_rule_name: Name of the firewall rule. Required. + :type firewall_rule_name: str + :return: An instance of LROPoller that returns None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._delete_initial( + resource_group_name=resource_group_name, + server_name=server_name, + firewall_rule_name=firewall_rule_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + def list_by_server( + self, resource_group_name: str, server_name: str, **kwargs: Any + ) -> ItemPaged["_models.FirewallRule"]: + """Lists information about all firewall rules in a server. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :return: An iterator like instance of FirewallRule + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.postgresqlflexibleservers.models.FirewallRule] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.FirewallRule]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_firewall_rules_list_by_server_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize(List[_models.FirewallRule], deserialized.get("value", [])) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class PrivateEndpointConnectionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.postgresqlflexibleservers.PostgreSQLManagementClient`'s + :attr:`private_endpoint_connections` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: PostgreSQLManagementClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get( + self, resource_group_name: str, server_name: str, private_endpoint_connection_name: str, **kwargs: Any + ) -> _models.PrivateEndpointConnection: + """Gets a private endpoint connection. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection associated + with the Azure resource. Required. + :type private_endpoint_connection_name: str + :return: PrivateEndpointConnection. The PrivateEndpointConnection is compatible with + MutableMapping + :rtype: ~azure.mgmt.postgresqlflexibleservers.models.PrivateEndpointConnection + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) + + _request = build_private_endpoint_connections_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + private_endpoint_connection_name=private_endpoint_connection_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() + else: + deserialized = _deserialize(_models.PrivateEndpointConnection, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + def _update_initial( + self, + resource_group_name: str, + server_name: str, + private_endpoint_connection_name: str, + parameters: Union[_models.PrivateEndpointConnection, JSON, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_private_endpoint_connections_update_request( + resource_group_name=resource_group_name, + server_name=server_name, + private_endpoint_connection_name=private_endpoint_connection_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_update( + self, + resource_group_name: str, + server_name: str, + private_endpoint_connection_name: str, + parameters: _models.PrivateEndpointConnection, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.PrivateEndpointConnection]: + """Approves or rejects a private endpoint connection. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection associated + with the Azure resource. Required. + :type private_endpoint_connection_name: str + :param parameters: Parameters required to update a private endpoint connection. Required. + :type parameters: ~azure.mgmt.postgresqlflexibleservers.models.PrivateEndpointConnection + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns PrivateEndpointConnection. The + PrivateEndpointConnection is compatible with MutableMapping + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.postgresqlflexibleservers.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + server_name: str, + private_endpoint_connection_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.PrivateEndpointConnection]: + """Approves or rejects a private endpoint connection. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection associated + with the Azure resource. Required. + :type private_endpoint_connection_name: str + :param parameters: Parameters required to update a private endpoint connection. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns PrivateEndpointConnection. The + PrivateEndpointConnection is compatible with MutableMapping + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.postgresqlflexibleservers.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + server_name: str, + private_endpoint_connection_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.PrivateEndpointConnection]: + """Approves or rejects a private endpoint connection. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection associated + with the Azure resource. Required. + :type private_endpoint_connection_name: str + :param parameters: Parameters required to update a private endpoint connection. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns PrivateEndpointConnection. The + PrivateEndpointConnection is compatible with MutableMapping + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.postgresqlflexibleservers.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_update( + self, + resource_group_name: str, + server_name: str, + private_endpoint_connection_name: str, + parameters: Union[_models.PrivateEndpointConnection, JSON, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.PrivateEndpointConnection]: + """Approves or rejects a private endpoint connection. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection associated + with the Azure resource. Required. + :type private_endpoint_connection_name: str + :param parameters: Parameters required to update a private endpoint connection. Is one of the + following types: PrivateEndpointConnection, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.postgresqlflexibleservers.models.PrivateEndpointConnection or + JSON or IO[bytes] + :return: An instance of LROPoller that returns PrivateEndpointConnection. The + PrivateEndpointConnection is compatible with MutableMapping + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.postgresqlflexibleservers.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._update_initial( + resource_group_name=resource_group_name, + server_name=server_name, + private_endpoint_connection_name=private_endpoint_connection_name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response_headers = {} + response = pipeline_response.http_response + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = _deserialize(_models.PrivateEndpointConnection, response.json()) + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.PrivateEndpointConnection].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.PrivateEndpointConnection]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + def _delete_initial( + self, resource_group_name: str, server_name: str, private_endpoint_connection_name: str, **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_private_endpoint_connections_delete_request( + resource_group_name=resource_group_name, + server_name=server_name, + private_endpoint_connection_name=private_endpoint_connection_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [202, 204]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def begin_delete( + self, resource_group_name: str, server_name: str, private_endpoint_connection_name: str, **kwargs: Any + ) -> LROPoller[None]: + """Deletes a private endpoint connection. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection associated + with the Azure resource. Required. + :type private_endpoint_connection_name: str + :return: An instance of LROPoller that returns None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._delete_initial( + resource_group_name=resource_group_name, + server_name=server_name, + private_endpoint_connection_name=private_endpoint_connection_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + def list_by_server( + self, resource_group_name: str, server_name: str, **kwargs: Any + ) -> ItemPaged["_models.PrivateEndpointConnection"]: + """Lists all private endpoint connections on a server. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :return: An iterator like instance of PrivateEndpointConnection + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.postgresqlflexibleservers.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.PrivateEndpointConnection]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_private_endpoint_connections_list_by_server_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize(List[_models.PrivateEndpointConnection], deserialized.get("value", [])) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class PrivateLinkResourcesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.postgresqlflexibleservers.PostgreSQLManagementClient`'s + :attr:`private_link_resources` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: PostgreSQLManagementClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get( + self, resource_group_name: str, server_name: str, group_name: str, **kwargs: Any + ) -> _models.PrivateLinkResource: + """Gets a private link resource for PostgreSQL server. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param group_name: The name of the private link resource. Required. + :type group_name: str + :return: PrivateLinkResource. The PrivateLinkResource is compatible with MutableMapping + :rtype: ~azure.mgmt.postgresqlflexibleservers.models.PrivateLinkResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.PrivateLinkResource] = kwargs.pop("cls", None) + + _request = build_private_link_resources_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + group_name=group_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() + else: + deserialized = _deserialize(_models.PrivateLinkResource, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list_by_server( + self, resource_group_name: str, server_name: str, **kwargs: Any + ) -> ItemPaged["_models.PrivateLinkResource"]: + """Gets the private link resources for PostgreSQL server. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :return: An iterator like instance of PrivateLinkResource + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.postgresqlflexibleservers.models.PrivateLinkResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.PrivateLinkResource]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_private_link_resources_list_by_server_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize(List[_models.PrivateLinkResource], deserialized.get("value", [])) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class VirtualEndpointsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.postgresqlflexibleservers.PostgreSQLManagementClient`'s + :attr:`virtual_endpoints` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: PostgreSQLManagementClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get( + self, resource_group_name: str, server_name: str, virtual_endpoint_name: str, **kwargs: Any + ) -> _models.VirtualEndpoint: + """Gets information about a pair of virtual endpoints. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param virtual_endpoint_name: Base name of the virtual endpoints. Required. + :type virtual_endpoint_name: str + :return: VirtualEndpoint. The VirtualEndpoint is compatible with MutableMapping + :rtype: ~azure.mgmt.postgresqlflexibleservers.models.VirtualEndpoint + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.VirtualEndpoint] = kwargs.pop("cls", None) + + _request = build_virtual_endpoints_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + virtual_endpoint_name=virtual_endpoint_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() + else: + deserialized = _deserialize(_models.VirtualEndpoint, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + def _create_initial( + self, + resource_group_name: str, + server_name: str, + virtual_endpoint_name: str, + parameters: Union[_models.VirtualEndpoint, JSON, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_virtual_endpoints_create_request( + resource_group_name=resource_group_name, + server_name=server_name, + virtual_endpoint_name=virtual_endpoint_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_create( + self, + resource_group_name: str, + server_name: str, + virtual_endpoint_name: str, + parameters: _models.VirtualEndpoint, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.VirtualEndpoint]: + """Creates a pair of virtual endpoints for a server. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param virtual_endpoint_name: Base name of the virtual endpoints. Required. + :type virtual_endpoint_name: str + :param parameters: Parameters required to create or update a pair of virtual endpoints. + Required. + :type parameters: ~azure.mgmt.postgresqlflexibleservers.models.VirtualEndpoint + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns VirtualEndpoint. The VirtualEndpoint is + compatible with MutableMapping + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.postgresqlflexibleservers.models.VirtualEndpoint] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create( + self, + resource_group_name: str, + server_name: str, + virtual_endpoint_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.VirtualEndpoint]: + """Creates a pair of virtual endpoints for a server. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param virtual_endpoint_name: Base name of the virtual endpoints. Required. + :type virtual_endpoint_name: str + :param parameters: Parameters required to create or update a pair of virtual endpoints. + Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns VirtualEndpoint. The VirtualEndpoint is + compatible with MutableMapping + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.postgresqlflexibleservers.models.VirtualEndpoint] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create( + self, + resource_group_name: str, + server_name: str, + virtual_endpoint_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.VirtualEndpoint]: + """Creates a pair of virtual endpoints for a server. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param virtual_endpoint_name: Base name of the virtual endpoints. Required. + :type virtual_endpoint_name: str + :param parameters: Parameters required to create or update a pair of virtual endpoints. + Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns VirtualEndpoint. The VirtualEndpoint is + compatible with MutableMapping + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.postgresqlflexibleservers.models.VirtualEndpoint] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create( + self, + resource_group_name: str, + server_name: str, + virtual_endpoint_name: str, + parameters: Union[_models.VirtualEndpoint, JSON, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.VirtualEndpoint]: + """Creates a pair of virtual endpoints for a server. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param virtual_endpoint_name: Base name of the virtual endpoints. Required. + :type virtual_endpoint_name: str + :param parameters: Parameters required to create or update a pair of virtual endpoints. Is one + of the following types: VirtualEndpoint, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.postgresqlflexibleservers.models.VirtualEndpoint or JSON or + IO[bytes] + :return: An instance of LROPoller that returns VirtualEndpoint. The VirtualEndpoint is + compatible with MutableMapping + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.postgresqlflexibleservers.models.VirtualEndpoint] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.VirtualEndpoint] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._create_initial( + resource_group_name=resource_group_name, + server_name=server_name, + virtual_endpoint_name=virtual_endpoint_name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response_headers = {} + response = pipeline_response.http_response + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = _deserialize(_models.VirtualEndpoint, response.json()) + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.VirtualEndpoint].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.VirtualEndpoint]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + def _update_initial( + self, + resource_group_name: str, + server_name: str, + virtual_endpoint_name: str, + parameters: Union[_models.VirtualEndpointResourceForPatch, JSON, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_virtual_endpoints_update_request( + resource_group_name=resource_group_name, + server_name=server_name, + virtual_endpoint_name=virtual_endpoint_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_update( + self, + resource_group_name: str, + server_name: str, + virtual_endpoint_name: str, + parameters: _models.VirtualEndpointResourceForPatch, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.VirtualEndpoint]: + """Updates a pair of virtual endpoints for a server. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param virtual_endpoint_name: Base name of the virtual endpoints. Required. + :type virtual_endpoint_name: str + :param parameters: Parameters required to update a pair of virtual endpoints. Required. + :type parameters: ~azure.mgmt.postgresqlflexibleservers.models.VirtualEndpointResourceForPatch + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns VirtualEndpoint. The VirtualEndpoint is + compatible with MutableMapping + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.postgresqlflexibleservers.models.VirtualEndpoint] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + server_name: str, + virtual_endpoint_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.VirtualEndpoint]: + """Updates a pair of virtual endpoints for a server. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param virtual_endpoint_name: Base name of the virtual endpoints. Required. + :type virtual_endpoint_name: str + :param parameters: Parameters required to update a pair of virtual endpoints. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns VirtualEndpoint. The VirtualEndpoint is + compatible with MutableMapping + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.postgresqlflexibleservers.models.VirtualEndpoint] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + server_name: str, + virtual_endpoint_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.VirtualEndpoint]: + """Updates a pair of virtual endpoints for a server. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param virtual_endpoint_name: Base name of the virtual endpoints. Required. + :type virtual_endpoint_name: str + :param parameters: Parameters required to update a pair of virtual endpoints. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns VirtualEndpoint. The VirtualEndpoint is + compatible with MutableMapping + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.postgresqlflexibleservers.models.VirtualEndpoint] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_update( + self, + resource_group_name: str, + server_name: str, + virtual_endpoint_name: str, + parameters: Union[_models.VirtualEndpointResourceForPatch, JSON, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.VirtualEndpoint]: + """Updates a pair of virtual endpoints for a server. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param virtual_endpoint_name: Base name of the virtual endpoints. Required. + :type virtual_endpoint_name: str + :param parameters: Parameters required to update a pair of virtual endpoints. Is one of the + following types: VirtualEndpointResourceForPatch, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.postgresqlflexibleservers.models.VirtualEndpointResourceForPatch + or JSON or IO[bytes] + :return: An instance of LROPoller that returns VirtualEndpoint. The VirtualEndpoint is + compatible with MutableMapping + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.postgresqlflexibleservers.models.VirtualEndpoint] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.VirtualEndpoint] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._update_initial( + resource_group_name=resource_group_name, + server_name=server_name, + virtual_endpoint_name=virtual_endpoint_name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response_headers = {} + response = pipeline_response.http_response + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = _deserialize(_models.VirtualEndpoint, response.json()) + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.VirtualEndpoint].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.VirtualEndpoint]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + def _delete_initial( + self, resource_group_name: str, server_name: str, virtual_endpoint_name: str, **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_virtual_endpoints_delete_request( + resource_group_name=resource_group_name, + server_name=server_name, + virtual_endpoint_name=virtual_endpoint_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [202, 204]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def begin_delete( + self, resource_group_name: str, server_name: str, virtual_endpoint_name: str, **kwargs: Any + ) -> LROPoller[None]: + """Deletes a pair of virtual endpoints. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param virtual_endpoint_name: Base name of the virtual endpoints. Required. + :type virtual_endpoint_name: str + :return: An instance of LROPoller that returns None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._delete_initial( + resource_group_name=resource_group_name, + server_name=server_name, + virtual_endpoint_name=virtual_endpoint_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + def list_by_server( + self, resource_group_name: str, server_name: str, **kwargs: Any + ) -> ItemPaged["_models.VirtualEndpoint"]: + """Lists pair of virtual endpoints associated to a server. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :return: An iterator like instance of VirtualEndpoint + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.postgresqlflexibleservers.models.VirtualEndpoint] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.VirtualEndpoint]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_virtual_endpoints_list_by_server_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize(List[_models.VirtualEndpoint], deserialized.get("value", [])) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class AdministratorsMicrosoftEntraOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.postgresqlflexibleservers.PostgreSQLManagementClient`'s + :attr:`administrators_microsoft_entra` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: PostgreSQLManagementClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get( + self, resource_group_name: str, server_name: str, object_id: str, **kwargs: Any + ) -> _models.AdministratorMicrosoftEntra: + """Gets information about a server administrator associated to a Microsoft Entra principal. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param object_id: Object identifier of the Microsoft Entra principal. Required. + :type object_id: str + :return: AdministratorMicrosoftEntra. The AdministratorMicrosoftEntra is compatible with + MutableMapping + :rtype: ~azure.mgmt.postgresqlflexibleservers.models.AdministratorMicrosoftEntra + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.AdministratorMicrosoftEntra] = kwargs.pop("cls", None) + + _request = build_administrators_microsoft_entra_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + object_id=object_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() + else: + deserialized = _deserialize(_models.AdministratorMicrosoftEntra, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + def _create_or_update_initial( + self, + resource_group_name: str, + server_name: str, + object_id: str, + parameters: Union[_models.AdministratorMicrosoftEntraAdd, JSON, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_administrators_microsoft_entra_create_or_update_request( + resource_group_name=resource_group_name, + server_name=server_name, + object_id=object_id, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + object_id: str, + parameters: _models.AdministratorMicrosoftEntraAdd, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.AdministratorMicrosoftEntra]: + """Creates a new server administrator associated to a Microsoft Entra principal. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param object_id: Object identifier of the Microsoft Entra principal. Required. + :type object_id: str + :param parameters: Required parameters for adding a server administrator associated to a + Microsoft Entra principal. Required. + :type parameters: ~azure.mgmt.postgresqlflexibleservers.models.AdministratorMicrosoftEntraAdd + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns AdministratorMicrosoftEntra. The + AdministratorMicrosoftEntra is compatible with MutableMapping + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.postgresqlflexibleservers.models.AdministratorMicrosoftEntra] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + object_id: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.AdministratorMicrosoftEntra]: + """Creates a new server administrator associated to a Microsoft Entra principal. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param object_id: Object identifier of the Microsoft Entra principal. Required. + :type object_id: str + :param parameters: Required parameters for adding a server administrator associated to a + Microsoft Entra principal. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns AdministratorMicrosoftEntra. The + AdministratorMicrosoftEntra is compatible with MutableMapping + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.postgresqlflexibleservers.models.AdministratorMicrosoftEntra] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + object_id: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.AdministratorMicrosoftEntra]: + """Creates a new server administrator associated to a Microsoft Entra principal. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param object_id: Object identifier of the Microsoft Entra principal. Required. + :type object_id: str + :param parameters: Required parameters for adding a server administrator associated to a + Microsoft Entra principal. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns AdministratorMicrosoftEntra. The + AdministratorMicrosoftEntra is compatible with MutableMapping + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.postgresqlflexibleservers.models.AdministratorMicrosoftEntra] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + object_id: str, + parameters: Union[_models.AdministratorMicrosoftEntraAdd, JSON, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.AdministratorMicrosoftEntra]: + """Creates a new server administrator associated to a Microsoft Entra principal. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param object_id: Object identifier of the Microsoft Entra principal. Required. + :type object_id: str + :param parameters: Required parameters for adding a server administrator associated to a + Microsoft Entra principal. Is one of the following types: AdministratorMicrosoftEntraAdd, JSON, + IO[bytes] Required. + :type parameters: ~azure.mgmt.postgresqlflexibleservers.models.AdministratorMicrosoftEntraAdd + or JSON or IO[bytes] + :return: An instance of LROPoller that returns AdministratorMicrosoftEntra. The + AdministratorMicrosoftEntra is compatible with MutableMapping + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.postgresqlflexibleservers.models.AdministratorMicrosoftEntra] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.AdministratorMicrosoftEntra] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._create_or_update_initial( + resource_group_name=resource_group_name, + server_name=server_name, + object_id=object_id, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response_headers = {} + response = pipeline_response.http_response + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = _deserialize(_models.AdministratorMicrosoftEntra, response.json()) + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.AdministratorMicrosoftEntra].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.AdministratorMicrosoftEntra]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + def _delete_initial( + self, resource_group_name: str, server_name: str, object_id: str, **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_administrators_microsoft_entra_delete_request( + resource_group_name=resource_group_name, + server_name=server_name, + object_id=object_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [202, 204]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def begin_delete( + self, resource_group_name: str, server_name: str, object_id: str, **kwargs: Any + ) -> LROPoller[None]: + """Deletes an existing server administrator associated to a Microsoft Entra principal. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param object_id: Object identifier of the Microsoft Entra principal. Required. + :type object_id: str + :return: An instance of LROPoller that returns None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._delete_initial( + resource_group_name=resource_group_name, + server_name=server_name, + object_id=object_id, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + def list_by_server( + self, resource_group_name: str, server_name: str, **kwargs: Any + ) -> ItemPaged["_models.AdministratorMicrosoftEntra"]: + """List all server administrators associated to a Microsoft Entra principal. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :return: An iterator like instance of AdministratorMicrosoftEntra + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.postgresqlflexibleservers.models.AdministratorMicrosoftEntra] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.AdministratorMicrosoftEntra]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_administrators_microsoft_entra_list_by_server_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize(List[_models.AdministratorMicrosoftEntra], deserialized.get("value", [])) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class CapabilitiesByServerOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.postgresqlflexibleservers.PostgreSQLManagementClient`'s + :attr:`capabilities_by_server` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: PostgreSQLManagementClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list(self, resource_group_name: str, server_name: str, **kwargs: Any) -> ItemPaged["_models.Capability"]: + """Lists the capabilities available for a given server. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :return: An iterator like instance of Capability + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.postgresqlflexibleservers.models.Capability] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.Capability]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_capabilities_by_server_list_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize(List[_models.Capability], deserialized.get("value", [])) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class CapturedLogsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.postgresqlflexibleservers.PostgreSQLManagementClient`'s + :attr:`captured_logs` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: PostgreSQLManagementClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list_by_server( + self, resource_group_name: str, server_name: str, **kwargs: Any + ) -> ItemPaged["_models.CapturedLog"]: + """Lists all captured logs for download in a server. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :return: An iterator like instance of CapturedLog + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.postgresqlflexibleservers.models.CapturedLog] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.CapturedLog]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_captured_logs_list_by_server_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize(List[_models.CapturedLog], deserialized.get("value", [])) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class BackupsLongTermRetentionOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.postgresqlflexibleservers.PostgreSQLManagementClient`'s + :attr:`backups_long_term_retention` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: PostgreSQLManagementClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @overload + def check_prerequisites( + self, + resource_group_name: str, + server_name: str, + parameters: _models.LtrPreBackupRequest, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.LtrPreBackupResponse: + """Performs all checks required for a long term retention backup operation to succeed. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param parameters: Request body for operation. Required. + :type parameters: ~azure.mgmt.postgresqlflexibleservers.models.LtrPreBackupRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: LtrPreBackupResponse. The LtrPreBackupResponse is compatible with MutableMapping + :rtype: ~azure.mgmt.postgresqlflexibleservers.models.LtrPreBackupResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def check_prerequisites( + self, + resource_group_name: str, + server_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.LtrPreBackupResponse: + """Performs all checks required for a long term retention backup operation to succeed. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param parameters: Request body for operation. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: LtrPreBackupResponse. The LtrPreBackupResponse is compatible with MutableMapping + :rtype: ~azure.mgmt.postgresqlflexibleservers.models.LtrPreBackupResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def check_prerequisites( + self, + resource_group_name: str, + server_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.LtrPreBackupResponse: + """Performs all checks required for a long term retention backup operation to succeed. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param parameters: Request body for operation. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: LtrPreBackupResponse. The LtrPreBackupResponse is compatible with MutableMapping + :rtype: ~azure.mgmt.postgresqlflexibleservers.models.LtrPreBackupResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def check_prerequisites( + self, + resource_group_name: str, + server_name: str, + parameters: Union[_models.LtrPreBackupRequest, JSON, IO[bytes]], + **kwargs: Any + ) -> _models.LtrPreBackupResponse: + """Performs all checks required for a long term retention backup operation to succeed. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param parameters: Request body for operation. Is one of the following types: + LtrPreBackupRequest, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.postgresqlflexibleservers.models.LtrPreBackupRequest or JSON or + IO[bytes] + :return: LtrPreBackupResponse. The LtrPreBackupResponse is compatible with MutableMapping + :rtype: ~azure.mgmt.postgresqlflexibleservers.models.LtrPreBackupResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.LtrPreBackupResponse] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_backups_long_term_retention_check_prerequisites_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["x-ms-request-id"] = self._deserialize("str", response.headers.get("x-ms-request-id")) + + if _stream: + deserialized = response.iter_bytes() + else: + deserialized = _deserialize(_models.LtrPreBackupResponse, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + def _start_initial( + self, + resource_group_name: str, + server_name: str, + parameters: Union[_models.BackupsLongTermRetentionRequest, JSON, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_backups_long_term_retention_start_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 200: + response_headers["x-ms-request-id"] = self._deserialize("str", response.headers.get("x-ms-request-id")) + + if response.status_code == 202: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + response_headers["x-ms-request-id"] = self._deserialize("str", response.headers.get("x-ms-request-id")) + + deserialized = response.iter_bytes() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_start( + self, + resource_group_name: str, + server_name: str, + parameters: _models.BackupsLongTermRetentionRequest, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.BackupsLongTermRetentionResponse]: + """Initiates a long term retention backup. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param parameters: Request body for operation. Required. + :type parameters: ~azure.mgmt.postgresqlflexibleservers.models.BackupsLongTermRetentionRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns BackupsLongTermRetentionResponse. The + BackupsLongTermRetentionResponse is compatible with MutableMapping + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.postgresqlflexibleservers.models.BackupsLongTermRetentionResponse] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_start( + self, + resource_group_name: str, + server_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.BackupsLongTermRetentionResponse]: + """Initiates a long term retention backup. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param parameters: Request body for operation. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns BackupsLongTermRetentionResponse. The + BackupsLongTermRetentionResponse is compatible with MutableMapping + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.postgresqlflexibleservers.models.BackupsLongTermRetentionResponse] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_start( + self, + resource_group_name: str, + server_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.BackupsLongTermRetentionResponse]: + """Initiates a long term retention backup. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param parameters: Request body for operation. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns BackupsLongTermRetentionResponse. The + BackupsLongTermRetentionResponse is compatible with MutableMapping + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.postgresqlflexibleservers.models.BackupsLongTermRetentionResponse] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_start( + self, + resource_group_name: str, + server_name: str, + parameters: Union[_models.BackupsLongTermRetentionRequest, JSON, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.BackupsLongTermRetentionResponse]: + """Initiates a long term retention backup. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param parameters: Request body for operation. Is one of the following types: + BackupsLongTermRetentionRequest, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.postgresqlflexibleservers.models.BackupsLongTermRetentionRequest + or JSON or IO[bytes] + :return: An instance of LROPoller that returns BackupsLongTermRetentionResponse. The + BackupsLongTermRetentionResponse is compatible with MutableMapping + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.postgresqlflexibleservers.models.BackupsLongTermRetentionResponse] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.BackupsLongTermRetentionResponse] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._start_initial( + resource_group_name=resource_group_name, + server_name=server_name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response_headers = {} + response = pipeline_response.http_response + response_headers["x-ms-request-id"] = self._deserialize("str", response.headers.get("x-ms-request-id")) + + deserialized = _deserialize(_models.BackupsLongTermRetentionResponse, response.json()) + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.BackupsLongTermRetentionResponse].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.BackupsLongTermRetentionResponse]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + @distributed_trace + def get( + self, resource_group_name: str, server_name: str, backup_name: str, **kwargs: Any + ) -> _models.BackupsLongTermRetentionOperation: + """Gets the results of a long retention backup operation for a server. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param backup_name: The name of the backup. Required. + :type backup_name: str + :return: BackupsLongTermRetentionOperation. The BackupsLongTermRetentionOperation is compatible + with MutableMapping + :rtype: ~azure.mgmt.postgresqlflexibleservers.models.BackupsLongTermRetentionOperation + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.BackupsLongTermRetentionOperation] = kwargs.pop("cls", None) + + _request = build_backups_long_term_retention_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + backup_name=backup_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() + else: + deserialized = _deserialize(_models.BackupsLongTermRetentionOperation, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list_by_server( + self, resource_group_name: str, server_name: str, **kwargs: Any + ) -> ItemPaged["_models.BackupsLongTermRetentionOperation"]: + """Lists the results of the long term retention backup operations for a server. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :return: An iterator like instance of BackupsLongTermRetentionOperation + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.postgresqlflexibleservers.models.BackupsLongTermRetentionOperation] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.BackupsLongTermRetentionOperation]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_backups_long_term_retention_list_by_server_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize(List[_models.BackupsLongTermRetentionOperation], deserialized.get("value", [])) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class ReplicasOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.postgresqlflexibleservers.PostgreSQLManagementClient`'s + :attr:`replicas` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: PostgreSQLManagementClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list_by_server(self, resource_group_name: str, server_name: str, **kwargs: Any) -> ItemPaged["_models.Server"]: + """Lists all read replicas of a server. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :return: An iterator like instance of Server + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.postgresqlflexibleservers.models.Server] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.Server]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_replicas_list_by_server_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize(List[_models.Server], deserialized.get("value", [])) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class AdvancedThreatProtectionSettingsOperations: # pylint: disable=name-too-long + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.postgresqlflexibleservers.PostgreSQLManagementClient`'s + :attr:`advanced_threat_protection_settings` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: PostgreSQLManagementClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get( + self, + resource_group_name: str, + server_name: str, + threat_protection_name: Union[str, _models.ThreatProtectionName], + **kwargs: Any + ) -> _models.AdvancedThreatProtectionSettingsModel: + """Gets state of advanced threat protection settings for a server. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param threat_protection_name: Name of the advanced threat protection settings. "Default" + Required. + :type threat_protection_name: str or + ~azure.mgmt.postgresqlflexibleservers.models.ThreatProtectionName + :return: AdvancedThreatProtectionSettingsModel. The AdvancedThreatProtectionSettingsModel is + compatible with MutableMapping + :rtype: ~azure.mgmt.postgresqlflexibleservers.models.AdvancedThreatProtectionSettingsModel + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.AdvancedThreatProtectionSettingsModel] = kwargs.pop("cls", None) + + _request = build_advanced_threat_protection_settings_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + threat_protection_name=threat_protection_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() + else: + deserialized = _deserialize(_models.AdvancedThreatProtectionSettingsModel, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list_by_server( + self, resource_group_name: str, server_name: str, **kwargs: Any + ) -> ItemPaged["_models.AdvancedThreatProtectionSettingsModel"]: + """Lists state of advanced threat protection settings for a server. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :return: An iterator like instance of AdvancedThreatProtectionSettingsModel + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.postgresqlflexibleservers.models.AdvancedThreatProtectionSettingsModel] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.AdvancedThreatProtectionSettingsModel]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_advanced_threat_protection_settings_list_by_server_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.AdvancedThreatProtectionSettingsModel], deserialized.get("value", []) + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class ServerThreatProtectionSettingsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.postgresqlflexibleservers.PostgreSQLManagementClient`'s + :attr:`server_threat_protection_settings` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: PostgreSQLManagementClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + def _create_or_update_initial( + self, + resource_group_name: str, + server_name: str, + threat_protection_name: Union[str, _models.ThreatProtectionName], + parameters: Union[_models.AdvancedThreatProtectionSettingsModel, JSON, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_server_threat_protection_settings_create_or_update_request( + resource_group_name=resource_group_name, + server_name=server_name, + threat_protection_name=threat_protection_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + threat_protection_name: Union[str, _models.ThreatProtectionName], + parameters: _models.AdvancedThreatProtectionSettingsModel, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.AdvancedThreatProtectionSettingsModel]: + """Creates or updates a server's Advanced Threat Protection settings. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param threat_protection_name: Name of the advanced threat protection settings. "Default" + Required. + :type threat_protection_name: str or + ~azure.mgmt.postgresqlflexibleservers.models.ThreatProtectionName + :param parameters: The Advanced Threat Protection state for the server. Required. + :type parameters: + ~azure.mgmt.postgresqlflexibleservers.models.AdvancedThreatProtectionSettingsModel + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns AdvancedThreatProtectionSettingsModel. The + AdvancedThreatProtectionSettingsModel is compatible with MutableMapping + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.postgresqlflexibleservers.models.AdvancedThreatProtectionSettingsModel] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + threat_protection_name: Union[str, _models.ThreatProtectionName], + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.AdvancedThreatProtectionSettingsModel]: + """Creates or updates a server's Advanced Threat Protection settings. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param threat_protection_name: Name of the advanced threat protection settings. "Default" + Required. + :type threat_protection_name: str or + ~azure.mgmt.postgresqlflexibleservers.models.ThreatProtectionName + :param parameters: The Advanced Threat Protection state for the server. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns AdvancedThreatProtectionSettingsModel. The + AdvancedThreatProtectionSettingsModel is compatible with MutableMapping + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.postgresqlflexibleservers.models.AdvancedThreatProtectionSettingsModel] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + threat_protection_name: Union[str, _models.ThreatProtectionName], + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.AdvancedThreatProtectionSettingsModel]: + """Creates or updates a server's Advanced Threat Protection settings. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param threat_protection_name: Name of the advanced threat protection settings. "Default" + Required. + :type threat_protection_name: str or + ~azure.mgmt.postgresqlflexibleservers.models.ThreatProtectionName + :param parameters: The Advanced Threat Protection state for the server. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns AdvancedThreatProtectionSettingsModel. The + AdvancedThreatProtectionSettingsModel is compatible with MutableMapping + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.postgresqlflexibleservers.models.AdvancedThreatProtectionSettingsModel] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + threat_protection_name: Union[str, _models.ThreatProtectionName], + parameters: Union[_models.AdvancedThreatProtectionSettingsModel, JSON, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.AdvancedThreatProtectionSettingsModel]: + """Creates or updates a server's Advanced Threat Protection settings. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param threat_protection_name: Name of the advanced threat protection settings. "Default" + Required. + :type threat_protection_name: str or + ~azure.mgmt.postgresqlflexibleservers.models.ThreatProtectionName + :param parameters: The Advanced Threat Protection state for the server. Is one of the following + types: AdvancedThreatProtectionSettingsModel, JSON, IO[bytes] Required. + :type parameters: + ~azure.mgmt.postgresqlflexibleservers.models.AdvancedThreatProtectionSettingsModel or JSON or + IO[bytes] + :return: An instance of LROPoller that returns AdvancedThreatProtectionSettingsModel. The + AdvancedThreatProtectionSettingsModel is compatible with MutableMapping + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.postgresqlflexibleservers.models.AdvancedThreatProtectionSettingsModel] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.AdvancedThreatProtectionSettingsModel] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._create_or_update_initial( + resource_group_name=resource_group_name, + server_name=server_name, + threat_protection_name=threat_protection_name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response_headers = {} + response = pipeline_response.http_response + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = _deserialize(_models.AdvancedThreatProtectionSettingsModel, response.json()) + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.AdvancedThreatProtectionSettingsModel].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.AdvancedThreatProtectionSettingsModel]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + +class BackupsAutomaticAndOnDemandOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.postgresqlflexibleservers.PostgreSQLManagementClient`'s + :attr:`backups_automatic_and_on_demand` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: PostgreSQLManagementClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get( + self, resource_group_name: str, server_name: str, backup_name: str, **kwargs: Any + ) -> _models.BackupAutomaticAndOnDemand: + """Gets information of an on demand backup, given its name. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param backup_name: Name of the backup. Required. + :type backup_name: str + :return: BackupAutomaticAndOnDemand. The BackupAutomaticAndOnDemand is compatible with + MutableMapping + :rtype: ~azure.mgmt.postgresqlflexibleservers.models.BackupAutomaticAndOnDemand + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.BackupAutomaticAndOnDemand] = kwargs.pop("cls", None) + + _request = build_backups_automatic_and_on_demand_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + backup_name=backup_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() + else: + deserialized = _deserialize(_models.BackupAutomaticAndOnDemand, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + def _create_initial( + self, resource_group_name: str, server_name: str, backup_name: str, **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_backups_automatic_and_on_demand_create_request( + resource_group_name=resource_group_name, + server_name=server_name, + backup_name=backup_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def begin_create( + self, resource_group_name: str, server_name: str, backup_name: str, **kwargs: Any + ) -> LROPoller[_models.BackupAutomaticAndOnDemand]: + """Creates an on demand backup of a server. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param backup_name: Name of the backup. Required. + :type backup_name: str + :return: An instance of LROPoller that returns BackupAutomaticAndOnDemand. The + BackupAutomaticAndOnDemand is compatible with MutableMapping + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.postgresqlflexibleservers.models.BackupAutomaticAndOnDemand] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.BackupAutomaticAndOnDemand] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._create_initial( + resource_group_name=resource_group_name, + server_name=server_name, + backup_name=backup_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response_headers = {} + response = pipeline_response.http_response + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = _deserialize(_models.BackupAutomaticAndOnDemand, response.json()) + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.BackupAutomaticAndOnDemand].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.BackupAutomaticAndOnDemand]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + def _delete_initial( + self, resource_group_name: str, server_name: str, backup_name: str, **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_backups_automatic_and_on_demand_delete_request( + resource_group_name=resource_group_name, + server_name=server_name, + backup_name=backup_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [202, 204]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def begin_delete( + self, resource_group_name: str, server_name: str, backup_name: str, **kwargs: Any + ) -> LROPoller[None]: + """Deletes a specific backup, given its name. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param backup_name: Name of the backup. Required. + :type backup_name: str + :return: An instance of LROPoller that returns None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._delete_initial( + resource_group_name=resource_group_name, + server_name=server_name, + backup_name=backup_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + def list_by_server( + self, resource_group_name: str, server_name: str, **kwargs: Any + ) -> ItemPaged["_models.BackupAutomaticAndOnDemand"]: + """Lists all available backups of a server. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :return: An iterator like instance of BackupAutomaticAndOnDemand + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.postgresqlflexibleservers.models.BackupAutomaticAndOnDemand] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.BackupAutomaticAndOnDemand]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_backups_automatic_and_on_demand_list_by_server_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize(List[_models.BackupAutomaticAndOnDemand], deserialized.get("value", [])) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class TuningOptionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.postgresqlflexibleservers.PostgreSQLManagementClient`'s + :attr:`tuning_options` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: PostgreSQLManagementClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get( + self, + resource_group_name: str, + server_name: str, + tuning_option: Union[str, _models.TuningOptionParameterEnum], + **kwargs: Any + ) -> _models.TuningOptions: + """Gets the tuning options of a server. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param tuning_option: The name of the tuning option. Known values are: "index" and "table". + Required. + :type tuning_option: str or + ~azure.mgmt.postgresqlflexibleservers.models.TuningOptionParameterEnum + :return: TuningOptions. The TuningOptions is compatible with MutableMapping + :rtype: ~azure.mgmt.postgresqlflexibleservers.models.TuningOptions + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.TuningOptions] = kwargs.pop("cls", None) + + _request = build_tuning_options_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + tuning_option=tuning_option, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() + else: + deserialized = _deserialize(_models.TuningOptions, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list_by_server( + self, resource_group_name: str, server_name: str, **kwargs: Any + ) -> ItemPaged["_models.TuningOptions"]: + """Lists the tuning options of a server. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :return: An iterator like instance of TuningOptions + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.postgresqlflexibleservers.models.TuningOptions] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.TuningOptions]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_tuning_options_list_by_server_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize(List[_models.TuningOptions], deserialized.get("value", [])) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def list_recommendations( + self, + resource_group_name: str, + server_name: str, + tuning_option: Union[str, _models.TuningOptionParameterEnum], + *, + recommendation_type: Optional[Union[str, _models.RecommendationTypeParameterEnum]] = None, + **kwargs: Any + ) -> ItemPaged["_models.ObjectRecommendation"]: + """Lists available object recommendations. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param tuning_option: The name of the tuning option. Known values are: "index" and "table". + Required. + :type tuning_option: str or + ~azure.mgmt.postgresqlflexibleservers.models.TuningOptionParameterEnum + :keyword recommendation_type: Recommendations list filter. Retrieves recommendations based on + type. Known values are: "CreateIndex", "DropIndex", "ReIndex", "AnalyzeTable", and + "VacuumTable". Default value is None. + :paramtype recommendation_type: str or + ~azure.mgmt.postgresqlflexibleservers.models.RecommendationTypeParameterEnum + :return: An iterator like instance of ObjectRecommendation + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.postgresqlflexibleservers.models.ObjectRecommendation] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.ObjectRecommendation]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_tuning_options_list_recommendations_request( + resource_group_name=resource_group_name, + server_name=server_name, + tuning_option=tuning_option, + subscription_id=self._config.subscription_id, + recommendation_type=recommendation_type, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize(List[_models.ObjectRecommendation], deserialized.get("value", [])) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class CapabilitiesByLocationOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.postgresqlflexibleservers.PostgreSQLManagementClient`'s + :attr:`capabilities_by_location` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: PostgreSQLManagementClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list(self, location_name: str, **kwargs: Any) -> ItemPaged["_models.Capability"]: + """Lists the capabilities available in a given location for a specific subscription. + + :param location_name: The name of the location. Required. + :type location_name: str + :return: An iterator like instance of Capability + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.postgresqlflexibleservers.models.Capability] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.Capability]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_capabilities_by_location_list_request( + location_name=location_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize(List[_models.Capability], deserialized.get("value", [])) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class NameAvailabilityOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.postgresqlflexibleservers.PostgreSQLManagementClient`'s + :attr:`name_availability` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: PostgreSQLManagementClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @overload + def check_globally( + self, parameters: _models.CheckNameAvailabilityRequest, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.NameAvailabilityModel: + """Checks the validity and availability of the given name, to assign it to a new server or to use + it as the base name of a new pair of virtual endpoints. + + :param parameters: The request body. Required. + :type parameters: ~azure.mgmt.postgresqlflexibleservers.models.CheckNameAvailabilityRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: NameAvailabilityModel. The NameAvailabilityModel is compatible with MutableMapping + :rtype: ~azure.mgmt.postgresqlflexibleservers.models.NameAvailabilityModel + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def check_globally( + self, parameters: JSON, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.NameAvailabilityModel: + """Checks the validity and availability of the given name, to assign it to a new server or to use + it as the base name of a new pair of virtual endpoints. + + :param parameters: The request body. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: NameAvailabilityModel. The NameAvailabilityModel is compatible with MutableMapping + :rtype: ~azure.mgmt.postgresqlflexibleservers.models.NameAvailabilityModel + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def check_globally( + self, parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any + ) -> _models.NameAvailabilityModel: + """Checks the validity and availability of the given name, to assign it to a new server or to use + it as the base name of a new pair of virtual endpoints. + + :param parameters: The request body. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: NameAvailabilityModel. The NameAvailabilityModel is compatible with MutableMapping + :rtype: ~azure.mgmt.postgresqlflexibleservers.models.NameAvailabilityModel + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def check_globally( + self, parameters: Union[_models.CheckNameAvailabilityRequest, JSON, IO[bytes]], **kwargs: Any + ) -> _models.NameAvailabilityModel: + """Checks the validity and availability of the given name, to assign it to a new server or to use + it as the base name of a new pair of virtual endpoints. + + :param parameters: The request body. Is one of the following types: + CheckNameAvailabilityRequest, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.postgresqlflexibleservers.models.CheckNameAvailabilityRequest or + JSON or IO[bytes] + :return: NameAvailabilityModel. The NameAvailabilityModel is compatible with MutableMapping + :rtype: ~azure.mgmt.postgresqlflexibleservers.models.NameAvailabilityModel + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.NameAvailabilityModel] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_name_availability_check_globally_request( + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() + else: + deserialized = _deserialize(_models.NameAvailabilityModel, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def check_with_location( + self, + location_name: str, + parameters: _models.CheckNameAvailabilityRequest, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.NameAvailabilityModel: + """Check the availability of name for resource. + + :param location_name: The name of the location. Required. + :type location_name: str + :param parameters: The request body. Required. + :type parameters: ~azure.mgmt.postgresqlflexibleservers.models.CheckNameAvailabilityRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: NameAvailabilityModel. The NameAvailabilityModel is compatible with MutableMapping + :rtype: ~azure.mgmt.postgresqlflexibleservers.models.NameAvailabilityModel + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def check_with_location( + self, location_name: str, parameters: JSON, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.NameAvailabilityModel: + """Check the availability of name for resource. + + :param location_name: The name of the location. Required. + :type location_name: str + :param parameters: The request body. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: NameAvailabilityModel. The NameAvailabilityModel is compatible with MutableMapping + :rtype: ~azure.mgmt.postgresqlflexibleservers.models.NameAvailabilityModel + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def check_with_location( + self, location_name: str, parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any + ) -> _models.NameAvailabilityModel: + """Check the availability of name for resource. + + :param location_name: The name of the location. Required. + :type location_name: str + :param parameters: The request body. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: NameAvailabilityModel. The NameAvailabilityModel is compatible with MutableMapping + :rtype: ~azure.mgmt.postgresqlflexibleservers.models.NameAvailabilityModel + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def check_with_location( + self, + location_name: str, + parameters: Union[_models.CheckNameAvailabilityRequest, JSON, IO[bytes]], + **kwargs: Any + ) -> _models.NameAvailabilityModel: + """Check the availability of name for resource. + + :param location_name: The name of the location. Required. + :type location_name: str + :param parameters: The request body. Is one of the following types: + CheckNameAvailabilityRequest, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.postgresqlflexibleservers.models.CheckNameAvailabilityRequest or + JSON or IO[bytes] + :return: NameAvailabilityModel. The NameAvailabilityModel is compatible with MutableMapping + :rtype: ~azure.mgmt.postgresqlflexibleservers.models.NameAvailabilityModel + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.NameAvailabilityModel] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_name_availability_check_with_location_request( + location_name=location_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() + else: + deserialized = _deserialize(_models.NameAvailabilityModel, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + +class PrivateDnsZoneSuffixOperations: """ + .. warning:: + **DO NOT** instantiate this class directly. - models = _models + Instead, you should access the following operations through + :class:`~azure.mgmt.postgresqlflexibleservers.PostgreSQLManagementClient`'s + :attr:`private_dns_zone_suffix` attribute. + """ def __init__(self, *args, **kwargs) -> None: input_args = list(args) @@ -78,18 +11109,100 @@ def __init__(self, *args, **kwargs) -> None: self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def list(self, **kwargs: Any) -> ItemPaged["_models.Operation"]: - """Lists all available REST API operations. + def get(self, **kwargs: Any) -> str: + """Gets the private DNS zone suffix. - :return: An iterator like instance of either Operation or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.postgresqlflexibleservers.models.Operation] + :return: str + :rtype: str + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[str] = kwargs.pop("cls", None) + + _request = build_private_dns_zone_suffix_get_request( + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() + else: + deserialized = _deserialize(str, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + +class QuotaUsagesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.postgresqlflexibleservers.PostgreSQLManagementClient`'s + :attr:`quota_usages` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: PostgreSQLManagementClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list(self, location_name: str, **kwargs: Any) -> ItemPaged["_models.QuotaUsage"]: + """Get quota usages at specified location in a given subscription. + + :param location_name: The name of the location. Required. + :type location_name: str + :return: An iterator like instance of QuotaUsage + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.postgresqlflexibleservers.models.QuotaUsage] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + _params = kwargs.pop("params", {}) or {} - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.OperationList] = kwargs.pop("cls", None) + cls: ClsType[List[_models.QuotaUsage]] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -102,12 +11215,19 @@ def list(self, **kwargs: Any) -> ItemPaged["_models.Operation"]: def prepare_request(next_link=None): if not next_link: - _request = build_list_request( - api_version=api_version, + _request = build_quota_usages_list_request( + location_name=location_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, headers=_headers, params=_params, ) - _request.url = self._client.format_url(_request.url) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) else: # make call to next link with the client's api-version @@ -122,16 +11242,21 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + return _request def extract_data(pipeline_response): - deserialized = self._deserialize("OperationList", pipeline_response) - list_of_elem = deserialized.value + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize(List[_models.QuotaUsage], deserialized.get("value", [])) if cls: list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) + return deserialized.get("nextLink") or None, iter(list_of_elem) def get_next(next_link=None): _request = prepare_request(next_link) @@ -144,12 +11269,181 @@ def get_next(next_link=None): if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize( + error = _failsafe_deserialize( _models.ErrorResponse, - pipeline_response, + response, ) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response return ItemPaged(get_next, extract_data) + + +class VirtualNetworkSubnetUsageOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.postgresqlflexibleservers.PostgreSQLManagementClient`'s + :attr:`virtual_network_subnet_usage` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: PostgreSQLManagementClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @overload + def list( + self, + location_name: str, + parameters: _models.VirtualNetworkSubnetUsageParameter, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.VirtualNetworkSubnetUsageModel: + """Lists the virtual network subnet usage for a given virtual network. + + :param location_name: The name of the location. Required. + :type location_name: str + :param parameters: The request body. Required. + :type parameters: + ~azure.mgmt.postgresqlflexibleservers.models.VirtualNetworkSubnetUsageParameter + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: VirtualNetworkSubnetUsageModel. The VirtualNetworkSubnetUsageModel is compatible with + MutableMapping + :rtype: ~azure.mgmt.postgresqlflexibleservers.models.VirtualNetworkSubnetUsageModel + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def list( + self, location_name: str, parameters: JSON, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.VirtualNetworkSubnetUsageModel: + """Lists the virtual network subnet usage for a given virtual network. + + :param location_name: The name of the location. Required. + :type location_name: str + :param parameters: The request body. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: VirtualNetworkSubnetUsageModel. The VirtualNetworkSubnetUsageModel is compatible with + MutableMapping + :rtype: ~azure.mgmt.postgresqlflexibleservers.models.VirtualNetworkSubnetUsageModel + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def list( + self, location_name: str, parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any + ) -> _models.VirtualNetworkSubnetUsageModel: + """Lists the virtual network subnet usage for a given virtual network. + + :param location_name: The name of the location. Required. + :type location_name: str + :param parameters: The request body. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: VirtualNetworkSubnetUsageModel. The VirtualNetworkSubnetUsageModel is compatible with + MutableMapping + :rtype: ~azure.mgmt.postgresqlflexibleservers.models.VirtualNetworkSubnetUsageModel + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def list( + self, + location_name: str, + parameters: Union[_models.VirtualNetworkSubnetUsageParameter, JSON, IO[bytes]], + **kwargs: Any + ) -> _models.VirtualNetworkSubnetUsageModel: + """Lists the virtual network subnet usage for a given virtual network. + + :param location_name: The name of the location. Required. + :type location_name: str + :param parameters: The request body. Is one of the following types: + VirtualNetworkSubnetUsageParameter, JSON, IO[bytes] Required. + :type parameters: + ~azure.mgmt.postgresqlflexibleservers.models.VirtualNetworkSubnetUsageParameter or JSON or + IO[bytes] + :return: VirtualNetworkSubnetUsageModel. The VirtualNetworkSubnetUsageModel is compatible with + MutableMapping + :rtype: ~azure.mgmt.postgresqlflexibleservers.models.VirtualNetworkSubnetUsageModel + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.VirtualNetworkSubnetUsageModel] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_virtual_network_subnet_usage_list_request( + location_name=location_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() + else: + deserialized = _deserialize(_models.VirtualNetworkSubnetUsageModel, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore diff --git a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/azure/mgmt/postgresqlflexibleservers/operations/_patch.py b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/azure/mgmt/postgresqlflexibleservers/operations/_patch.py index f7dd32510333..87676c65a8f0 100644 --- a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/azure/mgmt/postgresqlflexibleservers/operations/_patch.py +++ b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/azure/mgmt/postgresqlflexibleservers/operations/_patch.py @@ -1,14 +1,15 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------- """Customize generated code here. Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize """ -from typing import List -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +__all__: list[str] = [] # Add all objects you want publicly available to users at this package level def patch_sdk(): diff --git a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/azure/mgmt/postgresqlflexibleservers/operations/_private_dns_zone_suffix_operations.py b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/azure/mgmt/postgresqlflexibleservers/operations/_private_dns_zone_suffix_operations.py deleted file mode 100644 index ed941ede5165..000000000000 --- a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/azure/mgmt/postgresqlflexibleservers/operations/_private_dns_zone_suffix_operations.py +++ /dev/null @@ -1,127 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from collections.abc import MutableMapping -from typing import Any, Callable, Optional, TypeVar - -from azure.core import PipelineClient -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.rest import HttpRequest, HttpResponse -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from .._configuration import PostgreSQLManagementClientConfiguration -from .._utils.serialization import Deserializer, Serializer - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, dict[str, Any]], Any]] -List = list - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_get_request(**kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-08-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.DBforPostgreSQL/getPrivateDnsZoneSuffix") - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -class PrivateDnsZoneSuffixOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.postgresqlflexibleservers.PostgreSQLManagementClient`'s - :attr:`private_dns_zone_suffix` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: PostgreSQLManagementClientConfiguration = ( - input_args.pop(0) if input_args else kwargs.pop("config") - ) - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def get(self, **kwargs: Any) -> str: - """Gets the private DNS zone suffix. - - :return: str or the result of cls(response) - :rtype: str - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[str] = kwargs.pop("cls", None) - - _request = build_get_request( - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize( - _models.ErrorResponse, - pipeline_response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("str", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/azure/mgmt/postgresqlflexibleservers/operations/_private_endpoint_connections_operations.py b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/azure/mgmt/postgresqlflexibleservers/operations/_private_endpoint_connections_operations.py deleted file mode 100644 index 1743595e51c5..000000000000 --- a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/azure/mgmt/postgresqlflexibleservers/operations/_private_endpoint_connections_operations.py +++ /dev/null @@ -1,734 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from collections.abc import MutableMapping -from io import IOBase -from typing import Any, Callable, IO, Iterator, Optional, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core import PipelineClient -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest, HttpResponse -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.arm_polling import ARMPolling - -from .. import models as _models -from .._configuration import PostgreSQLManagementClientConfiguration -from .._utils.serialization import Deserializer, Serializer - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, dict[str, Any]], Any]] -List = list - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_get_request( - resource_group_name: str, - server_name: str, - private_endpoint_connection_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-08-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}/privateEndpointConnections/{privateEndpointConnectionName}", - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "serverName": _SERIALIZER.url( - "server_name", server_name, "str", max_length=63, min_length=3, pattern=r"^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*" - ), - "privateEndpointConnectionName": _SERIALIZER.url( - "private_endpoint_connection_name", - private_endpoint_connection_name, - "str", - pattern=r"^[a-zA-Z][a-zA-Z0-9-]*\.[a-fA-F0-9\-]+$", - ), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_update_request( - resource_group_name: str, - server_name: str, - private_endpoint_connection_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-08-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}/privateEndpointConnections/{privateEndpointConnectionName}", - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "serverName": _SERIALIZER.url( - "server_name", server_name, "str", max_length=63, min_length=3, pattern=r"^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*" - ), - "privateEndpointConnectionName": _SERIALIZER.url( - "private_endpoint_connection_name", - private_endpoint_connection_name, - "str", - pattern=r"^[a-zA-Z][a-zA-Z0-9-]*\.[a-fA-F0-9\-]+$", - ), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_delete_request( - resource_group_name: str, - server_name: str, - private_endpoint_connection_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-08-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}/privateEndpointConnections/{privateEndpointConnectionName}", - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "serverName": _SERIALIZER.url( - "server_name", server_name, "str", max_length=63, min_length=3, pattern=r"^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*" - ), - "privateEndpointConnectionName": _SERIALIZER.url( - "private_endpoint_connection_name", - private_endpoint_connection_name, - "str", - pattern=r"^[a-zA-Z][a-zA-Z0-9-]*\.[a-fA-F0-9\-]+$", - ), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_list_by_server_request( - resource_group_name: str, server_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-08-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}/privateEndpointConnections", - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "serverName": _SERIALIZER.url( - "server_name", server_name, "str", max_length=63, min_length=3, pattern=r"^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*" - ), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -class PrivateEndpointConnectionsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.postgresqlflexibleservers.PostgreSQLManagementClient`'s - :attr:`private_endpoint_connections` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: PostgreSQLManagementClientConfiguration = ( - input_args.pop(0) if input_args else kwargs.pop("config") - ) - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def get( - self, resource_group_name: str, server_name: str, private_endpoint_connection_name: str, **kwargs: Any - ) -> _models.PrivateEndpointConnection: - """Gets a private endpoint connection. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param private_endpoint_connection_name: The name of the private endpoint connection. Required. - :type private_endpoint_connection_name: str - :return: PrivateEndpointConnection or the result of cls(response) - :rtype: ~azure.mgmt.postgresqlflexibleservers.models.PrivateEndpointConnection - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - server_name=server_name, - private_endpoint_connection_name=private_endpoint_connection_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize( - _models.ErrorResponse, - pipeline_response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - def _update_initial( - self, - resource_group_name: str, - server_name: str, - private_endpoint_connection_name: str, - parameters: Union[_models.PrivateEndpointConnection, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "PrivateEndpointConnection") - - _request = build_update_request( - resource_group_name=resource_group_name, - server_name=server_name, - private_endpoint_connection_name=private_endpoint_connection_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize( - _models.ErrorResponse, - pipeline_response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - response_headers = {} - if response.status_code == 202: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_update( - self, - resource_group_name: str, - server_name: str, - private_endpoint_connection_name: str, - parameters: _models.PrivateEndpointConnection, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.PrivateEndpointConnection]: - """Approves or rejects a private endpoint connection. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param private_endpoint_connection_name: The name of the private endpoint connection. Required. - :type private_endpoint_connection_name: str - :param parameters: Parameters required to update a private endpoint connection. Required. - :type parameters: ~azure.mgmt.postgresqlflexibleservers.models.PrivateEndpointConnection - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either PrivateEndpointConnection or the result - of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.postgresqlflexibleservers.models.PrivateEndpointConnection] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_update( - self, - resource_group_name: str, - server_name: str, - private_endpoint_connection_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.PrivateEndpointConnection]: - """Approves or rejects a private endpoint connection. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param private_endpoint_connection_name: The name of the private endpoint connection. Required. - :type private_endpoint_connection_name: str - :param parameters: Parameters required to update a private endpoint connection. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either PrivateEndpointConnection or the result - of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.postgresqlflexibleservers.models.PrivateEndpointConnection] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_update( - self, - resource_group_name: str, - server_name: str, - private_endpoint_connection_name: str, - parameters: Union[_models.PrivateEndpointConnection, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.PrivateEndpointConnection]: - """Approves or rejects a private endpoint connection. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param private_endpoint_connection_name: The name of the private endpoint connection. Required. - :type private_endpoint_connection_name: str - :param parameters: Parameters required to update a private endpoint connection. Is either a - PrivateEndpointConnection type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.postgresqlflexibleservers.models.PrivateEndpointConnection or - IO[bytes] - :return: An instance of LROPoller that returns either PrivateEndpointConnection or the result - of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.postgresqlflexibleservers.models.PrivateEndpointConnection] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._update_initial( - resource_group_name=resource_group_name, - server_name=server_name, - private_endpoint_connection_name=private_endpoint_connection_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - if polling is True: - polling_method: PollingMethod = cast( - PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) - ) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[_models.PrivateEndpointConnection].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.PrivateEndpointConnection]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _delete_initial( - self, resource_group_name: str, server_name: str, private_endpoint_connection_name: str, **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_delete_request( - resource_group_name=resource_group_name, - server_name=server_name, - private_endpoint_connection_name=private_endpoint_connection_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [202, 204]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize( - _models.ErrorResponse, - pipeline_response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - response_headers = {} - if response.status_code == 202: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def begin_delete( - self, resource_group_name: str, server_name: str, private_endpoint_connection_name: str, **kwargs: Any - ) -> LROPoller[None]: - """Deletes a private endpoint connection. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param private_endpoint_connection_name: The name of the private endpoint connection. Required. - :type private_endpoint_connection_name: str - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._delete_initial( - resource_group_name=resource_group_name, - server_name=server_name, - private_endpoint_connection_name=private_endpoint_connection_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: PollingMethod = cast( - PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) - ) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - @distributed_trace - def list_by_server( - self, resource_group_name: str, server_name: str, **kwargs: Any - ) -> ItemPaged["_models.PrivateEndpointConnection"]: - """Lists all private endpoint connections on a server. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :return: An iterator like instance of either PrivateEndpointConnection or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.postgresqlflexibleservers.models.PrivateEndpointConnection] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.PrivateEndpointConnectionList] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_by_server_request( - resource_group_name=resource_group_name, - server_name=server_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("PrivateEndpointConnectionList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize( - _models.ErrorResponse, - pipeline_response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) diff --git a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/azure/mgmt/postgresqlflexibleservers/operations/_private_link_resources_operations.py b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/azure/mgmt/postgresqlflexibleservers/operations/_private_link_resources_operations.py deleted file mode 100644 index cf4cae725c9b..000000000000 --- a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/azure/mgmt/postgresqlflexibleservers/operations/_private_link_resources_operations.py +++ /dev/null @@ -1,283 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from collections.abc import MutableMapping -from typing import Any, Callable, Optional, TypeVar -import urllib.parse - -from azure.core import PipelineClient -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.rest import HttpRequest, HttpResponse -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from .._configuration import PostgreSQLManagementClientConfiguration -from .._utils.serialization import Deserializer, Serializer - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, dict[str, Any]], Any]] -List = list - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_by_server_request( - resource_group_name: str, server_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-08-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}/privateLinkResources", - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "serverName": _SERIALIZER.url( - "server_name", server_name, "str", max_length=63, min_length=3, pattern=r"^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*" - ), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_get_request( - resource_group_name: str, server_name: str, group_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-08-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}/privateLinkResources/{groupName}", - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "serverName": _SERIALIZER.url( - "server_name", server_name, "str", max_length=63, min_length=3, pattern=r"^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*" - ), - "groupName": _SERIALIZER.url("group_name", group_name, "str", pattern=r"^.*$"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -class PrivateLinkResourcesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.postgresqlflexibleservers.PostgreSQLManagementClient`'s - :attr:`private_link_resources` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: PostgreSQLManagementClientConfiguration = ( - input_args.pop(0) if input_args else kwargs.pop("config") - ) - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def list_by_server( - self, resource_group_name: str, server_name: str, **kwargs: Any - ) -> ItemPaged["_models.PrivateLinkResource"]: - """Gets the private link resources for PostgreSQL server. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :return: An iterator like instance of either PrivateLinkResource or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.postgresqlflexibleservers.models.PrivateLinkResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.PrivateLinkResourceList] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_by_server_request( - resource_group_name=resource_group_name, - server_name=server_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("PrivateLinkResourceList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize( - _models.ErrorResponse, - pipeline_response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def get( - self, resource_group_name: str, server_name: str, group_name: str, **kwargs: Any - ) -> _models.PrivateLinkResource: - """Gets a private link resource for PostgreSQL server. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param group_name: The name of the private link resource. Required. - :type group_name: str - :return: PrivateLinkResource or the result of cls(response) - :rtype: ~azure.mgmt.postgresqlflexibleservers.models.PrivateLinkResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.PrivateLinkResource] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - server_name=server_name, - group_name=group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize( - _models.ErrorResponse, - pipeline_response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("PrivateLinkResource", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/azure/mgmt/postgresqlflexibleservers/operations/_quota_usages_operations.py b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/azure/mgmt/postgresqlflexibleservers/operations/_quota_usages_operations.py deleted file mode 100644 index a3a04a19802b..000000000000 --- a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/azure/mgmt/postgresqlflexibleservers/operations/_quota_usages_operations.py +++ /dev/null @@ -1,169 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from collections.abc import MutableMapping -from typing import Any, Callable, Optional, TypeVar -import urllib.parse - -from azure.core import PipelineClient -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.rest import HttpRequest, HttpResponse -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from .._configuration import PostgreSQLManagementClientConfiguration -from .._utils.serialization import Deserializer, Serializer - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, dict[str, Any]], Any]] -List = list - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_request(location_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-08-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.DBforPostgreSQL/locations/{locationName}/resourceType/flexibleServers/usages", - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "locationName": _SERIALIZER.url("location_name", location_name, "str", min_length=1, pattern=r"^[-\w\._]+$"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -class QuotaUsagesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.postgresqlflexibleservers.PostgreSQLManagementClient`'s - :attr:`quota_usages` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: PostgreSQLManagementClientConfiguration = ( - input_args.pop(0) if input_args else kwargs.pop("config") - ) - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def list(self, location_name: str, **kwargs: Any) -> ItemPaged["_models.QuotaUsage"]: - """Get quota usages at specified location in a given subscription. - - :param location_name: The name of the location. Required. - :type location_name: str - :return: An iterator like instance of either QuotaUsage or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.postgresqlflexibleservers.models.QuotaUsage] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.QuotaUsageList] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_request( - location_name=location_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("QuotaUsageList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize( - _models.ErrorResponse, - pipeline_response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) diff --git a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/azure/mgmt/postgresqlflexibleservers/operations/_replicas_operations.py b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/azure/mgmt/postgresqlflexibleservers/operations/_replicas_operations.py deleted file mode 100644 index e6b3749d43c7..000000000000 --- a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/azure/mgmt/postgresqlflexibleservers/operations/_replicas_operations.py +++ /dev/null @@ -1,180 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from collections.abc import MutableMapping -from typing import Any, Callable, Optional, TypeVar -import urllib.parse - -from azure.core import PipelineClient -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.rest import HttpRequest, HttpResponse -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from .._configuration import PostgreSQLManagementClientConfiguration -from .._utils.serialization import Deserializer, Serializer - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, dict[str, Any]], Any]] -List = list - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_by_server_request( - resource_group_name: str, server_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-08-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}/replicas", - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "serverName": _SERIALIZER.url( - "server_name", server_name, "str", max_length=63, min_length=3, pattern=r"^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*" - ), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -class ReplicasOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.postgresqlflexibleservers.PostgreSQLManagementClient`'s - :attr:`replicas` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: PostgreSQLManagementClientConfiguration = ( - input_args.pop(0) if input_args else kwargs.pop("config") - ) - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def list_by_server(self, resource_group_name: str, server_name: str, **kwargs: Any) -> ItemPaged["_models.Server"]: - """Lists all read replicas of a server. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :return: An iterator like instance of either Server or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.postgresqlflexibleservers.models.Server] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.ServerList] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_by_server_request( - resource_group_name=resource_group_name, - server_name=server_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("ServerList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize( - _models.ErrorResponse, - pipeline_response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) diff --git a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/azure/mgmt/postgresqlflexibleservers/operations/_server_threat_protection_settings_operations.py b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/azure/mgmt/postgresqlflexibleservers/operations/_server_threat_protection_settings_operations.py deleted file mode 100644 index d2612650f850..000000000000 --- a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/azure/mgmt/postgresqlflexibleservers/operations/_server_threat_protection_settings_operations.py +++ /dev/null @@ -1,334 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from collections.abc import MutableMapping -from io import IOBase -from typing import Any, Callable, IO, Iterator, Optional, TypeVar, Union, cast, overload - -from azure.core import PipelineClient -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest, HttpResponse -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.arm_polling import ARMPolling - -from .. import models as _models -from .._configuration import PostgreSQLManagementClientConfiguration -from .._utils.serialization import Deserializer, Serializer - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, dict[str, Any]], Any]] -List = list - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_create_or_update_request( - resource_group_name: str, - server_name: str, - threat_protection_name: Union[str, _models.ThreatProtectionName], - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-08-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}/advancedThreatProtectionSettings/{threatProtectionName}", - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "serverName": _SERIALIZER.url( - "server_name", server_name, "str", max_length=63, min_length=3, pattern=r"^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*" - ), - "threatProtectionName": _SERIALIZER.url("threat_protection_name", threat_protection_name, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -class ServerThreatProtectionSettingsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.postgresqlflexibleservers.PostgreSQLManagementClient`'s - :attr:`server_threat_protection_settings` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: PostgreSQLManagementClientConfiguration = ( - input_args.pop(0) if input_args else kwargs.pop("config") - ) - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - def _create_or_update_initial( - self, - resource_group_name: str, - server_name: str, - threat_protection_name: Union[str, _models.ThreatProtectionName], - parameters: Union[_models.AdvancedThreatProtectionSettingsModel, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "AdvancedThreatProtectionSettingsModel") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - server_name=server_name, - threat_protection_name=threat_protection_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize( - _models.ErrorResponse, - pipeline_response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - response_headers = {} - if response.status_code == 202: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - server_name: str, - threat_protection_name: Union[str, _models.ThreatProtectionName], - parameters: _models.AdvancedThreatProtectionSettingsModel, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.AdvancedThreatProtectionSettingsModel]: - """Creates or updates a server's Advanced Threat Protection settings. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param threat_protection_name: Name of the advanced threat protection settings. "Default" - Required. - :type threat_protection_name: str or - ~azure.mgmt.postgresqlflexibleservers.models.ThreatProtectionName - :param parameters: The Advanced Threat Protection state for the server. Required. - :type parameters: - ~azure.mgmt.postgresqlflexibleservers.models.AdvancedThreatProtectionSettingsModel - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either AdvancedThreatProtectionSettingsModel or - the result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.postgresqlflexibleservers.models.AdvancedThreatProtectionSettingsModel] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - server_name: str, - threat_protection_name: Union[str, _models.ThreatProtectionName], - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.AdvancedThreatProtectionSettingsModel]: - """Creates or updates a server's Advanced Threat Protection settings. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param threat_protection_name: Name of the advanced threat protection settings. "Default" - Required. - :type threat_protection_name: str or - ~azure.mgmt.postgresqlflexibleservers.models.ThreatProtectionName - :param parameters: The Advanced Threat Protection state for the server. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either AdvancedThreatProtectionSettingsModel or - the result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.postgresqlflexibleservers.models.AdvancedThreatProtectionSettingsModel] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_create_or_update( - self, - resource_group_name: str, - server_name: str, - threat_protection_name: Union[str, _models.ThreatProtectionName], - parameters: Union[_models.AdvancedThreatProtectionSettingsModel, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.AdvancedThreatProtectionSettingsModel]: - """Creates or updates a server's Advanced Threat Protection settings. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param threat_protection_name: Name of the advanced threat protection settings. "Default" - Required. - :type threat_protection_name: str or - ~azure.mgmt.postgresqlflexibleservers.models.ThreatProtectionName - :param parameters: The Advanced Threat Protection state for the server. Is either a - AdvancedThreatProtectionSettingsModel type or a IO[bytes] type. Required. - :type parameters: - ~azure.mgmt.postgresqlflexibleservers.models.AdvancedThreatProtectionSettingsModel or IO[bytes] - :return: An instance of LROPoller that returns either AdvancedThreatProtectionSettingsModel or - the result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.postgresqlflexibleservers.models.AdvancedThreatProtectionSettingsModel] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.AdvancedThreatProtectionSettingsModel] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._create_or_update_initial( - resource_group_name=resource_group_name, - server_name=server_name, - threat_protection_name=threat_protection_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("AdvancedThreatProtectionSettingsModel", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - if polling is True: - polling_method: PollingMethod = cast( - PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) - ) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[_models.AdvancedThreatProtectionSettingsModel].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.AdvancedThreatProtectionSettingsModel]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) diff --git a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/azure/mgmt/postgresqlflexibleservers/operations/_servers_operations.py b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/azure/mgmt/postgresqlflexibleservers/operations/_servers_operations.py deleted file mode 100644 index 444f8e750a9e..000000000000 --- a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/azure/mgmt/postgresqlflexibleservers/operations/_servers_operations.py +++ /dev/null @@ -1,1531 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression,too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from collections.abc import MutableMapping -from io import IOBase -from typing import Any, Callable, IO, Iterator, Optional, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core import PipelineClient -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest, HttpResponse -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.arm_polling import ARMPolling - -from .. import models as _models -from .._configuration import PostgreSQLManagementClientConfiguration -from .._utils.serialization import Deserializer, Serializer - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, dict[str, Any]], Any]] -List = list - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_create_or_update_request( - resource_group_name: str, server_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-08-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}", - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "serverName": _SERIALIZER.url( - "server_name", server_name, "str", max_length=63, min_length=3, pattern=r"^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*" - ), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_update_request( - resource_group_name: str, server_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-08-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}", - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "serverName": _SERIALIZER.url( - "server_name", server_name, "str", max_length=63, min_length=3, pattern=r"^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*" - ), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_delete_request( - resource_group_name: str, server_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-08-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}", - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "serverName": _SERIALIZER.url( - "server_name", server_name, "str", max_length=63, min_length=3, pattern=r"^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*" - ), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_get_request(resource_group_name: str, server_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-08-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}", - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "serverName": _SERIALIZER.url( - "server_name", server_name, "str", max_length=63, min_length=3, pattern=r"^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*" - ), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_list_by_resource_group_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-08-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers", - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_list_by_subscription_request(subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-08-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.DBforPostgreSQL/flexibleServers" - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_restart_request( - resource_group_name: str, server_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-08-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}/restart", - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "serverName": _SERIALIZER.url( - "server_name", server_name, "str", max_length=63, min_length=3, pattern=r"^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*" - ), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_start_request(resource_group_name: str, server_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-08-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}/start", - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "serverName": _SERIALIZER.url( - "server_name", server_name, "str", max_length=63, min_length=3, pattern=r"^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*" - ), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_stop_request(resource_group_name: str, server_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-08-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}/stop", - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "serverName": _SERIALIZER.url( - "server_name", server_name, "str", max_length=63, min_length=3, pattern=r"^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*" - ), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -class ServersOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.postgresqlflexibleservers.PostgreSQLManagementClient`'s - :attr:`servers` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: PostgreSQLManagementClientConfiguration = ( - input_args.pop(0) if input_args else kwargs.pop("config") - ) - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - def _create_or_update_initial( - self, resource_group_name: str, server_name: str, parameters: Union[_models.Server, IO[bytes]], **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "Server") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - server_name=server_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize( - _models.ErrorResponse, - pipeline_response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - response_headers = {} - if response.status_code == 202: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - server_name: str, - parameters: _models.Server, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.Server]: - """Creates a new server. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param parameters: Parameters required to create a new server or to update an existing server. - Required. - :type parameters: ~azure.mgmt.postgresqlflexibleservers.models.Server - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either Server or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.postgresqlflexibleservers.models.Server] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - server_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.Server]: - """Creates a new server. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param parameters: Parameters required to create a new server or to update an existing server. - Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either Server or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.postgresqlflexibleservers.models.Server] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_create_or_update( - self, resource_group_name: str, server_name: str, parameters: Union[_models.Server, IO[bytes]], **kwargs: Any - ) -> LROPoller[_models.Server]: - """Creates a new server. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param parameters: Parameters required to create a new server or to update an existing server. - Is either a Server type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.postgresqlflexibleservers.models.Server or IO[bytes] - :return: An instance of LROPoller that returns either Server or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.postgresqlflexibleservers.models.Server] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.Server] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._create_or_update_initial( - resource_group_name=resource_group_name, - server_name=server_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Server", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - if polling is True: - polling_method: PollingMethod = cast( - PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) - ) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[_models.Server].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.Server]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _update_initial( - self, - resource_group_name: str, - server_name: str, - parameters: Union[_models.ServerForPatch, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "ServerForPatch") - - _request = build_update_request( - resource_group_name=resource_group_name, - server_name=server_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize( - _models.ErrorResponse, - pipeline_response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - response_headers = {} - if response.status_code == 202: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_update( - self, - resource_group_name: str, - server_name: str, - parameters: _models.ServerForPatch, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.Server]: - """Updates an existing server. The request body can contain one or multiple of the properties - present in the normal server definition. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param parameters: Parameters required to update a server. Required. - :type parameters: ~azure.mgmt.postgresqlflexibleservers.models.ServerForPatch - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either Server or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.postgresqlflexibleservers.models.Server] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_update( - self, - resource_group_name: str, - server_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.Server]: - """Updates an existing server. The request body can contain one or multiple of the properties - present in the normal server definition. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param parameters: Parameters required to update a server. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either Server or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.postgresqlflexibleservers.models.Server] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_update( - self, - resource_group_name: str, - server_name: str, - parameters: Union[_models.ServerForPatch, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.Server]: - """Updates an existing server. The request body can contain one or multiple of the properties - present in the normal server definition. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param parameters: Parameters required to update a server. Is either a ServerForPatch type or a - IO[bytes] type. Required. - :type parameters: ~azure.mgmt.postgresqlflexibleservers.models.ServerForPatch or IO[bytes] - :return: An instance of LROPoller that returns either Server or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.postgresqlflexibleservers.models.Server] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.Server] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._update_initial( - resource_group_name=resource_group_name, - server_name=server_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Server", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - if polling is True: - polling_method: PollingMethod = cast( - PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) - ) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[_models.Server].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.Server]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _delete_initial(self, resource_group_name: str, server_name: str, **kwargs: Any) -> Iterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_delete_request( - resource_group_name=resource_group_name, - server_name=server_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [202, 204]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize( - _models.ErrorResponse, - pipeline_response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - response_headers = {} - if response.status_code == 202: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def begin_delete(self, resource_group_name: str, server_name: str, **kwargs: Any) -> LROPoller[None]: - """Deletes or drops an existing server. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._delete_initial( - resource_group_name=resource_group_name, - server_name=server_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: PollingMethod = cast( - PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) - ) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - @distributed_trace - def get(self, resource_group_name: str, server_name: str, **kwargs: Any) -> _models.Server: - """Gets information about an existing server. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :return: Server or the result of cls(response) - :rtype: ~azure.mgmt.postgresqlflexibleservers.models.Server - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.Server] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - server_name=server_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize( - _models.ErrorResponse, - pipeline_response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("Server", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> ItemPaged["_models.Server"]: - """Lists all servers in a resource group. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :return: An iterator like instance of either Server or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.postgresqlflexibleservers.models.Server] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.ServerList] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("ServerList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize( - _models.ErrorResponse, - pipeline_response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def list_by_subscription(self, **kwargs: Any) -> ItemPaged["_models.Server"]: - """Lists all servers in a subscription. - - :return: An iterator like instance of either Server or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.postgresqlflexibleservers.models.Server] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.ServerList] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_by_subscription_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("ServerList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize( - _models.ErrorResponse, - pipeline_response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - def _restart_initial( - self, - resource_group_name: str, - server_name: str, - parameters: Optional[Union[_models.RestartParameter, IO[bytes]]] = None, - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - content_type = content_type if parameters else None - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" if parameters else None - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - if parameters is not None: - _json = self._serialize.body(parameters, "RestartParameter") - else: - _json = None - - _request = build_restart_request( - resource_group_name=resource_group_name, - server_name=server_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize( - _models.ErrorResponse, - pipeline_response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - response_headers = {} - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_restart( - self, - resource_group_name: str, - server_name: str, - parameters: Optional[_models.RestartParameter] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[None]: - """Restarts PostgreSQL database engine in a server. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param parameters: Parameters to restart a server. Default value is None. - :type parameters: ~azure.mgmt.postgresqlflexibleservers.models.RestartParameter - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_restart( - self, - resource_group_name: str, - server_name: str, - parameters: Optional[IO[bytes]] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[None]: - """Restarts PostgreSQL database engine in a server. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param parameters: Parameters to restart a server. Default value is None. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_restart( - self, - resource_group_name: str, - server_name: str, - parameters: Optional[Union[_models.RestartParameter, IO[bytes]]] = None, - **kwargs: Any - ) -> LROPoller[None]: - """Restarts PostgreSQL database engine in a server. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param parameters: Parameters to restart a server. Is either a RestartParameter type or a - IO[bytes] type. Default value is None. - :type parameters: ~azure.mgmt.postgresqlflexibleservers.models.RestartParameter or IO[bytes] - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - content_type = content_type if parameters else None - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._restart_initial( - resource_group_name=resource_group_name, - server_name=server_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: PollingMethod = cast( - PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) - ) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - def _start_initial(self, resource_group_name: str, server_name: str, **kwargs: Any) -> Iterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_start_request( - resource_group_name=resource_group_name, - server_name=server_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize( - _models.ErrorResponse, - pipeline_response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - response_headers = {} - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def begin_start(self, resource_group_name: str, server_name: str, **kwargs: Any) -> LROPoller[None]: - """Starts a stopped server. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._start_initial( - resource_group_name=resource_group_name, - server_name=server_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: PollingMethod = cast( - PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) - ) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - def _stop_initial(self, resource_group_name: str, server_name: str, **kwargs: Any) -> Iterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_stop_request( - resource_group_name=resource_group_name, - server_name=server_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize( - _models.ErrorResponse, - pipeline_response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - response_headers = {} - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def begin_stop(self, resource_group_name: str, server_name: str, **kwargs: Any) -> LROPoller[None]: - """Stops a server. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._stop_initial( - resource_group_name=resource_group_name, - server_name=server_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: PollingMethod = cast( - PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) - ) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/azure/mgmt/postgresqlflexibleservers/operations/_tuning_options_operations.py b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/azure/mgmt/postgresqlflexibleservers/operations/_tuning_options_operations.py deleted file mode 100644 index 22e04d492c07..000000000000 --- a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/azure/mgmt/postgresqlflexibleservers/operations/_tuning_options_operations.py +++ /dev/null @@ -1,442 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from collections.abc import MutableMapping -from typing import Any, Callable, Optional, TypeVar, Union -import urllib.parse - -from azure.core import PipelineClient -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.rest import HttpRequest, HttpResponse -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from .._configuration import PostgreSQLManagementClientConfiguration -from .._utils.serialization import Deserializer, Serializer - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, dict[str, Any]], Any]] -List = list - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_get_request( - resource_group_name: str, - server_name: str, - tuning_option: Union[str, _models.TuningOptionParameterEnum], - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-08-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}/tuningOptions/{tuningOption}", - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "serverName": _SERIALIZER.url( - "server_name", server_name, "str", max_length=63, min_length=3, pattern=r"^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*" - ), - "tuningOption": _SERIALIZER.url("tuning_option", tuning_option, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_list_recommendations_request( - resource_group_name: str, - server_name: str, - tuning_option: Union[str, _models.TuningOptionParameterEnum], - subscription_id: str, - *, - recommendation_type: Optional[Union[str, _models.RecommendationTypeParameterEnum]] = None, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-08-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}/tuningOptions/{tuningOption}/recommendations", - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "serverName": _SERIALIZER.url( - "server_name", server_name, "str", max_length=63, min_length=3, pattern=r"^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*" - ), - "tuningOption": _SERIALIZER.url("tuning_option", tuning_option, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - if recommendation_type is not None: - _params["recommendationType"] = _SERIALIZER.query("recommendation_type", recommendation_type, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_list_by_server_request( - resource_group_name: str, server_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-08-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}/tuningOptions", - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "serverName": _SERIALIZER.url( - "server_name", server_name, "str", max_length=63, min_length=3, pattern=r"^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*" - ), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -class TuningOptionsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.postgresqlflexibleservers.PostgreSQLManagementClient`'s - :attr:`tuning_options` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: PostgreSQLManagementClientConfiguration = ( - input_args.pop(0) if input_args else kwargs.pop("config") - ) - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def get( - self, - resource_group_name: str, - server_name: str, - tuning_option: Union[str, _models.TuningOptionParameterEnum], - **kwargs: Any - ) -> _models.TuningOptions: - """Gets the tuning options of a server. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param tuning_option: The name of the tuning option. Known values are: "index" and "table". - Required. - :type tuning_option: str or - ~azure.mgmt.postgresqlflexibleservers.models.TuningOptionParameterEnum - :return: TuningOptions or the result of cls(response) - :rtype: ~azure.mgmt.postgresqlflexibleservers.models.TuningOptions - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.TuningOptions] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - server_name=server_name, - tuning_option=tuning_option, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize( - _models.ErrorResponse, - pipeline_response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("TuningOptions", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def list_recommendations( - self, - resource_group_name: str, - server_name: str, - tuning_option: Union[str, _models.TuningOptionParameterEnum], - recommendation_type: Optional[Union[str, _models.RecommendationTypeParameterEnum]] = None, - **kwargs: Any - ) -> ItemPaged["_models.ObjectRecommendation"]: - """Lists available object recommendations. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param tuning_option: The name of the tuning option. Known values are: "index" and "table". - Required. - :type tuning_option: str or - ~azure.mgmt.postgresqlflexibleservers.models.TuningOptionParameterEnum - :param recommendation_type: Recommendations list filter. Retrieves recommendations based on - type. Known values are: "CreateIndex", "DropIndex", "ReIndex", and "AnalyzeTable". Default - value is None. - :type recommendation_type: str or - ~azure.mgmt.postgresqlflexibleservers.models.RecommendationTypeParameterEnum - :return: An iterator like instance of either ObjectRecommendation or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.postgresqlflexibleservers.models.ObjectRecommendation] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.ObjectRecommendationList] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_recommendations_request( - resource_group_name=resource_group_name, - server_name=server_name, - tuning_option=tuning_option, - subscription_id=self._config.subscription_id, - recommendation_type=recommendation_type, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("ObjectRecommendationList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize( - _models.ErrorResponse, - pipeline_response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def list_by_server( - self, resource_group_name: str, server_name: str, **kwargs: Any - ) -> ItemPaged["_models.TuningOptions"]: - """Lists the tuning options of a server. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :return: An iterator like instance of either TuningOptions or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.postgresqlflexibleservers.models.TuningOptions] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.TuningOptionsList] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_by_server_request( - resource_group_name=resource_group_name, - server_name=server_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("TuningOptionsList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize( - _models.ErrorResponse, - pipeline_response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) diff --git a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/azure/mgmt/postgresqlflexibleservers/operations/_virtual_endpoints_operations.py b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/azure/mgmt/postgresqlflexibleservers/operations/_virtual_endpoints_operations.py deleted file mode 100644 index c9904e07731e..000000000000 --- a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/azure/mgmt/postgresqlflexibleservers/operations/_virtual_endpoints_operations.py +++ /dev/null @@ -1,995 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from collections.abc import MutableMapping -from io import IOBase -from typing import Any, Callable, IO, Iterator, Optional, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core import PipelineClient -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest, HttpResponse -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.arm_polling import ARMPolling - -from .. import models as _models -from .._configuration import PostgreSQLManagementClientConfiguration -from .._utils.serialization import Deserializer, Serializer - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, dict[str, Any]], Any]] -List = list - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_create_request( - resource_group_name: str, server_name: str, virtual_endpoint_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-08-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}/virtualendpoints/{virtualEndpointName}", - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "serverName": _SERIALIZER.url( - "server_name", server_name, "str", max_length=63, min_length=3, pattern=r"^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*" - ), - "virtualEndpointName": _SERIALIZER.url( - "virtual_endpoint_name", - virtual_endpoint_name, - "str", - max_length=63, - min_length=3, - pattern=r"^[A-Za-z0-9][A-Za-z0-9-]{0,62}(? HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-08-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}/virtualendpoints/{virtualEndpointName}", - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "serverName": _SERIALIZER.url( - "server_name", server_name, "str", max_length=63, min_length=3, pattern=r"^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*" - ), - "virtualEndpointName": _SERIALIZER.url( - "virtual_endpoint_name", - virtual_endpoint_name, - "str", - max_length=63, - min_length=3, - pattern=r"^[A-Za-z0-9][A-Za-z0-9-]{0,62}(? HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-08-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}/virtualendpoints/{virtualEndpointName}", - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "serverName": _SERIALIZER.url( - "server_name", server_name, "str", max_length=63, min_length=3, pattern=r"^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*" - ), - "virtualEndpointName": _SERIALIZER.url( - "virtual_endpoint_name", - virtual_endpoint_name, - "str", - max_length=63, - min_length=3, - pattern=r"^[A-Za-z0-9][A-Za-z0-9-]{0,62}(? HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-08-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}/virtualendpoints/{virtualEndpointName}", - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "serverName": _SERIALIZER.url( - "server_name", server_name, "str", max_length=63, min_length=3, pattern=r"^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*" - ), - "virtualEndpointName": _SERIALIZER.url( - "virtual_endpoint_name", - virtual_endpoint_name, - "str", - max_length=63, - min_length=3, - pattern=r"^[A-Za-z0-9][A-Za-z0-9-]{0,62}(? HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-08-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}/virtualendpoints", - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "serverName": _SERIALIZER.url( - "server_name", server_name, "str", max_length=63, min_length=3, pattern=r"^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*" - ), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -class VirtualEndpointsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.postgresqlflexibleservers.PostgreSQLManagementClient`'s - :attr:`virtual_endpoints` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: PostgreSQLManagementClientConfiguration = ( - input_args.pop(0) if input_args else kwargs.pop("config") - ) - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - def _create_initial( - self, - resource_group_name: str, - server_name: str, - virtual_endpoint_name: str, - parameters: Union[_models.VirtualEndpoint, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "VirtualEndpoint") - - _request = build_create_request( - resource_group_name=resource_group_name, - server_name=server_name, - virtual_endpoint_name=virtual_endpoint_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize( - _models.ErrorResponse, - pipeline_response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - response_headers = {} - if response.status_code == 202: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_create( - self, - resource_group_name: str, - server_name: str, - virtual_endpoint_name: str, - parameters: _models.VirtualEndpoint, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.VirtualEndpoint]: - """Creates a pair of virtual endpoints for a server. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param virtual_endpoint_name: Base name of the virtual endpoints. Required. - :type virtual_endpoint_name: str - :param parameters: Parameters required to create or update a pair of virtual endpoints. - Required. - :type parameters: ~azure.mgmt.postgresqlflexibleservers.models.VirtualEndpoint - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either VirtualEndpoint or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.postgresqlflexibleservers.models.VirtualEndpoint] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_create( - self, - resource_group_name: str, - server_name: str, - virtual_endpoint_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.VirtualEndpoint]: - """Creates a pair of virtual endpoints for a server. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param virtual_endpoint_name: Base name of the virtual endpoints. Required. - :type virtual_endpoint_name: str - :param parameters: Parameters required to create or update a pair of virtual endpoints. - Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either VirtualEndpoint or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.postgresqlflexibleservers.models.VirtualEndpoint] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_create( - self, - resource_group_name: str, - server_name: str, - virtual_endpoint_name: str, - parameters: Union[_models.VirtualEndpoint, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.VirtualEndpoint]: - """Creates a pair of virtual endpoints for a server. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param virtual_endpoint_name: Base name of the virtual endpoints. Required. - :type virtual_endpoint_name: str - :param parameters: Parameters required to create or update a pair of virtual endpoints. Is - either a VirtualEndpoint type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.postgresqlflexibleservers.models.VirtualEndpoint or IO[bytes] - :return: An instance of LROPoller that returns either VirtualEndpoint or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.postgresqlflexibleservers.models.VirtualEndpoint] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.VirtualEndpoint] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._create_initial( - resource_group_name=resource_group_name, - server_name=server_name, - virtual_endpoint_name=virtual_endpoint_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("VirtualEndpoint", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - if polling is True: - polling_method: PollingMethod = cast( - PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) - ) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[_models.VirtualEndpoint].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.VirtualEndpoint]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _update_initial( - self, - resource_group_name: str, - server_name: str, - virtual_endpoint_name: str, - parameters: Union[_models.VirtualEndpointResourceForPatch, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "VirtualEndpointResourceForPatch") - - _request = build_update_request( - resource_group_name=resource_group_name, - server_name=server_name, - virtual_endpoint_name=virtual_endpoint_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize( - _models.ErrorResponse, - pipeline_response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - response_headers = {} - if response.status_code == 202: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_update( - self, - resource_group_name: str, - server_name: str, - virtual_endpoint_name: str, - parameters: _models.VirtualEndpointResourceForPatch, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.VirtualEndpoint]: - """Updates a pair of virtual endpoints for a server. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param virtual_endpoint_name: Base name of the virtual endpoints. Required. - :type virtual_endpoint_name: str - :param parameters: Parameters required to update a pair of virtual endpoints. Required. - :type parameters: ~azure.mgmt.postgresqlflexibleservers.models.VirtualEndpointResourceForPatch - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either VirtualEndpoint or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.postgresqlflexibleservers.models.VirtualEndpoint] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_update( - self, - resource_group_name: str, - server_name: str, - virtual_endpoint_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.VirtualEndpoint]: - """Updates a pair of virtual endpoints for a server. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param virtual_endpoint_name: Base name of the virtual endpoints. Required. - :type virtual_endpoint_name: str - :param parameters: Parameters required to update a pair of virtual endpoints. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either VirtualEndpoint or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.postgresqlflexibleservers.models.VirtualEndpoint] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_update( - self, - resource_group_name: str, - server_name: str, - virtual_endpoint_name: str, - parameters: Union[_models.VirtualEndpointResourceForPatch, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.VirtualEndpoint]: - """Updates a pair of virtual endpoints for a server. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param virtual_endpoint_name: Base name of the virtual endpoints. Required. - :type virtual_endpoint_name: str - :param parameters: Parameters required to update a pair of virtual endpoints. Is either a - VirtualEndpointResourceForPatch type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.postgresqlflexibleservers.models.VirtualEndpointResourceForPatch - or IO[bytes] - :return: An instance of LROPoller that returns either VirtualEndpoint or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.postgresqlflexibleservers.models.VirtualEndpoint] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.VirtualEndpoint] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._update_initial( - resource_group_name=resource_group_name, - server_name=server_name, - virtual_endpoint_name=virtual_endpoint_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("VirtualEndpoint", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - if polling is True: - polling_method: PollingMethod = cast( - PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) - ) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[_models.VirtualEndpoint].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.VirtualEndpoint]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _delete_initial( - self, resource_group_name: str, server_name: str, virtual_endpoint_name: str, **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_delete_request( - resource_group_name=resource_group_name, - server_name=server_name, - virtual_endpoint_name=virtual_endpoint_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [202, 204]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize( - _models.ErrorResponse, - pipeline_response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - response_headers = {} - if response.status_code == 202: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def begin_delete( - self, resource_group_name: str, server_name: str, virtual_endpoint_name: str, **kwargs: Any - ) -> LROPoller[None]: - """Deletes a pair of virtual endpoints. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param virtual_endpoint_name: Base name of the virtual endpoints. Required. - :type virtual_endpoint_name: str - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._delete_initial( - resource_group_name=resource_group_name, - server_name=server_name, - virtual_endpoint_name=virtual_endpoint_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: PollingMethod = cast( - PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) - ) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - @distributed_trace - def get( - self, resource_group_name: str, server_name: str, virtual_endpoint_name: str, **kwargs: Any - ) -> _models.VirtualEndpoint: - """Gets information about a pair of virtual endpoints. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param virtual_endpoint_name: Base name of the virtual endpoints. Required. - :type virtual_endpoint_name: str - :return: VirtualEndpoint or the result of cls(response) - :rtype: ~azure.mgmt.postgresqlflexibleservers.models.VirtualEndpoint - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.VirtualEndpoint] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - server_name=server_name, - virtual_endpoint_name=virtual_endpoint_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize( - _models.ErrorResponse, - pipeline_response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("VirtualEndpoint", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def list_by_server( - self, resource_group_name: str, server_name: str, **kwargs: Any - ) -> ItemPaged["_models.VirtualEndpoint"]: - """Lists pair of virtual endpoints associated to a server. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :return: An iterator like instance of either VirtualEndpoint or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.postgresqlflexibleservers.models.VirtualEndpoint] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.VirtualEndpointsList] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_by_server_request( - resource_group_name=resource_group_name, - server_name=server_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("VirtualEndpointsList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize( - _models.ErrorResponse, - pipeline_response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) diff --git a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/azure/mgmt/postgresqlflexibleservers/operations/_virtual_network_subnet_usage_operations.py b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/azure/mgmt/postgresqlflexibleservers/operations/_virtual_network_subnet_usage_operations.py deleted file mode 100644 index 579bcdff7286..000000000000 --- a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/azure/mgmt/postgresqlflexibleservers/operations/_virtual_network_subnet_usage_operations.py +++ /dev/null @@ -1,208 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from collections.abc import MutableMapping -from io import IOBase -from typing import Any, Callable, IO, Optional, TypeVar, Union, overload - -from azure.core import PipelineClient -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.rest import HttpRequest, HttpResponse -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from .._configuration import PostgreSQLManagementClientConfiguration -from .._utils.serialization import Deserializer, Serializer - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, dict[str, Any]], Any]] -List = list - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_request(location_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-08-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.DBforPostgreSQL/locations/{locationName}/checkVirtualNetworkSubnetUsage", - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "locationName": _SERIALIZER.url("location_name", location_name, "str", min_length=1, pattern=r"^[-\w\._]+$"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -class VirtualNetworkSubnetUsageOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.postgresqlflexibleservers.PostgreSQLManagementClient`'s - :attr:`virtual_network_subnet_usage` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: PostgreSQLManagementClientConfiguration = ( - input_args.pop(0) if input_args else kwargs.pop("config") - ) - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @overload - def list( - self, - location_name: str, - parameters: _models.VirtualNetworkSubnetUsageParameter, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.VirtualNetworkSubnetUsageModel: - """Lists the virtual network subnet usage for a given virtual network. - - :param location_name: The name of the location. Required. - :type location_name: str - :param parameters: The required parameters for creating or updating a server. Required. - :type parameters: - ~azure.mgmt.postgresqlflexibleservers.models.VirtualNetworkSubnetUsageParameter - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: VirtualNetworkSubnetUsageModel or the result of cls(response) - :rtype: ~azure.mgmt.postgresqlflexibleservers.models.VirtualNetworkSubnetUsageModel - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def list( - self, location_name: str, parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> _models.VirtualNetworkSubnetUsageModel: - """Lists the virtual network subnet usage for a given virtual network. - - :param location_name: The name of the location. Required. - :type location_name: str - :param parameters: The required parameters for creating or updating a server. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: VirtualNetworkSubnetUsageModel or the result of cls(response) - :rtype: ~azure.mgmt.postgresqlflexibleservers.models.VirtualNetworkSubnetUsageModel - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def list( - self, - location_name: str, - parameters: Union[_models.VirtualNetworkSubnetUsageParameter, IO[bytes]], - **kwargs: Any - ) -> _models.VirtualNetworkSubnetUsageModel: - """Lists the virtual network subnet usage for a given virtual network. - - :param location_name: The name of the location. Required. - :type location_name: str - :param parameters: The required parameters for creating or updating a server. Is either a - VirtualNetworkSubnetUsageParameter type or a IO[bytes] type. Required. - :type parameters: - ~azure.mgmt.postgresqlflexibleservers.models.VirtualNetworkSubnetUsageParameter or IO[bytes] - :return: VirtualNetworkSubnetUsageModel or the result of cls(response) - :rtype: ~azure.mgmt.postgresqlflexibleservers.models.VirtualNetworkSubnetUsageModel - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.VirtualNetworkSubnetUsageModel] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "VirtualNetworkSubnetUsageParameter") - - _request = build_list_request( - location_name=location_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize( - _models.ErrorResponse, - pipeline_response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("VirtualNetworkSubnetUsageModel", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/administrators_microsoft_entra_add.py b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/administrators_microsoft_entra_add.py index 3771869621a9..2f298494007a 100644 --- a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/administrators_microsoft_entra_add.py +++ b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/administrators_microsoft_entra_add.py @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = PostgreSQLManagementClient( credential=DefaultAzureCredential(), - subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff", + subscription_id="SUBSCRIPTION_ID", ) response = client.administrators_microsoft_entra.begin_create_or_update( @@ -46,6 +45,6 @@ def main(): print(response) -# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2025-08-01/examples/AdministratorsMicrosoftEntraAdd.json +# x-ms-original-file: 2026-01-01-preview/AdministratorsMicrosoftEntraAdd.json if __name__ == "__main__": main() diff --git a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/administrators_microsoft_entra_delete.py b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/administrators_microsoft_entra_delete.py index 6a149b984824..b2ff0d9b1130 100644 --- a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/administrators_microsoft_entra_delete.py +++ b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/administrators_microsoft_entra_delete.py @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = PostgreSQLManagementClient( credential=DefaultAzureCredential(), - subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff", + subscription_id="SUBSCRIPTION_ID", ) client.administrators_microsoft_entra.begin_delete( @@ -38,6 +37,6 @@ def main(): ).result() -# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2025-08-01/examples/AdministratorsMicrosoftEntraDelete.json +# x-ms-original-file: 2026-01-01-preview/AdministratorsMicrosoftEntraDelete.json if __name__ == "__main__": main() diff --git a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/administrators_microsoft_entra_get.py b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/administrators_microsoft_entra_get.py index 6f100dc2b1fc..e5e5ed66d00b 100644 --- a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/administrators_microsoft_entra_get.py +++ b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/administrators_microsoft_entra_get.py @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = PostgreSQLManagementClient( credential=DefaultAzureCredential(), - subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff", + subscription_id="SUBSCRIPTION_ID", ) response = client.administrators_microsoft_entra.get( @@ -39,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2025-08-01/examples/AdministratorsMicrosoftEntraGet.json +# x-ms-original-file: 2026-01-01-preview/AdministratorsMicrosoftEntraGet.json if __name__ == "__main__": main() diff --git a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/administrators_microsoft_entra_list_by_server.py b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/administrators_microsoft_entra_list_by_server.py index 73672157411b..6dfab21bb0a9 100644 --- a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/administrators_microsoft_entra_list_by_server.py +++ b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/administrators_microsoft_entra_list_by_server.py @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = PostgreSQLManagementClient( credential=DefaultAzureCredential(), - subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff", + subscription_id="SUBSCRIPTION_ID", ) response = client.administrators_microsoft_entra.list_by_server( @@ -39,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2025-08-01/examples/AdministratorsMicrosoftEntraListByServer.json +# x-ms-original-file: 2026-01-01-preview/AdministratorsMicrosoftEntraListByServer.json if __name__ == "__main__": main() diff --git a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/advanced_threat_protection_settings_create_or_update.py b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/advanced_threat_protection_settings_create_or_update.py index ef213d21f0c0..61be9f2aa5e1 100644 --- a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/advanced_threat_protection_settings_create_or_update.py +++ b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/advanced_threat_protection_settings_create_or_update.py @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = PostgreSQLManagementClient( credential=DefaultAzureCredential(), - subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff", + subscription_id="SUBSCRIPTION_ID", ) response = client.server_threat_protection_settings.begin_create_or_update( @@ -40,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2025-08-01/examples/AdvancedThreatProtectionSettingsCreateOrUpdate.json +# x-ms-original-file: 2026-01-01-preview/AdvancedThreatProtectionSettingsCreateOrUpdate.json if __name__ == "__main__": main() diff --git a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/advanced_threat_protection_settings_get.py b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/advanced_threat_protection_settings_get.py index a9a69c05de74..c38449dac308 100644 --- a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/advanced_threat_protection_settings_get.py +++ b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/advanced_threat_protection_settings_get.py @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = PostgreSQLManagementClient( credential=DefaultAzureCredential(), - subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff", + subscription_id="SUBSCRIPTION_ID", ) response = client.advanced_threat_protection_settings.get( @@ -39,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2025-08-01/examples/AdvancedThreatProtectionSettingsGet.json +# x-ms-original-file: 2026-01-01-preview/AdvancedThreatProtectionSettingsGet.json if __name__ == "__main__": main() diff --git a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/advanced_threat_protection_settings_list_by_server.py b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/advanced_threat_protection_settings_list_by_server.py index 898e38ccc926..59de3101b3ab 100644 --- a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/advanced_threat_protection_settings_list_by_server.py +++ b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/advanced_threat_protection_settings_list_by_server.py @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = PostgreSQLManagementClient( credential=DefaultAzureCredential(), - subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff", + subscription_id="SUBSCRIPTION_ID", ) response = client.advanced_threat_protection_settings.list_by_server( @@ -39,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2025-08-01/examples/AdvancedThreatProtectionSettingsListByServer.json +# x-ms-original-file: 2026-01-01-preview/AdvancedThreatProtectionSettingsListByServer.json if __name__ == "__main__": main() diff --git a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/backups_automatic_and_on_demand_create.py b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/backups_automatic_and_on_demand_create.py index f1b680b5b429..d569c850f9ab 100644 --- a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/backups_automatic_and_on_demand_create.py +++ b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/backups_automatic_and_on_demand_create.py @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = PostgreSQLManagementClient( credential=DefaultAzureCredential(), - subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff", + subscription_id="SUBSCRIPTION_ID", ) response = client.backups_automatic_and_on_demand.begin_create( @@ -39,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2025-08-01/examples/BackupsAutomaticAndOnDemandCreate.json +# x-ms-original-file: 2026-01-01-preview/BackupsAutomaticAndOnDemandCreate.json if __name__ == "__main__": main() diff --git a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/backups_automatic_and_on_demand_delete.py b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/backups_automatic_and_on_demand_delete.py index 642f23835d4d..cd6a5bf2dcaa 100644 --- a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/backups_automatic_and_on_demand_delete.py +++ b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/backups_automatic_and_on_demand_delete.py @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = PostgreSQLManagementClient( credential=DefaultAzureCredential(), - subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff", + subscription_id="SUBSCRIPTION_ID", ) client.backups_automatic_and_on_demand.begin_delete( @@ -38,6 +37,6 @@ def main(): ).result() -# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2025-08-01/examples/BackupsAutomaticAndOnDemandDelete.json +# x-ms-original-file: 2026-01-01-preview/BackupsAutomaticAndOnDemandDelete.json if __name__ == "__main__": main() diff --git a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/backups_automatic_and_on_demand_get.py b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/backups_automatic_and_on_demand_get.py index 5d5998014c19..37b35c5f94d6 100644 --- a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/backups_automatic_and_on_demand_get.py +++ b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/backups_automatic_and_on_demand_get.py @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = PostgreSQLManagementClient( credential=DefaultAzureCredential(), - subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff", + subscription_id="SUBSCRIPTION_ID", ) response = client.backups_automatic_and_on_demand.get( @@ -39,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2025-08-01/examples/BackupsAutomaticAndOnDemandGet.json +# x-ms-original-file: 2026-01-01-preview/BackupsAutomaticAndOnDemandGet.json if __name__ == "__main__": main() diff --git a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/backups_automatic_and_on_demand_list_by_server.py b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/backups_automatic_and_on_demand_list_by_server.py index 6070a3e2bbaf..1a4dd3a3ef41 100644 --- a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/backups_automatic_and_on_demand_list_by_server.py +++ b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/backups_automatic_and_on_demand_list_by_server.py @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = PostgreSQLManagementClient( credential=DefaultAzureCredential(), - subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff", + subscription_id="SUBSCRIPTION_ID", ) response = client.backups_automatic_and_on_demand.list_by_server( @@ -39,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2025-08-01/examples/BackupsAutomaticAndOnDemandListByServer.json +# x-ms-original-file: 2026-01-01-preview/BackupsAutomaticAndOnDemandListByServer.json if __name__ == "__main__": main() diff --git a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/backups_long_term_retention_check_prerequisites.py b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/backups_long_term_retention_check_prerequisites.py index 1d2261aedf24..5d2937d28a40 100644 --- a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/backups_long_term_retention_check_prerequisites.py +++ b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/backups_long_term_retention_check_prerequisites.py @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = PostgreSQLManagementClient( credential=DefaultAzureCredential(), - subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff", + subscription_id="SUBSCRIPTION_ID", ) response = client.backups_long_term_retention.check_prerequisites( @@ -39,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2025-08-01/examples/BackupsLongTermRetentionCheckPrerequisites.json +# x-ms-original-file: 2026-01-01-preview/BackupsLongTermRetentionCheckPrerequisites.json if __name__ == "__main__": main() diff --git a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/backups_long_term_retention_get.py b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/backups_long_term_retention_get.py index e35dbc60f149..f7cb69a29e9a 100644 --- a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/backups_long_term_retention_get.py +++ b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/backups_long_term_retention_get.py @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = PostgreSQLManagementClient( credential=DefaultAzureCredential(), - subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff", + subscription_id="SUBSCRIPTION_ID", ) response = client.backups_long_term_retention.get( @@ -39,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2025-08-01/examples/BackupsLongTermRetentionGet.json +# x-ms-original-file: 2026-01-01-preview/BackupsLongTermRetentionGet.json if __name__ == "__main__": main() diff --git a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/backups_long_term_retention_list_by_server.py b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/backups_long_term_retention_list_by_server.py index 775982b2a272..22d5b04962ef 100644 --- a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/backups_long_term_retention_list_by_server.py +++ b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/backups_long_term_retention_list_by_server.py @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = PostgreSQLManagementClient( credential=DefaultAzureCredential(), - subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff", + subscription_id="SUBSCRIPTION_ID", ) response = client.backups_long_term_retention.list_by_server( @@ -39,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2025-08-01/examples/BackupsLongTermRetentionListByServer.json +# x-ms-original-file: 2026-01-01-preview/BackupsLongTermRetentionListByServer.json if __name__ == "__main__": main() diff --git a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/backups_long_term_retention_start.py b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/backups_long_term_retention_start.py index 233e446047b4..5537b1e15b5e 100644 --- a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/backups_long_term_retention_start.py +++ b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/backups_long_term_retention_start.py @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = PostgreSQLManagementClient( credential=DefaultAzureCredential(), - subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff", + subscription_id="SUBSCRIPTION_ID", ) response = client.backups_long_term_retention.begin_start( @@ -39,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2025-08-01/examples/BackupsLongTermRetentionStart.json +# x-ms-original-file: 2026-01-01-preview/BackupsLongTermRetentionStart.json if __name__ == "__main__": main() diff --git a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/capabilities_by_location_list.py b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/capabilities_by_location_list.py index 99577c1ce8c9..0adc888e9379 100644 --- a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/capabilities_by_location_list.py +++ b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/capabilities_by_location_list.py @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = PostgreSQLManagementClient( credential=DefaultAzureCredential(), - subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff", + subscription_id="SUBSCRIPTION_ID", ) response = client.capabilities_by_location.list( @@ -38,6 +37,6 @@ def main(): print(item) -# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2025-08-01/examples/CapabilitiesByLocationList.json +# x-ms-original-file: 2026-01-01-preview/CapabilitiesByLocationList.json if __name__ == "__main__": main() diff --git a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/capabilities_by_server_list.py b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/capabilities_by_server_list.py index 69e093fbb70f..0e4e2069d469 100644 --- a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/capabilities_by_server_list.py +++ b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/capabilities_by_server_list.py @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = PostgreSQLManagementClient( credential=DefaultAzureCredential(), - subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff", + subscription_id="SUBSCRIPTION_ID", ) response = client.capabilities_by_server.list( @@ -39,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2025-08-01/examples/CapabilitiesByServerList.json +# x-ms-original-file: 2026-01-01-preview/CapabilitiesByServerList.json if __name__ == "__main__": main() diff --git a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/captured_logs_list_by_server.py b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/captured_logs_list_by_server.py index e5f23df09266..6c6b4ac51ca8 100644 --- a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/captured_logs_list_by_server.py +++ b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/captured_logs_list_by_server.py @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = PostgreSQLManagementClient( credential=DefaultAzureCredential(), - subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff", + subscription_id="SUBSCRIPTION_ID", ) response = client.captured_logs.list_by_server( @@ -39,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2025-08-01/examples/CapturedLogsListByServer.json +# x-ms-original-file: 2026-01-01-preview/CapturedLogsListByServer.json if __name__ == "__main__": main() diff --git a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/configurations_get.py b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/configurations_get.py index 6e870aa890bf..91044820943f 100644 --- a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/configurations_get.py +++ b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/configurations_get.py @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = PostgreSQLManagementClient( credential=DefaultAzureCredential(), - subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff", + subscription_id="SUBSCRIPTION_ID", ) response = client.configurations.get( @@ -39,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2025-08-01/examples/ConfigurationsGet.json +# x-ms-original-file: 2026-01-01-preview/ConfigurationsGet.json if __name__ == "__main__": main() diff --git a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/configurations_list_by_server.py b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/configurations_list_by_server.py index 2cbb5d31fee8..72f0b66ee0ca 100644 --- a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/configurations_list_by_server.py +++ b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/configurations_list_by_server.py @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = PostgreSQLManagementClient( credential=DefaultAzureCredential(), - subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff", + subscription_id="SUBSCRIPTION_ID", ) response = client.configurations.list_by_server( @@ -39,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2025-08-01/examples/ConfigurationsListByServer.json +# x-ms-original-file: 2026-01-01-preview/ConfigurationsListByServer.json if __name__ == "__main__": main() diff --git a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/configurations_update.py b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/configurations_update.py index 75c9404cc068..cf7a8d3a24a4 100644 --- a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/configurations_update.py +++ b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/configurations_update.py @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = PostgreSQLManagementClient( credential=DefaultAzureCredential(), - subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff", + subscription_id="SUBSCRIPTION_ID", ) response = client.configurations.begin_update( @@ -40,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2025-08-01/examples/ConfigurationsUpdate.json +# x-ms-original-file: 2026-01-01-preview/ConfigurationsUpdate.json if __name__ == "__main__": main() diff --git a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/configurations_update_using_put.py b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/configurations_update_using_put.py index 56522a016ef4..5c0bc77527f2 100644 --- a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/configurations_update_using_put.py +++ b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/configurations_update_using_put.py @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = PostgreSQLManagementClient( credential=DefaultAzureCredential(), - subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff", + subscription_id="SUBSCRIPTION_ID", ) response = client.configurations.begin_put( @@ -40,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2025-08-01/examples/ConfigurationsUpdateUsingPut.json +# x-ms-original-file: 2026-01-01-preview/ConfigurationsUpdateUsingPut.json if __name__ == "__main__": main() diff --git a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/databases_create.py b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/databases_create.py index 6c2edf56ddab..b3568ad926ee 100644 --- a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/databases_create.py +++ b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/databases_create.py @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = PostgreSQLManagementClient( credential=DefaultAzureCredential(), - subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff", + subscription_id="SUBSCRIPTION_ID", ) response = client.databases.begin_create( @@ -40,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2025-08-01/examples/DatabasesCreate.json +# x-ms-original-file: 2026-01-01-preview/DatabasesCreate.json if __name__ == "__main__": main() diff --git a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/databases_delete.py b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/databases_delete.py index 66352b0b605f..446b48772803 100644 --- a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/databases_delete.py +++ b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/databases_delete.py @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = PostgreSQLManagementClient( credential=DefaultAzureCredential(), - subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff", + subscription_id="SUBSCRIPTION_ID", ) client.databases.begin_delete( @@ -38,6 +37,6 @@ def main(): ).result() -# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2025-08-01/examples/DatabasesDelete.json +# x-ms-original-file: 2026-01-01-preview/DatabasesDelete.json if __name__ == "__main__": main() diff --git a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/databases_get.py b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/databases_get.py index 209e77955731..e72ca3e95c36 100644 --- a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/databases_get.py +++ b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/databases_get.py @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = PostgreSQLManagementClient( credential=DefaultAzureCredential(), - subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff", + subscription_id="SUBSCRIPTION_ID", ) response = client.databases.get( @@ -39,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2025-08-01/examples/DatabasesGet.json +# x-ms-original-file: 2026-01-01-preview/DatabasesGet.json if __name__ == "__main__": main() diff --git a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/databases_list_by_server.py b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/databases_list_by_server.py index 3a10a16fa7e8..a9392540139d 100644 --- a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/databases_list_by_server.py +++ b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/databases_list_by_server.py @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = PostgreSQLManagementClient( credential=DefaultAzureCredential(), - subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff", + subscription_id="SUBSCRIPTION_ID", ) response = client.databases.list_by_server( @@ -39,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2025-08-01/examples/DatabasesListByServer.json +# x-ms-original-file: 2026-01-01-preview/DatabasesListByServer.json if __name__ == "__main__": main() diff --git a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/firewall_rules_create_or_update.py b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/firewall_rules_create_or_update.py index 9f7a251201d1..c604ff20158a 100644 --- a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/firewall_rules_create_or_update.py +++ b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/firewall_rules_create_or_update.py @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = PostgreSQLManagementClient( credential=DefaultAzureCredential(), - subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff", + subscription_id="SUBSCRIPTION_ID", ) response = client.firewall_rules.begin_create_or_update( @@ -40,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2025-08-01/examples/FirewallRulesCreateOrUpdate.json +# x-ms-original-file: 2026-01-01-preview/FirewallRulesCreateOrUpdate.json if __name__ == "__main__": main() diff --git a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/firewall_rules_delete.py b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/firewall_rules_delete.py index 6496bfe7e7b5..c1eaa92ee0f8 100644 --- a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/firewall_rules_delete.py +++ b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/firewall_rules_delete.py @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = PostgreSQLManagementClient( credential=DefaultAzureCredential(), - subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff", + subscription_id="SUBSCRIPTION_ID", ) client.firewall_rules.begin_delete( @@ -38,6 +37,6 @@ def main(): ).result() -# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2025-08-01/examples/FirewallRulesDelete.json +# x-ms-original-file: 2026-01-01-preview/FirewallRulesDelete.json if __name__ == "__main__": main() diff --git a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/firewall_rules_get.py b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/firewall_rules_get.py index ca2fa3763cfa..ccb9e119cb75 100644 --- a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/firewall_rules_get.py +++ b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/firewall_rules_get.py @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = PostgreSQLManagementClient( credential=DefaultAzureCredential(), - subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff", + subscription_id="SUBSCRIPTION_ID", ) response = client.firewall_rules.get( @@ -39,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2025-08-01/examples/FirewallRulesGet.json +# x-ms-original-file: 2026-01-01-preview/FirewallRulesGet.json if __name__ == "__main__": main() diff --git a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/firewall_rules_list_by_server.py b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/firewall_rules_list_by_server.py index 05c85d1584f9..6cec21301257 100644 --- a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/firewall_rules_list_by_server.py +++ b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/firewall_rules_list_by_server.py @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = PostgreSQLManagementClient( credential=DefaultAzureCredential(), - subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff", + subscription_id="SUBSCRIPTION_ID", ) response = client.firewall_rules.list_by_server( @@ -39,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2025-08-01/examples/FirewallRulesListByServer.json +# x-ms-original-file: 2026-01-01-preview/FirewallRulesListByServer.json if __name__ == "__main__": main() diff --git a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/migrations_cancel.py b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/migrations_cancel.py index 1f983268ca3e..b373ff1262c0 100644 --- a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/migrations_cancel.py +++ b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/migrations_cancel.py @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = PostgreSQLManagementClient( credential=DefaultAzureCredential(), - subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff", + subscription_id="SUBSCRIPTION_ID", ) response = client.migrations.cancel( @@ -39,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2025-08-01/examples/MigrationsCancel.json +# x-ms-original-file: 2026-01-01-preview/MigrationsCancel.json if __name__ == "__main__": main() diff --git a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/migrations_check_name_availability.py b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/migrations_check_name_availability.py index 29587d0e5356..e4dde717298e 100644 --- a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/migrations_check_name_availability.py +++ b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/migrations_check_name_availability.py @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = PostgreSQLManagementClient( credential=DefaultAzureCredential(), - subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff", + subscription_id="SUBSCRIPTION_ID", ) response = client.migrations.check_name_availability( @@ -39,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2025-08-01/examples/MigrationsCheckNameAvailability.json +# x-ms-original-file: 2026-01-01-preview/MigrationsCheckNameAvailability.json if __name__ == "__main__": main() diff --git a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/migrations_create.py b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/migrations_create.py index 80dc440cb1e2..66a2cab7d43d 100644 --- a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/migrations_create.py +++ b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/migrations_create.py @@ -3,7 +3,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +28,7 @@ def main(): client = PostgreSQLManagementClient( credential=DefaultAzureCredential(), - subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff", + subscription_id="SUBSCRIPTION_ID", ) response = client.migrations.create( @@ -54,6 +54,6 @@ def main(): print(response) -# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2025-08-01/examples/MigrationsCreate.json +# x-ms-original-file: 2026-01-01-preview/MigrationsCreate.json if __name__ == "__main__": main() diff --git a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/migrations_create_other_source_types_validate_migrate.py b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/migrations_create_other_source_types_validate_migrate.py index e5a5cba654c9..8b3d58c7143c 100644 --- a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/migrations_create_other_source_types_validate_migrate.py +++ b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/migrations_create_other_source_types_validate_migrate.py @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = PostgreSQLManagementClient( credential=DefaultAzureCredential(), - subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff", + subscription_id="SUBSCRIPTION_ID", ) response = client.migrations.create( @@ -57,6 +56,6 @@ def main(): print(response) -# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2025-08-01/examples/MigrationsCreateOtherSourceTypesValidateMigrate.json +# x-ms-original-file: 2026-01-01-preview/MigrationsCreateOtherSourceTypesValidateMigrate.json if __name__ == "__main__": main() diff --git a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/migrations_create_validate_only.py b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/migrations_create_validate_only.py index 3f9d19f3025f..c6dc1bc091b5 100644 --- a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/migrations_create_validate_only.py +++ b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/migrations_create_validate_only.py @@ -3,7 +3,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +28,7 @@ def main(): client = PostgreSQLManagementClient( credential=DefaultAzureCredential(), - subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff", + subscription_id="SUBSCRIPTION_ID", ) response = client.migrations.create( @@ -55,6 +55,6 @@ def main(): print(response) -# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2025-08-01/examples/MigrationsCreateValidateOnly.json +# x-ms-original-file: 2026-01-01-preview/MigrationsCreateValidateOnly.json if __name__ == "__main__": main() diff --git a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/migrations_create_with_fully_qualified_domain_name.py b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/migrations_create_with_fully_qualified_domain_name.py index c9809b4f2b2a..ff613a5d419d 100644 --- a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/migrations_create_with_fully_qualified_domain_name.py +++ b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/migrations_create_with_fully_qualified_domain_name.py @@ -3,7 +3,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +28,7 @@ def main(): client = PostgreSQLManagementClient( credential=DefaultAzureCredential(), - subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff", + subscription_id="SUBSCRIPTION_ID", ) response = client.migrations.create( @@ -53,6 +53,6 @@ def main(): print(response) -# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2025-08-01/examples/MigrationsCreateWithFullyQualifiedDomainName.json +# x-ms-original-file: 2026-01-01-preview/MigrationsCreateWithFullyQualifiedDomainName.json if __name__ == "__main__": main() diff --git a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/migrations_create_with_other_users.py b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/migrations_create_with_other_users.py index 2f4802064a3a..93df2b4ba191 100644 --- a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/migrations_create_with_other_users.py +++ b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/migrations_create_with_other_users.py @@ -3,7 +3,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +28,7 @@ def main(): client = PostgreSQLManagementClient( credential=DefaultAzureCredential(), - subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff", + subscription_id="SUBSCRIPTION_ID", ) response = client.migrations.create( @@ -55,6 +55,6 @@ def main(): print(response) -# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2025-08-01/examples/MigrationsCreateWithOtherUsers.json +# x-ms-original-file: 2026-01-01-preview/MigrationsCreateWithOtherUsers.json if __name__ == "__main__": main() diff --git a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/migrations_create_with_private_endpoint_servers.py b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/migrations_create_with_private_endpoint_servers.py index 0b2748185b7c..b0464f902d86 100644 --- a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/migrations_create_with_private_endpoint_servers.py +++ b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/migrations_create_with_private_endpoint_servers.py @@ -3,7 +3,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +28,7 @@ def main(): client = PostgreSQLManagementClient( credential=DefaultAzureCredential(), - subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff", + subscription_id="SUBSCRIPTION_ID", ) response = client.migrations.create( @@ -55,6 +55,6 @@ def main(): print(response) -# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2025-08-01/examples/MigrationsCreateWithPrivateEndpointServers.json +# x-ms-original-file: 2026-01-01-preview/MigrationsCreateWithPrivateEndpointServers.json if __name__ == "__main__": main() diff --git a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/migrations_create_with_roles.py b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/migrations_create_with_roles.py index 003ed4ac9be4..71783b788a8e 100644 --- a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/migrations_create_with_roles.py +++ b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/migrations_create_with_roles.py @@ -3,7 +3,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +28,7 @@ def main(): client = PostgreSQLManagementClient( credential=DefaultAzureCredential(), - subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff", + subscription_id="SUBSCRIPTION_ID", ) response = client.migrations.create( @@ -55,6 +55,6 @@ def main(): print(response) -# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2025-08-01/examples/MigrationsCreateWithRoles.json +# x-ms-original-file: 2026-01-01-preview/MigrationsCreateWithRoles.json if __name__ == "__main__": main() diff --git a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/migrations_get.py b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/migrations_get.py index 58580c2e9972..3bf1d1348349 100644 --- a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/migrations_get.py +++ b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/migrations_get.py @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = PostgreSQLManagementClient( credential=DefaultAzureCredential(), - subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff", + subscription_id="SUBSCRIPTION_ID", ) response = client.migrations.get( @@ -39,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2025-08-01/examples/MigrationsGet.json +# x-ms-original-file: 2026-01-01-preview/MigrationsGet.json if __name__ == "__main__": main() diff --git a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/migrations_get_migration_with_successful_validation_and_migration.py b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/migrations_get_migration_with_successful_validation_and_migration.py index 250b96f0d3c4..e82517b5753d 100644 --- a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/migrations_get_migration_with_successful_validation_and_migration.py +++ b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/migrations_get_migration_with_successful_validation_and_migration.py @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = PostgreSQLManagementClient( credential=DefaultAzureCredential(), - subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff", + subscription_id="SUBSCRIPTION_ID", ) response = client.migrations.get( @@ -39,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2025-08-01/examples/MigrationsGetMigrationWithSuccessfulValidationAndMigration.json +# x-ms-original-file: 2026-01-01-preview/MigrationsGetMigrationWithSuccessfulValidationAndMigration.json if __name__ == "__main__": main() diff --git a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/migrations_get_migration_with_successful_validation_but_migration_failure.py b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/migrations_get_migration_with_successful_validation_but_migration_failure.py index d0cac45f1de2..6ee7e8feb62c 100644 --- a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/migrations_get_migration_with_successful_validation_but_migration_failure.py +++ b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/migrations_get_migration_with_successful_validation_but_migration_failure.py @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = PostgreSQLManagementClient( credential=DefaultAzureCredential(), - subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff", + subscription_id="SUBSCRIPTION_ID", ) response = client.migrations.get( @@ -39,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2025-08-01/examples/MigrationsGetMigrationWithSuccessfulValidationButMigrationFailure.json +# x-ms-original-file: 2026-01-01-preview/MigrationsGetMigrationWithSuccessfulValidationButMigrationFailure.json if __name__ == "__main__": main() diff --git a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/migrations_get_migration_with_successful_validation_only.py b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/migrations_get_migration_with_successful_validation_only.py index c57af79c430a..78a5780de844 100644 --- a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/migrations_get_migration_with_successful_validation_only.py +++ b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/migrations_get_migration_with_successful_validation_only.py @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = PostgreSQLManagementClient( credential=DefaultAzureCredential(), - subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff", + subscription_id="SUBSCRIPTION_ID", ) response = client.migrations.get( @@ -39,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2025-08-01/examples/MigrationsGetMigrationWithSuccessfulValidationOnly.json +# x-ms-original-file: 2026-01-01-preview/MigrationsGetMigrationWithSuccessfulValidationOnly.json if __name__ == "__main__": main() diff --git a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/migrations_get_migration_with_validation_failures.py b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/migrations_get_migration_with_validation_failures.py index 61e8c563aa9c..964429c3b665 100644 --- a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/migrations_get_migration_with_validation_failures.py +++ b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/migrations_get_migration_with_validation_failures.py @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = PostgreSQLManagementClient( credential=DefaultAzureCredential(), - subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff", + subscription_id="SUBSCRIPTION_ID", ) response = client.migrations.get( @@ -39,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2025-08-01/examples/MigrationsGetMigrationWithValidationFailures.json +# x-ms-original-file: 2026-01-01-preview/MigrationsGetMigrationWithValidationFailures.json if __name__ == "__main__": main() diff --git a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/migrations_list_by_target_server.py b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/migrations_list_by_target_server.py index f1eeff92d304..4658155a72bb 100644 --- a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/migrations_list_by_target_server.py +++ b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/migrations_list_by_target_server.py @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = PostgreSQLManagementClient( credential=DefaultAzureCredential(), - subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff", + subscription_id="SUBSCRIPTION_ID", ) response = client.migrations.list_by_target_server( @@ -39,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2025-08-01/examples/MigrationsListByTargetServer.json +# x-ms-original-file: 2026-01-01-preview/MigrationsListByTargetServer.json if __name__ == "__main__": main() diff --git a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/migrations_update.py b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/migrations_update.py index 78e550e32228..c85bbbee5d5b 100644 --- a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/migrations_update.py +++ b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/migrations_update.py @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = PostgreSQLManagementClient( credential=DefaultAzureCredential(), - subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff", + subscription_id="SUBSCRIPTION_ID", ) response = client.migrations.update( @@ -40,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2025-08-01/examples/MigrationsUpdate.json +# x-ms-original-file: 2026-01-01-preview/MigrationsUpdate.json if __name__ == "__main__": main() diff --git a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/name_availability_check_globally.py b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/name_availability_check_globally.py index cdfbf80d435e..870808e45eb2 100644 --- a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/name_availability_check_globally.py +++ b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/name_availability_check_globally.py @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = PostgreSQLManagementClient( credential=DefaultAzureCredential(), - subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff", + subscription_id="SUBSCRIPTION_ID", ) response = client.name_availability.check_globally( @@ -37,6 +36,6 @@ def main(): print(response) -# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2025-08-01/examples/NameAvailabilityCheckGlobally.json +# x-ms-original-file: 2026-01-01-preview/NameAvailabilityCheckGlobally.json if __name__ == "__main__": main() diff --git a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/name_availability_check_with_location.py b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/name_availability_check_with_location.py index e2f6b11b2edf..72cd0753cd4e 100644 --- a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/name_availability_check_with_location.py +++ b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/name_availability_check_with_location.py @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = PostgreSQLManagementClient( credential=DefaultAzureCredential(), - subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff", + subscription_id="SUBSCRIPTION_ID", ) response = client.name_availability.check_with_location( @@ -38,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2025-08-01/examples/NameAvailabilityCheckWithLocation.json +# x-ms-original-file: 2026-01-01-preview/NameAvailabilityCheckWithLocation.json if __name__ == "__main__": main() diff --git a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/operations_list.py b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/operations_list.py index c9e8fdbc0879..35590fd02b79 100644 --- a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/operations_list.py +++ b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/operations_list.py @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -36,6 +35,6 @@ def main(): print(item) -# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2025-08-01/examples/OperationsList.json +# x-ms-original-file: 2026-01-01-preview/OperationsList.json if __name__ == "__main__": main() diff --git a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/private_dns_zone_suffix_get.py b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/private_dns_zone_suffix_get.py index 9f08b88f229a..83fc38d4a64c 100644 --- a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/private_dns_zone_suffix_get.py +++ b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/private_dns_zone_suffix_get.py @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,13 +27,13 @@ def main(): client = PostgreSQLManagementClient( credential=DefaultAzureCredential(), - subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff", + subscription_id="SUBSCRIPTION_ID", ) response = client.private_dns_zone_suffix.get() print(response) -# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2025-08-01/examples/PrivateDnsZoneSuffixGet.json +# x-ms-original-file: 2026-01-01-preview/PrivateDnsZoneSuffixGet.json if __name__ == "__main__": main() diff --git a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/private_endpoint_connections_delete.py b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/private_endpoint_connections_delete.py index 4e92a8923e86..c84f8be06688 100644 --- a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/private_endpoint_connections_delete.py +++ b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/private_endpoint_connections_delete.py @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = PostgreSQLManagementClient( credential=DefaultAzureCredential(), - subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff", + subscription_id="SUBSCRIPTION_ID", ) client.private_endpoint_connections.begin_delete( @@ -38,6 +37,6 @@ def main(): ).result() -# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2025-08-01/examples/PrivateEndpointConnectionsDelete.json +# x-ms-original-file: 2026-01-01-preview/PrivateEndpointConnectionsDelete.json if __name__ == "__main__": main() diff --git a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/private_endpoint_connections_get.py b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/private_endpoint_connections_get.py index 9f163e935799..a6d9ed0ea950 100644 --- a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/private_endpoint_connections_get.py +++ b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/private_endpoint_connections_get.py @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = PostgreSQLManagementClient( credential=DefaultAzureCredential(), - subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff", + subscription_id="SUBSCRIPTION_ID", ) response = client.private_endpoint_connections.get( @@ -39,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2025-08-01/examples/PrivateEndpointConnectionsGet.json +# x-ms-original-file: 2026-01-01-preview/PrivateEndpointConnectionsGet.json if __name__ == "__main__": main() diff --git a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/private_endpoint_connections_list.py b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/private_endpoint_connections_list.py index 125bda75470c..1947236e6fa3 100644 --- a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/private_endpoint_connections_list.py +++ b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/private_endpoint_connections_list.py @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = PostgreSQLManagementClient( credential=DefaultAzureCredential(), - subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff", + subscription_id="SUBSCRIPTION_ID", ) response = client.private_endpoint_connections.list_by_server( @@ -39,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2025-08-01/examples/PrivateEndpointConnectionsList.json +# x-ms-original-file: 2026-01-01-preview/PrivateEndpointConnectionsList.json if __name__ == "__main__": main() diff --git a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/private_endpoint_connections_update.py b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/private_endpoint_connections_update.py index 09e2686d95e6..b932e31d9add 100644 --- a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/private_endpoint_connections_update.py +++ b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/private_endpoint_connections_update.py @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = PostgreSQLManagementClient( credential=DefaultAzureCredential(), - subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff", + subscription_id="SUBSCRIPTION_ID", ) response = client.private_endpoint_connections.begin_update( @@ -38,7 +37,7 @@ def main(): parameters={ "properties": { "privateLinkServiceConnectionState": { - "description": "Approved by johndoe@contoso.com", + "description": "Approved by `johndoe@contoso.com `_", "status": "Approved", } } @@ -47,6 +46,6 @@ def main(): print(response) -# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2025-08-01/examples/PrivateEndpointConnectionsUpdate.json +# x-ms-original-file: 2026-01-01-preview/PrivateEndpointConnectionsUpdate.json if __name__ == "__main__": main() diff --git a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/private_link_resources_get.py b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/private_link_resources_get.py index b7c1952cba76..98f2ec6cb683 100644 --- a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/private_link_resources_get.py +++ b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/private_link_resources_get.py @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = PostgreSQLManagementClient( credential=DefaultAzureCredential(), - subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff", + subscription_id="SUBSCRIPTION_ID", ) response = client.private_link_resources.get( @@ -39,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2025-08-01/examples/PrivateLinkResourcesGet.json +# x-ms-original-file: 2026-01-01-preview/PrivateLinkResourcesGet.json if __name__ == "__main__": main() diff --git a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/private_link_resources_list.py b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/private_link_resources_list.py index 7988575817b8..74fc82f6a1e1 100644 --- a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/private_link_resources_list.py +++ b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/private_link_resources_list.py @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = PostgreSQLManagementClient( credential=DefaultAzureCredential(), - subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff", + subscription_id="SUBSCRIPTION_ID", ) response = client.private_link_resources.list_by_server( @@ -39,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2025-08-01/examples/PrivateLinkResourcesList.json +# x-ms-original-file: 2026-01-01-preview/PrivateLinkResourcesList.json if __name__ == "__main__": main() diff --git a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/quota_usages_for_flexible_servers.py b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/quota_usages_for_flexible_servers.py index a6a5bc71ad8f..56f5b6724a26 100644 --- a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/quota_usages_for_flexible_servers.py +++ b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/quota_usages_for_flexible_servers.py @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = PostgreSQLManagementClient( credential=DefaultAzureCredential(), - subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff", + subscription_id="SUBSCRIPTION_ID", ) response = client.quota_usages.list( @@ -38,6 +37,6 @@ def main(): print(item) -# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2025-08-01/examples/QuotaUsagesForFlexibleServers.json +# x-ms-original-file: 2026-01-01-preview/QuotaUsagesForFlexibleServers.json if __name__ == "__main__": main() diff --git a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/replicas_list_by_server.py b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/replicas_list_by_server.py index 5f5512f16ff6..cc218c18bf89 100644 --- a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/replicas_list_by_server.py +++ b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/replicas_list_by_server.py @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = PostgreSQLManagementClient( credential=DefaultAzureCredential(), - subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff", + subscription_id="SUBSCRIPTION_ID", ) response = client.replicas.list_by_server( @@ -39,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2025-08-01/examples/ReplicasListByServer.json +# x-ms-original-file: 2026-01-01-preview/ReplicasListByServer.json if __name__ == "__main__": main() diff --git a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/servers_cluster_create.py b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/servers_cluster_create.py index 64b3fc82a0ce..077cd4d13aa1 100644 --- a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/servers_cluster_create.py +++ b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/servers_cluster_create.py @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = PostgreSQLManagementClient( credential=DefaultAzureCredential(), - subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff", + subscription_id="SUBSCRIPTION_ID", ) response = client.servers.begin_create_or_update( @@ -53,6 +52,6 @@ def main(): print(response) -# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2025-08-01/examples/ServersClusterCreate.json +# x-ms-original-file: 2026-01-01-preview/ServersClusterCreate.json if __name__ == "__main__": main() diff --git a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/servers_create_geo_restore_with_data_encryption_enabled.py b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/servers_create_geo_restore_with_data_encryption_enabled.py index 47285e58f01c..69789832d6a6 100644 --- a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/servers_create_geo_restore_with_data_encryption_enabled.py +++ b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/servers_create_geo_restore_with_data_encryption_enabled.py @@ -3,7 +3,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +28,7 @@ def main(): client = PostgreSQLManagementClient( credential=DefaultAzureCredential(), - subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff", + subscription_id="SUBSCRIPTION_ID", ) response = client.servers.begin_create_or_update( @@ -60,6 +60,6 @@ def main(): print(response) -# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2025-08-01/examples/ServersCreateGeoRestoreWithDataEncryptionEnabled.json +# x-ms-original-file: 2026-01-01-preview/ServersCreateGeoRestoreWithDataEncryptionEnabled.json if __name__ == "__main__": main() diff --git a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/servers_create_geo_restore_with_data_encryption_enabled_auto_update.py b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/servers_create_geo_restore_with_data_encryption_enabled_auto_update.py index 6c90388a970c..d42bb13c0348 100644 --- a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/servers_create_geo_restore_with_data_encryption_enabled_auto_update.py +++ b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/servers_create_geo_restore_with_data_encryption_enabled_auto_update.py @@ -3,7 +3,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +28,7 @@ def main(): client = PostgreSQLManagementClient( credential=DefaultAzureCredential(), - subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff", + subscription_id="SUBSCRIPTION_ID", ) response = client.servers.begin_create_or_update( @@ -60,6 +60,6 @@ def main(): print(response) -# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2025-08-01/examples/ServersCreateGeoRestoreWithDataEncryptionEnabledAutoUpdate.json +# x-ms-original-file: 2026-01-01-preview/ServersCreateGeoRestoreWithDataEncryptionEnabledAutoUpdate.json if __name__ == "__main__": main() diff --git a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/servers_create_in_microsoft_owned_virtual_network_with_zone_redundant_high_availability.py b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/servers_create_in_microsoft_owned_virtual_network_with_zone_redundant_high_availability.py index cab2180826b7..eb710aa4d6c5 100644 --- a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/servers_create_in_microsoft_owned_virtual_network_with_zone_redundant_high_availability.py +++ b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/servers_create_in_microsoft_owned_virtual_network_with_zone_redundant_high_availability.py @@ -3,7 +3,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +28,7 @@ def main(): client = PostgreSQLManagementClient( credential=DefaultAzureCredential(), - subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff", + subscription_id="SUBSCRIPTION_ID", ) response = client.servers.begin_create_or_update( @@ -54,6 +54,6 @@ def main(): print(response) -# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2025-08-01/examples/ServersCreateInMicrosoftOwnedVirtualNetworkWithZoneRedundantHighAvailability.json +# x-ms-original-file: 2026-01-01-preview/ServersCreateInMicrosoftOwnedVirtualNetworkWithZoneRedundantHighAvailability.json if __name__ == "__main__": main() diff --git a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/servers_create_in_your_own_virtual_network_with_same_zone_high_availability.py b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/servers_create_in_your_own_virtual_network_with_same_zone_high_availability.py index 29afd1be8ce4..7af08e32489e 100644 --- a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/servers_create_in_your_own_virtual_network_with_same_zone_high_availability.py +++ b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/servers_create_in_your_own_virtual_network_with_same_zone_high_availability.py @@ -3,7 +3,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +28,7 @@ def main(): client = PostgreSQLManagementClient( credential=DefaultAzureCredential(), - subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff", + subscription_id="SUBSCRIPTION_ID", ) response = client.servers.begin_create_or_update( @@ -57,6 +57,6 @@ def main(): print(response) -# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2025-08-01/examples/ServersCreateInYourOwnVirtualNetworkWithSameZoneHighAvailability.json +# x-ms-original-file: 2026-01-01-preview/ServersCreateInYourOwnVirtualNetworkWithSameZoneHighAvailability.json if __name__ == "__main__": main() diff --git a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/servers_create_point_in_time_restore.py b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/servers_create_point_in_time_restore.py index e7f4d3315805..43ebeab2225f 100644 --- a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/servers_create_point_in_time_restore.py +++ b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/servers_create_point_in_time_restore.py @@ -3,7 +3,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +28,7 @@ def main(): client = PostgreSQLManagementClient( credential=DefaultAzureCredential(), - subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff", + subscription_id="SUBSCRIPTION_ID", ) response = client.servers.begin_create_or_update( @@ -46,6 +46,6 @@ def main(): print(response) -# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2025-08-01/examples/ServersCreatePointInTimeRestore.json +# x-ms-original-file: 2026-01-01-preview/ServersCreatePointInTimeRestore.json if __name__ == "__main__": main() diff --git a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/servers_create_replica.py b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/servers_create_replica.py index 75ec8a0763f5..7998ea8a3373 100644 --- a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/servers_create_replica.py +++ b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/servers_create_replica.py @@ -3,7 +3,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +28,7 @@ def main(): client = PostgreSQLManagementClient( credential=DefaultAzureCredential(), - subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff", + subscription_id="SUBSCRIPTION_ID", ) response = client.servers.begin_create_or_update( @@ -59,6 +59,6 @@ def main(): print(response) -# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2025-08-01/examples/ServersCreateReplica.json +# x-ms-original-file: 2026-01-01-preview/ServersCreateReplica.json if __name__ == "__main__": main() diff --git a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/servers_create_revive_dropped.py b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/servers_create_revive_dropped.py index 12cc6a28a531..a2e99706bf04 100644 --- a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/servers_create_revive_dropped.py +++ b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/servers_create_revive_dropped.py @@ -3,7 +3,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +28,7 @@ def main(): client = PostgreSQLManagementClient( credential=DefaultAzureCredential(), - subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff", + subscription_id="SUBSCRIPTION_ID", ) response = client.servers.begin_create_or_update( @@ -46,6 +46,6 @@ def main(): print(response) -# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2025-08-01/examples/ServersCreateReviveDropped.json +# x-ms-original-file: 2026-01-01-preview/ServersCreateReviveDropped.json if __name__ == "__main__": main() diff --git a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/servers_create_with_data_encryption_enabled.py b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/servers_create_with_data_encryption_enabled.py index 456a5585ad72..32676daefac3 100644 --- a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/servers_create_with_data_encryption_enabled.py +++ b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/servers_create_with_data_encryption_enabled.py @@ -3,7 +3,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +28,7 @@ def main(): client = PostgreSQLManagementClient( credential=DefaultAzureCredential(), - subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff", + subscription_id="SUBSCRIPTION_ID", ) response = client.servers.begin_create_or_update( @@ -69,6 +69,6 @@ def main(): print(response) -# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2025-08-01/examples/ServersCreateWithDataEncryptionEnabled.json +# x-ms-original-file: 2026-01-01-preview/ServersCreateWithDataEncryptionEnabled.json if __name__ == "__main__": main() diff --git a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/servers_create_with_data_encryption_enabled_auto_update.py b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/servers_create_with_data_encryption_enabled_auto_update.py index 88efc99bfb38..c62fca7783f5 100644 --- a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/servers_create_with_data_encryption_enabled_auto_update.py +++ b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/servers_create_with_data_encryption_enabled_auto_update.py @@ -3,7 +3,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +28,7 @@ def main(): client = PostgreSQLManagementClient( credential=DefaultAzureCredential(), - subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff", + subscription_id="SUBSCRIPTION_ID", ) response = client.servers.begin_create_or_update( @@ -69,6 +69,6 @@ def main(): print(response) -# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2025-08-01/examples/ServersCreateWithDataEncryptionEnabledAutoUpdate.json +# x-ms-original-file: 2026-01-01-preview/ServersCreateWithDataEncryptionEnabledAutoUpdate.json if __name__ == "__main__": main() diff --git a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/servers_create_with_microsoft_entra_enabled_in_your_own_virtual_network_without_high_availability.py b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/servers_create_with_microsoft_entra_enabled_in_your_own_virtual_network_without_high_availability.py index 53e900ac8c64..c41db6191001 100644 --- a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/servers_create_with_microsoft_entra_enabled_in_your_own_virtual_network_without_high_availability.py +++ b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/servers_create_with_microsoft_entra_enabled_in_your_own_virtual_network_without_high_availability.py @@ -3,7 +3,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +28,7 @@ def main(): client = PostgreSQLManagementClient( credential=DefaultAzureCredential(), - subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff", + subscription_id="SUBSCRIPTION_ID", ) response = client.servers.begin_create_or_update( @@ -62,6 +62,6 @@ def main(): print(response) -# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2025-08-01/examples/ServersCreateWithMicrosoftEntraEnabledInYourOwnVirtualNetworkWithoutHighAvailability.json +# x-ms-original-file: 2026-01-01-preview/ServersCreateWithMicrosoftEntraEnabledInYourOwnVirtualNetworkWithoutHighAvailability.json if __name__ == "__main__": main() diff --git a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/servers_delete.py b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/servers_delete.py index 314da8f255bc..e58b39f89dff 100644 --- a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/servers_delete.py +++ b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/servers_delete.py @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = PostgreSQLManagementClient( credential=DefaultAzureCredential(), - subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff", + subscription_id="SUBSCRIPTION_ID", ) client.servers.begin_delete( @@ -37,6 +36,6 @@ def main(): ).result() -# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2025-08-01/examples/ServersDelete.json +# x-ms-original-file: 2026-01-01-preview/ServersDelete.json if __name__ == "__main__": main() diff --git a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/servers_get.py b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/servers_get.py index 99405e02eb5c..59d8b3f5e762 100644 --- a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/servers_get.py +++ b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/servers_get.py @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = PostgreSQLManagementClient( credential=DefaultAzureCredential(), - subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff", + subscription_id="SUBSCRIPTION_ID", ) response = client.servers.get( @@ -38,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2025-08-01/examples/ServersGet.json +# x-ms-original-file: 2026-01-01-preview/ServersGet.json if __name__ == "__main__": main() diff --git a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/servers_get_with_private_endpoints.py b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/servers_get_with_private_endpoints.py index 6be543730108..5cba40d6ae6a 100644 --- a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/servers_get_with_private_endpoints.py +++ b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/servers_get_with_private_endpoints.py @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = PostgreSQLManagementClient( credential=DefaultAzureCredential(), - subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff", + subscription_id="SUBSCRIPTION_ID", ) response = client.servers.get( @@ -38,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2025-08-01/examples/ServersGetWithPrivateEndpoints.json +# x-ms-original-file: 2026-01-01-preview/ServersGetWithPrivateEndpoints.json if __name__ == "__main__": main() diff --git a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/servers_get_with_vnet.py b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/servers_get_with_vnet.py index 7c8fc723622a..6e21abb29595 100644 --- a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/servers_get_with_vnet.py +++ b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/servers_get_with_vnet.py @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = PostgreSQLManagementClient( credential=DefaultAzureCredential(), - subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff", + subscription_id="SUBSCRIPTION_ID", ) response = client.servers.get( @@ -38,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2025-08-01/examples/ServersGetWithVnet.json +# x-ms-original-file: 2026-01-01-preview/ServersGetWithVnet.json if __name__ == "__main__": main() diff --git a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/servers_list_by_resource_group.py b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/servers_list_by_resource_group.py index ce5630db3bb3..682695a703eb 100644 --- a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/servers_list_by_resource_group.py +++ b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/servers_list_by_resource_group.py @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = PostgreSQLManagementClient( credential=DefaultAzureCredential(), - subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff", + subscription_id="SUBSCRIPTION_ID", ) response = client.servers.list_by_resource_group( @@ -38,6 +37,6 @@ def main(): print(item) -# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2025-08-01/examples/ServersListByResourceGroup.json +# x-ms-original-file: 2026-01-01-preview/ServersListByResourceGroup.json if __name__ == "__main__": main() diff --git a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/servers_list_by_subscription.py b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/servers_list_by_subscription.py index 32b264319a9e..936860513f51 100644 --- a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/servers_list_by_subscription.py +++ b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/servers_list_by_subscription.py @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = PostgreSQLManagementClient( credential=DefaultAzureCredential(), - subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff", + subscription_id="SUBSCRIPTION_ID", ) response = client.servers.list_by_subscription() @@ -36,6 +35,6 @@ def main(): print(item) -# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2025-08-01/examples/ServersListBySubscription.json +# x-ms-original-file: 2026-01-01-preview/ServersListBySubscription.json if __name__ == "__main__": main() diff --git a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/servers_migrate_network_mode.py b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/servers_migrate_network_mode.py new file mode 100644 index 000000000000..4b379655e541 --- /dev/null +++ b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/servers_migrate_network_mode.py @@ -0,0 +1,42 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.postgresqlflexibleservers import PostgreSQLManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-postgresqlflexibleservers +# USAGE + python servers_migrate_network_mode.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = PostgreSQLManagementClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.servers.begin_migrate_network_mode( + resource_group_name="exampleresourcegroup", + server_name="exampleserver", + ).result() + print(response) + + +# x-ms-original-file: 2026-01-01-preview/ServersMigrateNetworkMode.json +if __name__ == "__main__": + main() diff --git a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/servers_promote_replica_as_forced_standalone_server.py b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/servers_promote_replica_as_forced_standalone_server.py index a90c01a99a9b..1d671eb949d3 100644 --- a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/servers_promote_replica_as_forced_standalone_server.py +++ b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/servers_promote_replica_as_forced_standalone_server.py @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = PostgreSQLManagementClient( credential=DefaultAzureCredential(), - subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff", + subscription_id="SUBSCRIPTION_ID", ) response = client.servers.begin_update( @@ -39,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2025-08-01/examples/ServersPromoteReplicaAsForcedStandaloneServer.json +# x-ms-original-file: 2026-01-01-preview/ServersPromoteReplicaAsForcedStandaloneServer.json if __name__ == "__main__": main() diff --git a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/servers_promote_replica_as_forced_switchover.py b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/servers_promote_replica_as_forced_switchover.py index 24695e86f45a..5fdc8430594a 100644 --- a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/servers_promote_replica_as_forced_switchover.py +++ b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/servers_promote_replica_as_forced_switchover.py @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = PostgreSQLManagementClient( credential=DefaultAzureCredential(), - subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff", + subscription_id="SUBSCRIPTION_ID", ) response = client.servers.begin_update( @@ -39,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2025-08-01/examples/ServersPromoteReplicaAsForcedSwitchover.json +# x-ms-original-file: 2026-01-01-preview/ServersPromoteReplicaAsForcedSwitchover.json if __name__ == "__main__": main() diff --git a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/servers_promote_replica_as_planned_standalone_server.py b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/servers_promote_replica_as_planned_standalone_server.py index 8b2c7262439f..c22725c8aece 100644 --- a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/servers_promote_replica_as_planned_standalone_server.py +++ b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/servers_promote_replica_as_planned_standalone_server.py @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = PostgreSQLManagementClient( credential=DefaultAzureCredential(), - subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff", + subscription_id="SUBSCRIPTION_ID", ) response = client.servers.begin_update( @@ -39,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2025-08-01/examples/ServersPromoteReplicaAsPlannedStandaloneServer.json +# x-ms-original-file: 2026-01-01-preview/ServersPromoteReplicaAsPlannedStandaloneServer.json if __name__ == "__main__": main() diff --git a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/servers_promote_replica_as_planned_switchover.py b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/servers_promote_replica_as_planned_switchover.py index 55b4a3ea5bec..e33c5a42802f 100644 --- a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/servers_promote_replica_as_planned_switchover.py +++ b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/servers_promote_replica_as_planned_switchover.py @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = PostgreSQLManagementClient( credential=DefaultAzureCredential(), - subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff", + subscription_id="SUBSCRIPTION_ID", ) response = client.servers.begin_update( @@ -39,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2025-08-01/examples/ServersPromoteReplicaAsPlannedSwitchover.json +# x-ms-original-file: 2026-01-01-preview/ServersPromoteReplicaAsPlannedSwitchover.json if __name__ == "__main__": main() diff --git a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/servers_restart.py b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/servers_restart.py index 9b1f4343d022..e5773081ccf5 100644 --- a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/servers_restart.py +++ b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/servers_restart.py @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = PostgreSQLManagementClient( credential=DefaultAzureCredential(), - subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff", + subscription_id="SUBSCRIPTION_ID", ) client.servers.begin_restart( @@ -37,6 +36,6 @@ def main(): ).result() -# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2025-08-01/examples/ServersRestart.json +# x-ms-original-file: 2026-01-01-preview/ServersRestart.json if __name__ == "__main__": main() diff --git a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/servers_restart_with_failover.py b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/servers_restart_with_failover.py index a0bc7155ec92..da4874a70271 100644 --- a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/servers_restart_with_failover.py +++ b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/servers_restart_with_failover.py @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = PostgreSQLManagementClient( credential=DefaultAzureCredential(), - subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff", + subscription_id="SUBSCRIPTION_ID", ) client.servers.begin_restart( @@ -37,6 +36,6 @@ def main(): ).result() -# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2025-08-01/examples/ServersRestartWithFailover.json +# x-ms-original-file: 2026-01-01-preview/ServersRestartWithFailover.json if __name__ == "__main__": main() diff --git a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/servers_start.py b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/servers_start.py index 77508ed36c74..2d2682324d52 100644 --- a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/servers_start.py +++ b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/servers_start.py @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = PostgreSQLManagementClient( credential=DefaultAzureCredential(), - subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff", + subscription_id="SUBSCRIPTION_ID", ) client.servers.begin_start( @@ -37,6 +36,6 @@ def main(): ).result() -# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2025-08-01/examples/ServersStart.json +# x-ms-original-file: 2026-01-01-preview/ServersStart.json if __name__ == "__main__": main() diff --git a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/servers_stop.py b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/servers_stop.py index 61466c14968f..79acbec0b15e 100644 --- a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/servers_stop.py +++ b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/servers_stop.py @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = PostgreSQLManagementClient( credential=DefaultAzureCredential(), - subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff", + subscription_id="SUBSCRIPTION_ID", ) client.servers.begin_stop( @@ -37,6 +36,6 @@ def main(): ).result() -# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2025-08-01/examples/ServersStop.json +# x-ms-original-file: 2026-01-01-preview/ServersStop.json if __name__ == "__main__": main() diff --git a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/servers_update.py b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/servers_update.py index 15098bb1c66a..e7b768f96dbb 100644 --- a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/servers_update.py +++ b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/servers_update.py @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = PostgreSQLManagementClient( credential=DefaultAzureCredential(), - subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff", + subscription_id="SUBSCRIPTION_ID", ) response = client.servers.begin_update( @@ -47,6 +46,6 @@ def main(): print(response) -# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2025-08-01/examples/ServersUpdate.json +# x-ms-original-file: 2026-01-01-preview/ServersUpdate.json if __name__ == "__main__": main() diff --git a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/servers_update_with_custom_maintenance_window.py b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/servers_update_with_custom_maintenance_window.py index daf94ad46997..1f5c5a67bc6c 100644 --- a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/servers_update_with_custom_maintenance_window.py +++ b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/servers_update_with_custom_maintenance_window.py @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = PostgreSQLManagementClient( credential=DefaultAzureCredential(), - subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff", + subscription_id="SUBSCRIPTION_ID", ) response = client.servers.begin_update( @@ -44,6 +43,6 @@ def main(): print(response) -# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2025-08-01/examples/ServersUpdateWithCustomMaintenanceWindow.json +# x-ms-original-file: 2026-01-01-preview/ServersUpdateWithCustomMaintenanceWindow.json if __name__ == "__main__": main() diff --git a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/servers_update_with_data_encryption_enabled.py b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/servers_update_with_data_encryption_enabled.py index b807e8a2dae1..f02746051776 100644 --- a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/servers_update_with_data_encryption_enabled.py +++ b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/servers_update_with_data_encryption_enabled.py @@ -3,7 +3,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +28,7 @@ def main(): client = PostgreSQLManagementClient( credential=DefaultAzureCredential(), - subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff", + subscription_id="SUBSCRIPTION_ID", ) response = client.servers.begin_update( @@ -60,6 +60,6 @@ def main(): print(response) -# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2025-08-01/examples/ServersUpdateWithDataEncryptionEnabled.json +# x-ms-original-file: 2026-01-01-preview/ServersUpdateWithDataEncryptionEnabled.json if __name__ == "__main__": main() diff --git a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/servers_update_with_data_encryption_enabled_auto_update.py b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/servers_update_with_data_encryption_enabled_auto_update.py index 8794161aec69..0be57e4fe3bb 100644 --- a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/servers_update_with_data_encryption_enabled_auto_update.py +++ b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/servers_update_with_data_encryption_enabled_auto_update.py @@ -3,7 +3,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +28,7 @@ def main(): client = PostgreSQLManagementClient( credential=DefaultAzureCredential(), - subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff", + subscription_id="SUBSCRIPTION_ID", ) response = client.servers.begin_update( @@ -60,6 +60,6 @@ def main(): print(response) -# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2025-08-01/examples/ServersUpdateWithDataEncryptionEnabledAutoUpdate.json +# x-ms-original-file: 2026-01-01-preview/ServersUpdateWithDataEncryptionEnabledAutoUpdate.json if __name__ == "__main__": main() diff --git a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/servers_update_with_major_version_upgrade.py b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/servers_update_with_major_version_upgrade.py index e371579dc765..0373fbb91d7e 100644 --- a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/servers_update_with_major_version_upgrade.py +++ b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/servers_update_with_major_version_upgrade.py @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = PostgreSQLManagementClient( credential=DefaultAzureCredential(), - subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff", + subscription_id="SUBSCRIPTION_ID", ) response = client.servers.begin_update( @@ -39,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2025-08-01/examples/ServersUpdateWithMajorVersionUpgrade.json +# x-ms-original-file: 2026-01-01-preview/ServersUpdateWithMajorVersionUpgrade.json if __name__ == "__main__": main() diff --git a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/servers_update_with_microsoft_entra_enabled.py b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/servers_update_with_microsoft_entra_enabled.py index 42c65eb3ed3d..4a5902dd81d4 100644 --- a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/servers_update_with_microsoft_entra_enabled.py +++ b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/servers_update_with_microsoft_entra_enabled.py @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = PostgreSQLManagementClient( credential=DefaultAzureCredential(), - subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff", + subscription_id="SUBSCRIPTION_ID", ) response = client.servers.begin_update( @@ -52,6 +51,6 @@ def main(): print(response) -# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2025-08-01/examples/ServersUpdateWithMicrosoftEntraEnabled.json +# x-ms-original-file: 2026-01-01-preview/ServersUpdateWithMicrosoftEntraEnabled.json if __name__ == "__main__": main() diff --git a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/tuning_options_get.py b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/tuning_options_get.py index 109800ebccde..072dea5c7ba0 100644 --- a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/tuning_options_get.py +++ b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/tuning_options_get.py @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = PostgreSQLManagementClient( credential=DefaultAzureCredential(), - subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff", + subscription_id="SUBSCRIPTION_ID", ) response = client.tuning_options.get( @@ -39,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2025-08-01/examples/TuningOptionsGet.json +# x-ms-original-file: 2026-01-01-preview/TuningOptionsGet.json if __name__ == "__main__": main() diff --git a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/tuning_options_list_by_server.py b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/tuning_options_list_by_server.py index 38a55a75db55..ddbfdead5e2f 100644 --- a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/tuning_options_list_by_server.py +++ b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/tuning_options_list_by_server.py @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = PostgreSQLManagementClient( credential=DefaultAzureCredential(), - subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff", + subscription_id="SUBSCRIPTION_ID", ) response = client.tuning_options.list_by_server( @@ -39,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2025-08-01/examples/TuningOptionsListByServer.json +# x-ms-original-file: 2026-01-01-preview/TuningOptionsListByServer.json if __name__ == "__main__": main() diff --git a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/tuning_options_list_index_recommendations.py b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/tuning_options_list_index_recommendations.py index 480ea0ee27e2..e7b09bcf5368 100644 --- a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/tuning_options_list_index_recommendations.py +++ b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/tuning_options_list_index_recommendations.py @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = PostgreSQLManagementClient( credential=DefaultAzureCredential(), - subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff", + subscription_id="SUBSCRIPTION_ID", ) response = client.tuning_options.list_recommendations( @@ -40,6 +39,6 @@ def main(): print(item) -# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2025-08-01/examples/TuningOptionsListIndexRecommendations.json +# x-ms-original-file: 2026-01-01-preview/TuningOptionsListIndexRecommendations.json if __name__ == "__main__": main() diff --git a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/tuning_options_list_index_recommendations_filtered_for_create_index.py b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/tuning_options_list_index_recommendations_filtered_for_create_index.py index 587cb9303c09..b2484b04a91a 100644 --- a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/tuning_options_list_index_recommendations_filtered_for_create_index.py +++ b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/tuning_options_list_index_recommendations_filtered_for_create_index.py @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = PostgreSQLManagementClient( credential=DefaultAzureCredential(), - subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff", + subscription_id="SUBSCRIPTION_ID", ) response = client.tuning_options.list_recommendations( @@ -40,6 +39,6 @@ def main(): print(item) -# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2025-08-01/examples/TuningOptionsListIndexRecommendationsFilteredForCreateIndex.json +# x-ms-original-file: 2026-01-01-preview/TuningOptionsListIndexRecommendationsFilteredForCreateIndex.json if __name__ == "__main__": main() diff --git a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/tuning_options_list_table_recommendations.py b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/tuning_options_list_table_recommendations.py index 667bdd7a1968..dcf47c29674b 100644 --- a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/tuning_options_list_table_recommendations.py +++ b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/tuning_options_list_table_recommendations.py @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = PostgreSQLManagementClient( credential=DefaultAzureCredential(), - subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff", + subscription_id="SUBSCRIPTION_ID", ) response = client.tuning_options.list_recommendations( @@ -40,6 +39,6 @@ def main(): print(item) -# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2025-08-01/examples/TuningOptionsListTableRecommendations.json +# x-ms-original-file: 2026-01-01-preview/TuningOptionsListTableRecommendations.json if __name__ == "__main__": main() diff --git a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/tuning_options_list_table_recommendations_filtered_for_analyze_table.py b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/tuning_options_list_table_recommendations_filtered_for_analyze_table.py index f95ea42794b5..92b7f78dcacd 100644 --- a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/tuning_options_list_table_recommendations_filtered_for_analyze_table.py +++ b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/tuning_options_list_table_recommendations_filtered_for_analyze_table.py @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = PostgreSQLManagementClient( credential=DefaultAzureCredential(), - subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff", + subscription_id="SUBSCRIPTION_ID", ) response = client.tuning_options.list_recommendations( @@ -40,6 +39,6 @@ def main(): print(item) -# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2025-08-01/examples/TuningOptionsListTableRecommendationsFilteredForAnalyzeTable.json +# x-ms-original-file: 2026-01-01-preview/TuningOptionsListTableRecommendationsFilteredForAnalyzeTable.json if __name__ == "__main__": main() diff --git a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/virtual_endpoint_create.py b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/virtual_endpoint_create.py index ea6173b864d5..a2eeab100c5e 100644 --- a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/virtual_endpoint_create.py +++ b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/virtual_endpoint_create.py @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = PostgreSQLManagementClient( credential=DefaultAzureCredential(), - subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff", + subscription_id="SUBSCRIPTION_ID", ) response = client.virtual_endpoints.begin_create( @@ -40,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2025-08-01/examples/VirtualEndpointCreate.json +# x-ms-original-file: 2026-01-01-preview/VirtualEndpointCreate.json if __name__ == "__main__": main() diff --git a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/virtual_endpoint_delete.py b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/virtual_endpoint_delete.py index e69f4873faca..f4b5a4f33957 100644 --- a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/virtual_endpoint_delete.py +++ b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/virtual_endpoint_delete.py @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = PostgreSQLManagementClient( credential=DefaultAzureCredential(), - subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff", + subscription_id="SUBSCRIPTION_ID", ) client.virtual_endpoints.begin_delete( @@ -38,6 +37,6 @@ def main(): ).result() -# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2025-08-01/examples/VirtualEndpointDelete.json +# x-ms-original-file: 2026-01-01-preview/VirtualEndpointDelete.json if __name__ == "__main__": main() diff --git a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/virtual_endpoint_update.py b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/virtual_endpoint_update.py index 535e319c255e..9f2d93ada6ee 100644 --- a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/virtual_endpoint_update.py +++ b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/virtual_endpoint_update.py @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = PostgreSQLManagementClient( credential=DefaultAzureCredential(), - subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff", + subscription_id="SUBSCRIPTION_ID", ) response = client.virtual_endpoints.begin_update( @@ -40,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2025-08-01/examples/VirtualEndpointUpdate.json +# x-ms-original-file: 2026-01-01-preview/VirtualEndpointUpdate.json if __name__ == "__main__": main() diff --git a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/virtual_endpoints_get.py b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/virtual_endpoints_get.py index 6a4b5028e06a..51c0c3cac30f 100644 --- a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/virtual_endpoints_get.py +++ b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/virtual_endpoints_get.py @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = PostgreSQLManagementClient( credential=DefaultAzureCredential(), - subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff", + subscription_id="SUBSCRIPTION_ID", ) response = client.virtual_endpoints.get( @@ -39,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2025-08-01/examples/VirtualEndpointsGet.json +# x-ms-original-file: 2026-01-01-preview/VirtualEndpointsGet.json if __name__ == "__main__": main() diff --git a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/virtual_endpoints_list_by_server.py b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/virtual_endpoints_list_by_server.py index 450a28d1a13a..af99e6c08110 100644 --- a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/virtual_endpoints_list_by_server.py +++ b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/virtual_endpoints_list_by_server.py @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = PostgreSQLManagementClient( credential=DefaultAzureCredential(), - subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff", + subscription_id="SUBSCRIPTION_ID", ) response = client.virtual_endpoints.list_by_server( @@ -39,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2025-08-01/examples/VirtualEndpointsListByServer.json +# x-ms-original-file: 2026-01-01-preview/VirtualEndpointsListByServer.json if __name__ == "__main__": main() diff --git a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/virtual_network_subnet_usage_list.py b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/virtual_network_subnet_usage_list.py index 0bf8b3127c5b..ab56900c42b2 100644 --- a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/virtual_network_subnet_usage_list.py +++ b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_samples/virtual_network_subnet_usage_list.py @@ -3,7 +3,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +28,7 @@ def main(): client = PostgreSQLManagementClient( credential=DefaultAzureCredential(), - subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff", + subscription_id="SUBSCRIPTION_ID", ) response = client.virtual_network_subnet_usage.list( @@ -40,6 +40,6 @@ def main(): print(response) -# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2025-08-01/examples/VirtualNetworkSubnetUsageList.json +# x-ms-original-file: 2026-01-01-preview/VirtualNetworkSubnetUsageList.json if __name__ == "__main__": main() diff --git a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_tests/conftest.py b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_tests/conftest.py new file mode 100644 index 000000000000..eb1224bf7bb8 --- /dev/null +++ b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_tests/conftest.py @@ -0,0 +1,39 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import os +import pytest +from dotenv import load_dotenv +from devtools_testutils import ( + test_proxy, + add_general_regex_sanitizer, + add_body_key_sanitizer, + add_header_regex_sanitizer, +) + +load_dotenv() + + +# For security, please avoid record sensitive identity information in recordings +@pytest.fixture(scope="session", autouse=True) +def add_sanitizers(test_proxy): + postgresqlmanagement_subscription_id = os.environ.get( + "AZURE_SUBSCRIPTION_ID", "00000000-0000-0000-0000-000000000000" + ) + postgresqlmanagement_tenant_id = os.environ.get("AZURE_TENANT_ID", "00000000-0000-0000-0000-000000000000") + postgresqlmanagement_client_id = os.environ.get("AZURE_CLIENT_ID", "00000000-0000-0000-0000-000000000000") + postgresqlmanagement_client_secret = os.environ.get("AZURE_CLIENT_SECRET", "00000000-0000-0000-0000-000000000000") + add_general_regex_sanitizer( + regex=postgresqlmanagement_subscription_id, value="00000000-0000-0000-0000-000000000000" + ) + add_general_regex_sanitizer(regex=postgresqlmanagement_tenant_id, value="00000000-0000-0000-0000-000000000000") + add_general_regex_sanitizer(regex=postgresqlmanagement_client_id, value="00000000-0000-0000-0000-000000000000") + add_general_regex_sanitizer(regex=postgresqlmanagement_client_secret, value="00000000-0000-0000-0000-000000000000") + + add_header_regex_sanitizer(key="Set-Cookie", value="[set-cookie;]") + add_header_regex_sanitizer(key="Cookie", value="cookie;") + add_body_key_sanitizer(json_path="$..access_token", value="access_token") diff --git a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_tests/test_postgre_sql_management_administrators_microsoft_entra_operations.py b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_tests/test_postgre_sql_management_administrators_microsoft_entra_operations.py new file mode 100644 index 000000000000..7f71df601b96 --- /dev/null +++ b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_tests/test_postgre_sql_management_administrators_microsoft_entra_operations.py @@ -0,0 +1,67 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.postgresqlflexibleservers import PostgreSQLManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestPostgreSQLManagementAdministratorsMicrosoftEntraOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(PostgreSQLManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_administrators_microsoft_entra_get(self, resource_group): + response = self.client.administrators_microsoft_entra.get( + resource_group_name=resource_group.name, + server_name="str", + object_id="str", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_administrators_microsoft_entra_begin_create_or_update(self, resource_group): + response = self.client.administrators_microsoft_entra.begin_create_or_update( + resource_group_name=resource_group.name, + server_name="str", + object_id="str", + parameters={"properties": {"principalName": "str", "principalType": "str", "tenantId": "str"}}, + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_administrators_microsoft_entra_begin_delete(self, resource_group): + response = self.client.administrators_microsoft_entra.begin_delete( + resource_group_name=resource_group.name, + server_name="str", + object_id="str", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_administrators_microsoft_entra_list_by_server(self, resource_group): + response = self.client.administrators_microsoft_entra.list_by_server( + resource_group_name=resource_group.name, + server_name="str", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_tests/test_postgre_sql_management_administrators_microsoft_entra_operations_async.py b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_tests/test_postgre_sql_management_administrators_microsoft_entra_operations_async.py new file mode 100644 index 000000000000..0815de9663f6 --- /dev/null +++ b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_tests/test_postgre_sql_management_administrators_microsoft_entra_operations_async.py @@ -0,0 +1,72 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.postgresqlflexibleservers.aio import PostgreSQLManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestPostgreSQLManagementAdministratorsMicrosoftEntraOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(PostgreSQLManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_administrators_microsoft_entra_get(self, resource_group): + response = await self.client.administrators_microsoft_entra.get( + resource_group_name=resource_group.name, + server_name="str", + object_id="str", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_administrators_microsoft_entra_begin_create_or_update(self, resource_group): + response = await ( + await self.client.administrators_microsoft_entra.begin_create_or_update( + resource_group_name=resource_group.name, + server_name="str", + object_id="str", + parameters={"properties": {"principalName": "str", "principalType": "str", "tenantId": "str"}}, + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_administrators_microsoft_entra_begin_delete(self, resource_group): + response = await ( + await self.client.administrators_microsoft_entra.begin_delete( + resource_group_name=resource_group.name, + server_name="str", + object_id="str", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_administrators_microsoft_entra_list_by_server(self, resource_group): + response = self.client.administrators_microsoft_entra.list_by_server( + resource_group_name=resource_group.name, + server_name="str", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_tests/test_postgre_sql_management_advanced_threat_protection_settings_operations.py b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_tests/test_postgre_sql_management_advanced_threat_protection_settings_operations.py new file mode 100644 index 000000000000..02a462c93388 --- /dev/null +++ b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_tests/test_postgre_sql_management_advanced_threat_protection_settings_operations.py @@ -0,0 +1,42 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.postgresqlflexibleservers import PostgreSQLManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestPostgreSQLManagementAdvancedThreatProtectionSettingsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(PostgreSQLManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_advanced_threat_protection_settings_get(self, resource_group): + response = self.client.advanced_threat_protection_settings.get( + resource_group_name=resource_group.name, + server_name="str", + threat_protection_name="str", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_advanced_threat_protection_settings_list_by_server(self, resource_group): + response = self.client.advanced_threat_protection_settings.list_by_server( + resource_group_name=resource_group.name, + server_name="str", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_tests/test_postgre_sql_management_advanced_threat_protection_settings_operations_async.py b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_tests/test_postgre_sql_management_advanced_threat_protection_settings_operations_async.py new file mode 100644 index 000000000000..c8364d732514 --- /dev/null +++ b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_tests/test_postgre_sql_management_advanced_threat_protection_settings_operations_async.py @@ -0,0 +1,43 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.postgresqlflexibleservers.aio import PostgreSQLManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestPostgreSQLManagementAdvancedThreatProtectionSettingsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(PostgreSQLManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_advanced_threat_protection_settings_get(self, resource_group): + response = await self.client.advanced_threat_protection_settings.get( + resource_group_name=resource_group.name, + server_name="str", + threat_protection_name="str", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_advanced_threat_protection_settings_list_by_server(self, resource_group): + response = self.client.advanced_threat_protection_settings.list_by_server( + resource_group_name=resource_group.name, + server_name="str", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_tests/test_postgre_sql_management_backups_automatic_and_on_demand_operations.py b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_tests/test_postgre_sql_management_backups_automatic_and_on_demand_operations.py new file mode 100644 index 000000000000..d043ec4ba9d2 --- /dev/null +++ b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_tests/test_postgre_sql_management_backups_automatic_and_on_demand_operations.py @@ -0,0 +1,66 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.postgresqlflexibleservers import PostgreSQLManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestPostgreSQLManagementBackupsAutomaticAndOnDemandOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(PostgreSQLManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_backups_automatic_and_on_demand_get(self, resource_group): + response = self.client.backups_automatic_and_on_demand.get( + resource_group_name=resource_group.name, + server_name="str", + backup_name="str", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_backups_automatic_and_on_demand_begin_create(self, resource_group): + response = self.client.backups_automatic_and_on_demand.begin_create( + resource_group_name=resource_group.name, + server_name="str", + backup_name="str", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_backups_automatic_and_on_demand_begin_delete(self, resource_group): + response = self.client.backups_automatic_and_on_demand.begin_delete( + resource_group_name=resource_group.name, + server_name="str", + backup_name="str", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_backups_automatic_and_on_demand_list_by_server(self, resource_group): + response = self.client.backups_automatic_and_on_demand.list_by_server( + resource_group_name=resource_group.name, + server_name="str", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_tests/test_postgre_sql_management_backups_automatic_and_on_demand_operations_async.py b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_tests/test_postgre_sql_management_backups_automatic_and_on_demand_operations_async.py new file mode 100644 index 000000000000..03e624dd6ed2 --- /dev/null +++ b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_tests/test_postgre_sql_management_backups_automatic_and_on_demand_operations_async.py @@ -0,0 +1,71 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.postgresqlflexibleservers.aio import PostgreSQLManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestPostgreSQLManagementBackupsAutomaticAndOnDemandOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(PostgreSQLManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_backups_automatic_and_on_demand_get(self, resource_group): + response = await self.client.backups_automatic_and_on_demand.get( + resource_group_name=resource_group.name, + server_name="str", + backup_name="str", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_backups_automatic_and_on_demand_begin_create(self, resource_group): + response = await ( + await self.client.backups_automatic_and_on_demand.begin_create( + resource_group_name=resource_group.name, + server_name="str", + backup_name="str", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_backups_automatic_and_on_demand_begin_delete(self, resource_group): + response = await ( + await self.client.backups_automatic_and_on_demand.begin_delete( + resource_group_name=resource_group.name, + server_name="str", + backup_name="str", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_backups_automatic_and_on_demand_list_by_server(self, resource_group): + response = self.client.backups_automatic_and_on_demand.list_by_server( + resource_group_name=resource_group.name, + server_name="str", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_tests/test_postgre_sql_management_backups_long_term_retention_operations.py b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_tests/test_postgre_sql_management_backups_long_term_retention_operations.py new file mode 100644 index 000000000000..7a52ef292e7c --- /dev/null +++ b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_tests/test_postgre_sql_management_backups_long_term_retention_operations.py @@ -0,0 +1,66 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.postgresqlflexibleservers import PostgreSQLManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestPostgreSQLManagementBackupsLongTermRetentionOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(PostgreSQLManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_backups_long_term_retention_check_prerequisites(self, resource_group): + response = self.client.backups_long_term_retention.check_prerequisites( + resource_group_name=resource_group.name, + server_name="str", + parameters={"backupSettings": {"backupName": "str"}}, + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_backups_long_term_retention_begin_start(self, resource_group): + response = self.client.backups_long_term_retention.begin_start( + resource_group_name=resource_group.name, + server_name="str", + parameters={"backupSettings": {"backupName": "str"}, "targetDetails": {"sasUriList": ["str"]}}, + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_backups_long_term_retention_get(self, resource_group): + response = self.client.backups_long_term_retention.get( + resource_group_name=resource_group.name, + server_name="str", + backup_name="str", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_backups_long_term_retention_list_by_server(self, resource_group): + response = self.client.backups_long_term_retention.list_by_server( + resource_group_name=resource_group.name, + server_name="str", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_tests/test_postgre_sql_management_backups_long_term_retention_operations_async.py b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_tests/test_postgre_sql_management_backups_long_term_retention_operations_async.py new file mode 100644 index 000000000000..2557f4d24f90 --- /dev/null +++ b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_tests/test_postgre_sql_management_backups_long_term_retention_operations_async.py @@ -0,0 +1,69 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.postgresqlflexibleservers.aio import PostgreSQLManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestPostgreSQLManagementBackupsLongTermRetentionOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(PostgreSQLManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_backups_long_term_retention_check_prerequisites(self, resource_group): + response = await self.client.backups_long_term_retention.check_prerequisites( + resource_group_name=resource_group.name, + server_name="str", + parameters={"backupSettings": {"backupName": "str"}}, + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_backups_long_term_retention_begin_start(self, resource_group): + response = await ( + await self.client.backups_long_term_retention.begin_start( + resource_group_name=resource_group.name, + server_name="str", + parameters={"backupSettings": {"backupName": "str"}, "targetDetails": {"sasUriList": ["str"]}}, + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_backups_long_term_retention_get(self, resource_group): + response = await self.client.backups_long_term_retention.get( + resource_group_name=resource_group.name, + server_name="str", + backup_name="str", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_backups_long_term_retention_list_by_server(self, resource_group): + response = self.client.backups_long_term_retention.list_by_server( + resource_group_name=resource_group.name, + server_name="str", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_tests/test_postgre_sql_management_capabilities_by_location_operations.py b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_tests/test_postgre_sql_management_capabilities_by_location_operations.py new file mode 100644 index 000000000000..bf32762e5ae7 --- /dev/null +++ b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_tests/test_postgre_sql_management_capabilities_by_location_operations.py @@ -0,0 +1,29 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.postgresqlflexibleservers import PostgreSQLManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestPostgreSQLManagementCapabilitiesByLocationOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(PostgreSQLManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_capabilities_by_location_list(self, resource_group): + response = self.client.capabilities_by_location.list( + location_name="str", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_tests/test_postgre_sql_management_capabilities_by_location_operations_async.py b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_tests/test_postgre_sql_management_capabilities_by_location_operations_async.py new file mode 100644 index 000000000000..62c8eb16b64f --- /dev/null +++ b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_tests/test_postgre_sql_management_capabilities_by_location_operations_async.py @@ -0,0 +1,30 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.postgresqlflexibleservers.aio import PostgreSQLManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestPostgreSQLManagementCapabilitiesByLocationOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(PostgreSQLManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_capabilities_by_location_list(self, resource_group): + response = self.client.capabilities_by_location.list( + location_name="str", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_tests/test_postgre_sql_management_capabilities_by_server_operations.py b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_tests/test_postgre_sql_management_capabilities_by_server_operations.py new file mode 100644 index 000000000000..d58c1dd6bda1 --- /dev/null +++ b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_tests/test_postgre_sql_management_capabilities_by_server_operations.py @@ -0,0 +1,30 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.postgresqlflexibleservers import PostgreSQLManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestPostgreSQLManagementCapabilitiesByServerOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(PostgreSQLManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_capabilities_by_server_list(self, resource_group): + response = self.client.capabilities_by_server.list( + resource_group_name=resource_group.name, + server_name="str", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_tests/test_postgre_sql_management_capabilities_by_server_operations_async.py b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_tests/test_postgre_sql_management_capabilities_by_server_operations_async.py new file mode 100644 index 000000000000..9f280746745f --- /dev/null +++ b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_tests/test_postgre_sql_management_capabilities_by_server_operations_async.py @@ -0,0 +1,31 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.postgresqlflexibleservers.aio import PostgreSQLManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestPostgreSQLManagementCapabilitiesByServerOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(PostgreSQLManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_capabilities_by_server_list(self, resource_group): + response = self.client.capabilities_by_server.list( + resource_group_name=resource_group.name, + server_name="str", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_tests/test_postgre_sql_management_captured_logs_operations.py b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_tests/test_postgre_sql_management_captured_logs_operations.py new file mode 100644 index 000000000000..083a322a42f3 --- /dev/null +++ b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_tests/test_postgre_sql_management_captured_logs_operations.py @@ -0,0 +1,30 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.postgresqlflexibleservers import PostgreSQLManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestPostgreSQLManagementCapturedLogsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(PostgreSQLManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_captured_logs_list_by_server(self, resource_group): + response = self.client.captured_logs.list_by_server( + resource_group_name=resource_group.name, + server_name="str", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_tests/test_postgre_sql_management_captured_logs_operations_async.py b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_tests/test_postgre_sql_management_captured_logs_operations_async.py new file mode 100644 index 000000000000..2697cd2c2445 --- /dev/null +++ b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_tests/test_postgre_sql_management_captured_logs_operations_async.py @@ -0,0 +1,31 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.postgresqlflexibleservers.aio import PostgreSQLManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestPostgreSQLManagementCapturedLogsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(PostgreSQLManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_captured_logs_list_by_server(self, resource_group): + response = self.client.captured_logs.list_by_server( + resource_group_name=resource_group.name, + server_name="str", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_tests/test_postgre_sql_management_configurations_operations.py b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_tests/test_postgre_sql_management_configurations_operations.py new file mode 100644 index 000000000000..e4205349093e --- /dev/null +++ b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_tests/test_postgre_sql_management_configurations_operations.py @@ -0,0 +1,96 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.postgresqlflexibleservers import PostgreSQLManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestPostgreSQLManagementConfigurationsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(PostgreSQLManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_configurations_get(self, resource_group): + response = self.client.configurations.get( + resource_group_name=resource_group.name, + server_name="str", + configuration_name="str", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_configurations_begin_put(self, resource_group): + response = self.client.configurations.begin_put( + resource_group_name=resource_group.name, + server_name="str", + configuration_name="str", + parameters={ + "properties": { + "allowedValues": "str", + "dataType": "str", + "defaultValue": "str", + "description": "str", + "documentationLink": "str", + "isConfigPendingRestart": bool, + "isDynamicConfig": bool, + "isReadOnly": bool, + "source": "str", + "unit": "str", + "value": "str", + } + }, + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_configurations_begin_update(self, resource_group): + response = self.client.configurations.begin_update( + resource_group_name=resource_group.name, + server_name="str", + configuration_name="str", + parameters={ + "properties": { + "allowedValues": "str", + "dataType": "str", + "defaultValue": "str", + "description": "str", + "documentationLink": "str", + "isConfigPendingRestart": bool, + "isDynamicConfig": bool, + "isReadOnly": bool, + "source": "str", + "unit": "str", + "value": "str", + } + }, + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_configurations_list_by_server(self, resource_group): + response = self.client.configurations.list_by_server( + resource_group_name=resource_group.name, + server_name="str", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_tests/test_postgre_sql_management_configurations_operations_async.py b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_tests/test_postgre_sql_management_configurations_operations_async.py new file mode 100644 index 000000000000..f4d4b7e7696d --- /dev/null +++ b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_tests/test_postgre_sql_management_configurations_operations_async.py @@ -0,0 +1,101 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.postgresqlflexibleservers.aio import PostgreSQLManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestPostgreSQLManagementConfigurationsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(PostgreSQLManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_configurations_get(self, resource_group): + response = await self.client.configurations.get( + resource_group_name=resource_group.name, + server_name="str", + configuration_name="str", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_configurations_begin_put(self, resource_group): + response = await ( + await self.client.configurations.begin_put( + resource_group_name=resource_group.name, + server_name="str", + configuration_name="str", + parameters={ + "properties": { + "allowedValues": "str", + "dataType": "str", + "defaultValue": "str", + "description": "str", + "documentationLink": "str", + "isConfigPendingRestart": bool, + "isDynamicConfig": bool, + "isReadOnly": bool, + "source": "str", + "unit": "str", + "value": "str", + } + }, + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_configurations_begin_update(self, resource_group): + response = await ( + await self.client.configurations.begin_update( + resource_group_name=resource_group.name, + server_name="str", + configuration_name="str", + parameters={ + "properties": { + "allowedValues": "str", + "dataType": "str", + "defaultValue": "str", + "description": "str", + "documentationLink": "str", + "isConfigPendingRestart": bool, + "isDynamicConfig": bool, + "isReadOnly": bool, + "source": "str", + "unit": "str", + "value": "str", + } + }, + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_configurations_list_by_server(self, resource_group): + response = self.client.configurations.list_by_server( + resource_group_name=resource_group.name, + server_name="str", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_tests/test_postgre_sql_management_databases_operations.py b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_tests/test_postgre_sql_management_databases_operations.py new file mode 100644 index 000000000000..ca6109bf91fa --- /dev/null +++ b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_tests/test_postgre_sql_management_databases_operations.py @@ -0,0 +1,80 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.postgresqlflexibleservers import PostgreSQLManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestPostgreSQLManagementDatabasesOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(PostgreSQLManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_databases_get(self, resource_group): + response = self.client.databases.get( + resource_group_name=resource_group.name, + server_name="str", + database_name="str", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_databases_begin_create(self, resource_group): + response = self.client.databases.begin_create( + resource_group_name=resource_group.name, + server_name="str", + database_name="str", + parameters={ + "id": "str", + "name": "str", + "properties": {"charset": "str", "collation": "str"}, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_databases_begin_delete(self, resource_group): + response = self.client.databases.begin_delete( + resource_group_name=resource_group.name, + server_name="str", + database_name="str", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_databases_list_by_server(self, resource_group): + response = self.client.databases.list_by_server( + resource_group_name=resource_group.name, + server_name="str", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_tests/test_postgre_sql_management_databases_operations_async.py b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_tests/test_postgre_sql_management_databases_operations_async.py new file mode 100644 index 000000000000..0e70cbe0369b --- /dev/null +++ b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_tests/test_postgre_sql_management_databases_operations_async.py @@ -0,0 +1,85 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.postgresqlflexibleservers.aio import PostgreSQLManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestPostgreSQLManagementDatabasesOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(PostgreSQLManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_databases_get(self, resource_group): + response = await self.client.databases.get( + resource_group_name=resource_group.name, + server_name="str", + database_name="str", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_databases_begin_create(self, resource_group): + response = await ( + await self.client.databases.begin_create( + resource_group_name=resource_group.name, + server_name="str", + database_name="str", + parameters={ + "id": "str", + "name": "str", + "properties": {"charset": "str", "collation": "str"}, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_databases_begin_delete(self, resource_group): + response = await ( + await self.client.databases.begin_delete( + resource_group_name=resource_group.name, + server_name="str", + database_name="str", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_databases_list_by_server(self, resource_group): + response = self.client.databases.list_by_server( + resource_group_name=resource_group.name, + server_name="str", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_tests/test_postgre_sql_management_firewall_rules_operations.py b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_tests/test_postgre_sql_management_firewall_rules_operations.py new file mode 100644 index 000000000000..89befb3b3b49 --- /dev/null +++ b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_tests/test_postgre_sql_management_firewall_rules_operations.py @@ -0,0 +1,80 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.postgresqlflexibleservers import PostgreSQLManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestPostgreSQLManagementFirewallRulesOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(PostgreSQLManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_firewall_rules_get(self, resource_group): + response = self.client.firewall_rules.get( + resource_group_name=resource_group.name, + server_name="str", + firewall_rule_name="str", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_firewall_rules_begin_create_or_update(self, resource_group): + response = self.client.firewall_rules.begin_create_or_update( + resource_group_name=resource_group.name, + server_name="str", + firewall_rule_name="str", + parameters={ + "properties": {"endIpAddress": "str", "startIpAddress": "str"}, + "id": "str", + "name": "str", + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_firewall_rules_begin_delete(self, resource_group): + response = self.client.firewall_rules.begin_delete( + resource_group_name=resource_group.name, + server_name="str", + firewall_rule_name="str", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_firewall_rules_list_by_server(self, resource_group): + response = self.client.firewall_rules.list_by_server( + resource_group_name=resource_group.name, + server_name="str", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_tests/test_postgre_sql_management_firewall_rules_operations_async.py b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_tests/test_postgre_sql_management_firewall_rules_operations_async.py new file mode 100644 index 000000000000..df1f772f02bf --- /dev/null +++ b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_tests/test_postgre_sql_management_firewall_rules_operations_async.py @@ -0,0 +1,85 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.postgresqlflexibleservers.aio import PostgreSQLManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestPostgreSQLManagementFirewallRulesOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(PostgreSQLManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_firewall_rules_get(self, resource_group): + response = await self.client.firewall_rules.get( + resource_group_name=resource_group.name, + server_name="str", + firewall_rule_name="str", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_firewall_rules_begin_create_or_update(self, resource_group): + response = await ( + await self.client.firewall_rules.begin_create_or_update( + resource_group_name=resource_group.name, + server_name="str", + firewall_rule_name="str", + parameters={ + "properties": {"endIpAddress": "str", "startIpAddress": "str"}, + "id": "str", + "name": "str", + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_firewall_rules_begin_delete(self, resource_group): + response = await ( + await self.client.firewall_rules.begin_delete( + resource_group_name=resource_group.name, + server_name="str", + firewall_rule_name="str", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_firewall_rules_list_by_server(self, resource_group): + response = self.client.firewall_rules.list_by_server( + resource_group_name=resource_group.name, + server_name="str", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_tests/test_postgre_sql_management_migrations_operations.py b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_tests/test_postgre_sql_management_migrations_operations.py new file mode 100644 index 000000000000..ca63ddd3a0a2 --- /dev/null +++ b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_tests/test_postgre_sql_management_migrations_operations.py @@ -0,0 +1,218 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.postgresqlflexibleservers import PostgreSQLManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestPostgreSQLManagementMigrationsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(PostgreSQLManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_migrations_get(self, resource_group): + response = self.client.migrations.get( + resource_group_name=resource_group.name, + server_name="str", + migration_name="str", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_migrations_create(self, resource_group): + response = self.client.migrations.create( + resource_group_name=resource_group.name, + server_name="str", + migration_name="str", + parameters={ + "location": "str", + "id": "str", + "name": "str", + "properties": { + "cancel": "str", + "currentStatus": { + "currentSubStateDetails": { + "currentSubState": "str", + "dbDetails": { + "str": { + "appliedChanges": 0, + "cdcDeleteCounter": 0, + "cdcInsertCounter": 0, + "cdcUpdateCounter": 0, + "databaseName": "str", + "endedOn": "2020-02-20 00:00:00", + "fullLoadCompletedTables": 0, + "fullLoadErroredTables": 0, + "fullLoadLoadingTables": 0, + "fullLoadQueuedTables": 0, + "incomingChanges": 0, + "latency": 0, + "message": "str", + "migrationOperation": "str", + "migrationState": "str", + "startedOn": "2020-02-20 00:00:00", + } + }, + "validationDetails": { + "dbLevelValidationDetails": [ + { + "databaseName": "str", + "endedOn": "2020-02-20 00:00:00", + "startedOn": "2020-02-20 00:00:00", + "summary": [ + { + "messages": [{"message": "str", "state": "str"}], + "state": "str", + "type": "str", + } + ], + } + ], + "serverLevelValidationDetails": [ + {"messages": [{"message": "str", "state": "str"}], "state": "str", "type": "str"} + ], + "status": "str", + "validationEndTimeInUtc": "2020-02-20 00:00:00", + "validationStartTimeInUtc": "2020-02-20 00:00:00", + }, + }, + "error": "str", + "state": "str", + }, + "dbsToCancelMigrationOn": ["str"], + "dbsToMigrate": ["str"], + "dbsToTriggerCutoverOn": ["str"], + "migrateRoles": "str", + "migrationId": "str", + "migrationInstanceResourceId": "str", + "migrationMode": "str", + "migrationOption": "str", + "migrationWindowEndTimeInUtc": "2020-02-20 00:00:00", + "migrationWindowStartTimeInUtc": "2020-02-20 00:00:00", + "overwriteDbsInTarget": "str", + "secretParameters": { + "adminCredentials": {"sourceServerPassword": "str", "targetServerPassword": "str"}, + "sourceServerUsername": "str", + "targetServerUsername": "str", + }, + "setupLogicalReplicationOnSourceDbIfNeeded": "str", + "sourceDbServerFullyQualifiedDomainName": "str", + "sourceDbServerMetadata": { + "location": "str", + "sku": {"name": "str", "tier": "str"}, + "storageMb": 0, + "version": "str", + }, + "sourceDbServerResourceId": "str", + "sourceType": "str", + "sslMode": "str", + "startDataMigration": "str", + "targetDbServerFullyQualifiedDomainName": "str", + "targetDbServerMetadata": { + "location": "str", + "sku": {"name": "str", "tier": "str"}, + "storageMb": 0, + "version": "str", + }, + "targetDbServerResourceId": "str", + "triggerCutover": "str", + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "tags": {"str": "str"}, + "type": "str", + }, + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_migrations_update(self, resource_group): + response = self.client.migrations.update( + resource_group_name=resource_group.name, + server_name="str", + migration_name="str", + parameters={ + "properties": { + "cancel": "str", + "dbsToCancelMigrationOn": ["str"], + "dbsToMigrate": ["str"], + "dbsToTriggerCutoverOn": ["str"], + "migrateRoles": "str", + "migrationMode": "str", + "migrationWindowStartTimeInUtc": "2020-02-20 00:00:00", + "overwriteDbsInTarget": "str", + "secretParameters": { + "adminCredentials": {"sourceServerPassword": "str", "targetServerPassword": "str"}, + "sourceServerUsername": "str", + "targetServerUsername": "str", + }, + "setupLogicalReplicationOnSourceDbIfNeeded": "str", + "sourceDbServerFullyQualifiedDomainName": "str", + "sourceDbServerResourceId": "str", + "startDataMigration": "str", + "targetDbServerFullyQualifiedDomainName": "str", + "triggerCutover": "str", + }, + "tags": {"str": "str"}, + }, + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_migrations_cancel(self, resource_group): + response = self.client.migrations.cancel( + resource_group_name=resource_group.name, + server_name="str", + migration_name="str", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_migrations_list_by_target_server(self, resource_group): + response = self.client.migrations.list_by_target_server( + resource_group_name=resource_group.name, + server_name="str", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_migrations_check_name_availability(self, resource_group): + response = self.client.migrations.check_name_availability( + resource_group_name=resource_group.name, + server_name="str", + parameters={"name": "str", "type": "str", "message": "str", "nameAvailable": bool, "reason": "str"}, + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_tests/test_postgre_sql_management_migrations_operations_async.py b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_tests/test_postgre_sql_management_migrations_operations_async.py new file mode 100644 index 000000000000..8c70b0e86e05 --- /dev/null +++ b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_tests/test_postgre_sql_management_migrations_operations_async.py @@ -0,0 +1,219 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.postgresqlflexibleservers.aio import PostgreSQLManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestPostgreSQLManagementMigrationsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(PostgreSQLManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_migrations_get(self, resource_group): + response = await self.client.migrations.get( + resource_group_name=resource_group.name, + server_name="str", + migration_name="str", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_migrations_create(self, resource_group): + response = await self.client.migrations.create( + resource_group_name=resource_group.name, + server_name="str", + migration_name="str", + parameters={ + "location": "str", + "id": "str", + "name": "str", + "properties": { + "cancel": "str", + "currentStatus": { + "currentSubStateDetails": { + "currentSubState": "str", + "dbDetails": { + "str": { + "appliedChanges": 0, + "cdcDeleteCounter": 0, + "cdcInsertCounter": 0, + "cdcUpdateCounter": 0, + "databaseName": "str", + "endedOn": "2020-02-20 00:00:00", + "fullLoadCompletedTables": 0, + "fullLoadErroredTables": 0, + "fullLoadLoadingTables": 0, + "fullLoadQueuedTables": 0, + "incomingChanges": 0, + "latency": 0, + "message": "str", + "migrationOperation": "str", + "migrationState": "str", + "startedOn": "2020-02-20 00:00:00", + } + }, + "validationDetails": { + "dbLevelValidationDetails": [ + { + "databaseName": "str", + "endedOn": "2020-02-20 00:00:00", + "startedOn": "2020-02-20 00:00:00", + "summary": [ + { + "messages": [{"message": "str", "state": "str"}], + "state": "str", + "type": "str", + } + ], + } + ], + "serverLevelValidationDetails": [ + {"messages": [{"message": "str", "state": "str"}], "state": "str", "type": "str"} + ], + "status": "str", + "validationEndTimeInUtc": "2020-02-20 00:00:00", + "validationStartTimeInUtc": "2020-02-20 00:00:00", + }, + }, + "error": "str", + "state": "str", + }, + "dbsToCancelMigrationOn": ["str"], + "dbsToMigrate": ["str"], + "dbsToTriggerCutoverOn": ["str"], + "migrateRoles": "str", + "migrationId": "str", + "migrationInstanceResourceId": "str", + "migrationMode": "str", + "migrationOption": "str", + "migrationWindowEndTimeInUtc": "2020-02-20 00:00:00", + "migrationWindowStartTimeInUtc": "2020-02-20 00:00:00", + "overwriteDbsInTarget": "str", + "secretParameters": { + "adminCredentials": {"sourceServerPassword": "str", "targetServerPassword": "str"}, + "sourceServerUsername": "str", + "targetServerUsername": "str", + }, + "setupLogicalReplicationOnSourceDbIfNeeded": "str", + "sourceDbServerFullyQualifiedDomainName": "str", + "sourceDbServerMetadata": { + "location": "str", + "sku": {"name": "str", "tier": "str"}, + "storageMb": 0, + "version": "str", + }, + "sourceDbServerResourceId": "str", + "sourceType": "str", + "sslMode": "str", + "startDataMigration": "str", + "targetDbServerFullyQualifiedDomainName": "str", + "targetDbServerMetadata": { + "location": "str", + "sku": {"name": "str", "tier": "str"}, + "storageMb": 0, + "version": "str", + }, + "targetDbServerResourceId": "str", + "triggerCutover": "str", + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "tags": {"str": "str"}, + "type": "str", + }, + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_migrations_update(self, resource_group): + response = await self.client.migrations.update( + resource_group_name=resource_group.name, + server_name="str", + migration_name="str", + parameters={ + "properties": { + "cancel": "str", + "dbsToCancelMigrationOn": ["str"], + "dbsToMigrate": ["str"], + "dbsToTriggerCutoverOn": ["str"], + "migrateRoles": "str", + "migrationMode": "str", + "migrationWindowStartTimeInUtc": "2020-02-20 00:00:00", + "overwriteDbsInTarget": "str", + "secretParameters": { + "adminCredentials": {"sourceServerPassword": "str", "targetServerPassword": "str"}, + "sourceServerUsername": "str", + "targetServerUsername": "str", + }, + "setupLogicalReplicationOnSourceDbIfNeeded": "str", + "sourceDbServerFullyQualifiedDomainName": "str", + "sourceDbServerResourceId": "str", + "startDataMigration": "str", + "targetDbServerFullyQualifiedDomainName": "str", + "triggerCutover": "str", + }, + "tags": {"str": "str"}, + }, + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_migrations_cancel(self, resource_group): + response = await self.client.migrations.cancel( + resource_group_name=resource_group.name, + server_name="str", + migration_name="str", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_migrations_list_by_target_server(self, resource_group): + response = self.client.migrations.list_by_target_server( + resource_group_name=resource_group.name, + server_name="str", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_migrations_check_name_availability(self, resource_group): + response = await self.client.migrations.check_name_availability( + resource_group_name=resource_group.name, + server_name="str", + parameters={"name": "str", "type": "str", "message": "str", "nameAvailable": bool, "reason": "str"}, + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_tests/test_postgre_sql_management_name_availability_operations.py b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_tests/test_postgre_sql_management_name_availability_operations.py new file mode 100644 index 000000000000..b663fe3601df --- /dev/null +++ b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_tests/test_postgre_sql_management_name_availability_operations.py @@ -0,0 +1,40 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.postgresqlflexibleservers import PostgreSQLManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestPostgreSQLManagementNameAvailabilityOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(PostgreSQLManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_name_availability_check_globally(self, resource_group): + response = self.client.name_availability.check_globally( + parameters={"name": "str", "type": "str"}, + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_name_availability_check_with_location(self, resource_group): + response = self.client.name_availability.check_with_location( + location_name="str", + parameters={"name": "str", "type": "str"}, + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_tests/test_postgre_sql_management_name_availability_operations_async.py b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_tests/test_postgre_sql_management_name_availability_operations_async.py new file mode 100644 index 000000000000..25294b1013a5 --- /dev/null +++ b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_tests/test_postgre_sql_management_name_availability_operations_async.py @@ -0,0 +1,41 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.postgresqlflexibleservers.aio import PostgreSQLManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestPostgreSQLManagementNameAvailabilityOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(PostgreSQLManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_name_availability_check_globally(self, resource_group): + response = await self.client.name_availability.check_globally( + parameters={"name": "str", "type": "str"}, + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_name_availability_check_with_location(self, resource_group): + response = await self.client.name_availability.check_with_location( + location_name="str", + parameters={"name": "str", "type": "str"}, + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_tests/test_postgre_sql_management_operations.py b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_tests/test_postgre_sql_management_operations.py new file mode 100644 index 000000000000..ccf128267601 --- /dev/null +++ b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_tests/test_postgre_sql_management_operations.py @@ -0,0 +1,27 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.postgresqlflexibleservers import PostgreSQLManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestPostgreSQLManagementOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(PostgreSQLManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_operations_list(self, resource_group): + response = self.client.operations.list() + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_tests/test_postgre_sql_management_operations_async.py b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_tests/test_postgre_sql_management_operations_async.py new file mode 100644 index 000000000000..23995782856b --- /dev/null +++ b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_tests/test_postgre_sql_management_operations_async.py @@ -0,0 +1,28 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.postgresqlflexibleservers.aio import PostgreSQLManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestPostgreSQLManagementOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(PostgreSQLManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_operations_list(self, resource_group): + response = self.client.operations.list() + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_tests/test_postgre_sql_management_private_dns_zone_suffix_operations.py b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_tests/test_postgre_sql_management_private_dns_zone_suffix_operations.py new file mode 100644 index 000000000000..f5886b009027 --- /dev/null +++ b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_tests/test_postgre_sql_management_private_dns_zone_suffix_operations.py @@ -0,0 +1,27 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.postgresqlflexibleservers import PostgreSQLManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestPostgreSQLManagementPrivateDnsZoneSuffixOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(PostgreSQLManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_private_dns_zone_suffix_get(self, resource_group): + response = self.client.private_dns_zone_suffix.get() + + # please add some check logic here by yourself + # ... diff --git a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_tests/test_postgre_sql_management_private_dns_zone_suffix_operations_async.py b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_tests/test_postgre_sql_management_private_dns_zone_suffix_operations_async.py new file mode 100644 index 000000000000..65f61a6ae630 --- /dev/null +++ b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_tests/test_postgre_sql_management_private_dns_zone_suffix_operations_async.py @@ -0,0 +1,28 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.postgresqlflexibleservers.aio import PostgreSQLManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestPostgreSQLManagementPrivateDnsZoneSuffixOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(PostgreSQLManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_private_dns_zone_suffix_get(self, resource_group): + response = await self.client.private_dns_zone_suffix.get() + + # please add some check logic here by yourself + # ... diff --git a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_tests/test_postgre_sql_management_private_endpoint_connections_operations.py b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_tests/test_postgre_sql_management_private_endpoint_connections_operations.py new file mode 100644 index 000000000000..c6db5acf95dd --- /dev/null +++ b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_tests/test_postgre_sql_management_private_endpoint_connections_operations.py @@ -0,0 +1,89 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.postgresqlflexibleservers import PostgreSQLManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestPostgreSQLManagementPrivateEndpointConnectionsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(PostgreSQLManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_private_endpoint_connections_get(self, resource_group): + response = self.client.private_endpoint_connections.get( + resource_group_name=resource_group.name, + server_name="str", + private_endpoint_connection_name="str", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_private_endpoint_connections_begin_update(self, resource_group): + response = self.client.private_endpoint_connections.begin_update( + resource_group_name=resource_group.name, + server_name="str", + private_endpoint_connection_name="str", + parameters={ + "id": "str", + "name": "str", + "properties": { + "privateLinkServiceConnectionState": { + "actionsRequired": "str", + "description": "str", + "status": "str", + }, + "groupIds": ["str"], + "privateEndpoint": {"id": "str"}, + "provisioningState": "str", + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_private_endpoint_connections_begin_delete(self, resource_group): + response = self.client.private_endpoint_connections.begin_delete( + resource_group_name=resource_group.name, + server_name="str", + private_endpoint_connection_name="str", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_private_endpoint_connections_list_by_server(self, resource_group): + response = self.client.private_endpoint_connections.list_by_server( + resource_group_name=resource_group.name, + server_name="str", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_tests/test_postgre_sql_management_private_endpoint_connections_operations_async.py b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_tests/test_postgre_sql_management_private_endpoint_connections_operations_async.py new file mode 100644 index 000000000000..6cf31231fc3a --- /dev/null +++ b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_tests/test_postgre_sql_management_private_endpoint_connections_operations_async.py @@ -0,0 +1,94 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.postgresqlflexibleservers.aio import PostgreSQLManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestPostgreSQLManagementPrivateEndpointConnectionsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(PostgreSQLManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_private_endpoint_connections_get(self, resource_group): + response = await self.client.private_endpoint_connections.get( + resource_group_name=resource_group.name, + server_name="str", + private_endpoint_connection_name="str", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_private_endpoint_connections_begin_update(self, resource_group): + response = await ( + await self.client.private_endpoint_connections.begin_update( + resource_group_name=resource_group.name, + server_name="str", + private_endpoint_connection_name="str", + parameters={ + "id": "str", + "name": "str", + "properties": { + "privateLinkServiceConnectionState": { + "actionsRequired": "str", + "description": "str", + "status": "str", + }, + "groupIds": ["str"], + "privateEndpoint": {"id": "str"}, + "provisioningState": "str", + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_private_endpoint_connections_begin_delete(self, resource_group): + response = await ( + await self.client.private_endpoint_connections.begin_delete( + resource_group_name=resource_group.name, + server_name="str", + private_endpoint_connection_name="str", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_private_endpoint_connections_list_by_server(self, resource_group): + response = self.client.private_endpoint_connections.list_by_server( + resource_group_name=resource_group.name, + server_name="str", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_tests/test_postgre_sql_management_private_link_resources_operations.py b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_tests/test_postgre_sql_management_private_link_resources_operations.py new file mode 100644 index 000000000000..e2c49c0b21d6 --- /dev/null +++ b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_tests/test_postgre_sql_management_private_link_resources_operations.py @@ -0,0 +1,42 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.postgresqlflexibleservers import PostgreSQLManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestPostgreSQLManagementPrivateLinkResourcesOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(PostgreSQLManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_private_link_resources_get(self, resource_group): + response = self.client.private_link_resources.get( + resource_group_name=resource_group.name, + server_name="str", + group_name="str", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_private_link_resources_list_by_server(self, resource_group): + response = self.client.private_link_resources.list_by_server( + resource_group_name=resource_group.name, + server_name="str", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_tests/test_postgre_sql_management_private_link_resources_operations_async.py b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_tests/test_postgre_sql_management_private_link_resources_operations_async.py new file mode 100644 index 000000000000..50e7c25f3f5c --- /dev/null +++ b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_tests/test_postgre_sql_management_private_link_resources_operations_async.py @@ -0,0 +1,43 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.postgresqlflexibleservers.aio import PostgreSQLManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestPostgreSQLManagementPrivateLinkResourcesOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(PostgreSQLManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_private_link_resources_get(self, resource_group): + response = await self.client.private_link_resources.get( + resource_group_name=resource_group.name, + server_name="str", + group_name="str", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_private_link_resources_list_by_server(self, resource_group): + response = self.client.private_link_resources.list_by_server( + resource_group_name=resource_group.name, + server_name="str", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_tests/test_postgre_sql_management_quota_usages_operations.py b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_tests/test_postgre_sql_management_quota_usages_operations.py new file mode 100644 index 000000000000..964ffb1e98e8 --- /dev/null +++ b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_tests/test_postgre_sql_management_quota_usages_operations.py @@ -0,0 +1,29 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.postgresqlflexibleservers import PostgreSQLManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestPostgreSQLManagementQuotaUsagesOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(PostgreSQLManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_quota_usages_list(self, resource_group): + response = self.client.quota_usages.list( + location_name="str", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_tests/test_postgre_sql_management_quota_usages_operations_async.py b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_tests/test_postgre_sql_management_quota_usages_operations_async.py new file mode 100644 index 000000000000..40a839117a9f --- /dev/null +++ b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_tests/test_postgre_sql_management_quota_usages_operations_async.py @@ -0,0 +1,30 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.postgresqlflexibleservers.aio import PostgreSQLManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestPostgreSQLManagementQuotaUsagesOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(PostgreSQLManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_quota_usages_list(self, resource_group): + response = self.client.quota_usages.list( + location_name="str", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_tests/test_postgre_sql_management_replicas_operations.py b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_tests/test_postgre_sql_management_replicas_operations.py new file mode 100644 index 000000000000..94a29e0af3f5 --- /dev/null +++ b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_tests/test_postgre_sql_management_replicas_operations.py @@ -0,0 +1,30 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.postgresqlflexibleservers import PostgreSQLManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestPostgreSQLManagementReplicasOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(PostgreSQLManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_replicas_list_by_server(self, resource_group): + response = self.client.replicas.list_by_server( + resource_group_name=resource_group.name, + server_name="str", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_tests/test_postgre_sql_management_replicas_operations_async.py b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_tests/test_postgre_sql_management_replicas_operations_async.py new file mode 100644 index 000000000000..7cd99f0ed9fc --- /dev/null +++ b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_tests/test_postgre_sql_management_replicas_operations_async.py @@ -0,0 +1,31 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.postgresqlflexibleservers.aio import PostgreSQLManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestPostgreSQLManagementReplicasOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(PostgreSQLManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_replicas_list_by_server(self, resource_group): + response = self.client.replicas.list_by_server( + resource_group_name=resource_group.name, + server_name="str", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_tests/test_postgre_sql_management_server_threat_protection_settings_operations.py b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_tests/test_postgre_sql_management_server_threat_protection_settings_operations.py new file mode 100644 index 000000000000..dbfd1a79c29b --- /dev/null +++ b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_tests/test_postgre_sql_management_server_threat_protection_settings_operations.py @@ -0,0 +1,45 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.postgresqlflexibleservers import PostgreSQLManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestPostgreSQLManagementServerThreatProtectionSettingsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(PostgreSQLManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_server_threat_protection_settings_begin_create_or_update(self, resource_group): + response = self.client.server_threat_protection_settings.begin_create_or_update( + resource_group_name=resource_group.name, + server_name="str", + threat_protection_name="str", + parameters={ + "id": "str", + "name": "str", + "properties": {"state": "str", "creationTime": "2020-02-20 00:00:00"}, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_tests/test_postgre_sql_management_server_threat_protection_settings_operations_async.py b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_tests/test_postgre_sql_management_server_threat_protection_settings_operations_async.py new file mode 100644 index 000000000000..5960d40fde71 --- /dev/null +++ b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_tests/test_postgre_sql_management_server_threat_protection_settings_operations_async.py @@ -0,0 +1,48 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.postgresqlflexibleservers.aio import PostgreSQLManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestPostgreSQLManagementServerThreatProtectionSettingsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(PostgreSQLManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_server_threat_protection_settings_begin_create_or_update(self, resource_group): + response = await ( + await self.client.server_threat_protection_settings.begin_create_or_update( + resource_group_name=resource_group.name, + server_name="str", + threat_protection_name="str", + parameters={ + "id": "str", + "name": "str", + "properties": {"state": "str", "creationTime": "2020-02-20 00:00:00"}, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_tests/test_postgre_sql_management_servers_operations.py b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_tests/test_postgre_sql_management_servers_operations.py new file mode 100644 index 000000000000..067298656e25 --- /dev/null +++ b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_tests/test_postgre_sql_management_servers_operations.py @@ -0,0 +1,280 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.postgresqlflexibleservers import PostgreSQLManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestPostgreSQLManagementServersOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(PostgreSQLManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_servers_get(self, resource_group): + response = self.client.servers.get( + resource_group_name=resource_group.name, + server_name="str", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_servers_begin_create_or_update(self, resource_group): + response = self.client.servers.begin_create_or_update( + resource_group_name=resource_group.name, + server_name="str", + parameters={ + "location": "str", + "id": "str", + "identity": { + "type": "str", + "principalId": "str", + "tenantId": "str", + "userAssignedIdentities": {"str": {"clientId": "str", "principalId": "str"}}, + }, + "name": "str", + "properties": { + "administratorLogin": "str", + "administratorLoginPassword": "str", + "authConfig": {"activeDirectoryAuth": "str", "passwordAuth": "str", "tenantId": "str"}, + "availabilityZone": "str", + "backup": { + "backupRetentionDays": 0, + "earliestRestoreDate": "2020-02-20 00:00:00", + "geoRedundantBackup": "str", + }, + "cluster": {"clusterSize": 0, "defaultDatabaseName": "str"}, + "createMode": "str", + "dataEncryption": { + "geoBackupEncryptionKeyStatus": "str", + "geoBackupKeyURI": "str", + "geoBackupUserAssignedIdentityId": "str", + "primaryEncryptionKeyStatus": "str", + "primaryKeyURI": "str", + "primaryUserAssignedIdentityId": "str", + "type": "str", + }, + "fullyQualifiedDomainName": "str", + "highAvailability": {"mode": "str", "standbyAvailabilityZone": "str", "state": "str"}, + "maintenanceWindow": {"customWindow": "str", "dayOfWeek": 0, "startHour": 0, "startMinute": 0}, + "minorVersion": "str", + "network": { + "delegatedSubnetResourceId": "str", + "privateDnsZoneArmResourceId": "str", + "publicNetworkAccess": "str", + }, + "pointInTimeUTC": "2020-02-20 00:00:00", + "privateEndpointConnections": [ + { + "id": "str", + "name": "str", + "properties": { + "privateLinkServiceConnectionState": { + "actionsRequired": "str", + "description": "str", + "status": "str", + }, + "groupIds": ["str"], + "privateEndpoint": {"id": "str"}, + "provisioningState": "str", + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + } + ], + "replica": { + "capacity": 0, + "promoteMode": "str", + "promoteOption": "str", + "replicationState": "str", + "role": "str", + }, + "replicaCapacity": 0, + "replicationRole": "str", + "sourceServerResourceId": "str", + "state": "str", + "storage": { + "autoGrow": "str", + "iops": 0, + "storageSizeGB": 0, + "throughput": 0, + "tier": "str", + "type": "str", + }, + "version": "str", + }, + "sku": {"name": "str", "tier": "str"}, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "tags": {"str": "str"}, + "type": "str", + }, + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_servers_begin_update(self, resource_group): + response = self.client.servers.begin_update( + resource_group_name=resource_group.name, + server_name="str", + parameters={ + "identity": { + "type": "str", + "principalId": "str", + "tenantId": "str", + "userAssignedIdentities": {"str": {"clientId": "str", "principalId": "str"}}, + }, + "properties": { + "administratorLogin": "str", + "administratorLoginPassword": "str", + "authConfig": {"activeDirectoryAuth": "str", "passwordAuth": "str", "tenantId": "str"}, + "availabilityZone": "str", + "backup": { + "backupRetentionDays": 0, + "earliestRestoreDate": "2020-02-20 00:00:00", + "geoRedundantBackup": "str", + }, + "cluster": {"clusterSize": 0, "defaultDatabaseName": "str"}, + "createMode": "str", + "dataEncryption": { + "geoBackupEncryptionKeyStatus": "str", + "geoBackupKeyURI": "str", + "geoBackupUserAssignedIdentityId": "str", + "primaryEncryptionKeyStatus": "str", + "primaryKeyURI": "str", + "primaryUserAssignedIdentityId": "str", + "type": "str", + }, + "highAvailability": {"mode": "str", "standbyAvailabilityZone": "str", "state": "str"}, + "maintenanceWindow": {"customWindow": "str", "dayOfWeek": 0, "startHour": 0, "startMinute": 0}, + "network": { + "delegatedSubnetResourceId": "str", + "privateDnsZoneArmResourceId": "str", + "publicNetworkAccess": "str", + }, + "replica": { + "capacity": 0, + "promoteMode": "str", + "promoteOption": "str", + "replicationState": "str", + "role": "str", + }, + "replicationRole": "str", + "storage": { + "autoGrow": "str", + "iops": 0, + "storageSizeGB": 0, + "throughput": 0, + "tier": "str", + "type": "str", + }, + "version": "str", + }, + "sku": {"name": "str", "tier": "str"}, + "tags": {"str": "str"}, + }, + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_servers_begin_delete(self, resource_group): + response = self.client.servers.begin_delete( + resource_group_name=resource_group.name, + server_name="str", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_servers_list_by_resource_group(self, resource_group): + response = self.client.servers.list_by_resource_group( + resource_group_name=resource_group.name, + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_servers_list_by_subscription(self, resource_group): + response = self.client.servers.list_by_subscription() + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_servers_begin_restart(self, resource_group): + response = self.client.servers.begin_restart( + resource_group_name=resource_group.name, + server_name="str", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_servers_begin_start(self, resource_group): + response = self.client.servers.begin_start( + resource_group_name=resource_group.name, + server_name="str", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_servers_begin_stop(self, resource_group): + response = self.client.servers.begin_stop( + resource_group_name=resource_group.name, + server_name="str", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_servers_begin_migrate_network_mode(self, resource_group): + response = self.client.servers.begin_migrate_network_mode( + resource_group_name=resource_group.name, + server_name="str", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_tests/test_postgre_sql_management_servers_operations_async.py b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_tests/test_postgre_sql_management_servers_operations_async.py new file mode 100644 index 000000000000..3a3c024ba5a9 --- /dev/null +++ b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_tests/test_postgre_sql_management_servers_operations_async.py @@ -0,0 +1,295 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.postgresqlflexibleservers.aio import PostgreSQLManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestPostgreSQLManagementServersOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(PostgreSQLManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_servers_get(self, resource_group): + response = await self.client.servers.get( + resource_group_name=resource_group.name, + server_name="str", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_servers_begin_create_or_update(self, resource_group): + response = await ( + await self.client.servers.begin_create_or_update( + resource_group_name=resource_group.name, + server_name="str", + parameters={ + "location": "str", + "id": "str", + "identity": { + "type": "str", + "principalId": "str", + "tenantId": "str", + "userAssignedIdentities": {"str": {"clientId": "str", "principalId": "str"}}, + }, + "name": "str", + "properties": { + "administratorLogin": "str", + "administratorLoginPassword": "str", + "authConfig": {"activeDirectoryAuth": "str", "passwordAuth": "str", "tenantId": "str"}, + "availabilityZone": "str", + "backup": { + "backupRetentionDays": 0, + "earliestRestoreDate": "2020-02-20 00:00:00", + "geoRedundantBackup": "str", + }, + "cluster": {"clusterSize": 0, "defaultDatabaseName": "str"}, + "createMode": "str", + "dataEncryption": { + "geoBackupEncryptionKeyStatus": "str", + "geoBackupKeyURI": "str", + "geoBackupUserAssignedIdentityId": "str", + "primaryEncryptionKeyStatus": "str", + "primaryKeyURI": "str", + "primaryUserAssignedIdentityId": "str", + "type": "str", + }, + "fullyQualifiedDomainName": "str", + "highAvailability": {"mode": "str", "standbyAvailabilityZone": "str", "state": "str"}, + "maintenanceWindow": {"customWindow": "str", "dayOfWeek": 0, "startHour": 0, "startMinute": 0}, + "minorVersion": "str", + "network": { + "delegatedSubnetResourceId": "str", + "privateDnsZoneArmResourceId": "str", + "publicNetworkAccess": "str", + }, + "pointInTimeUTC": "2020-02-20 00:00:00", + "privateEndpointConnections": [ + { + "id": "str", + "name": "str", + "properties": { + "privateLinkServiceConnectionState": { + "actionsRequired": "str", + "description": "str", + "status": "str", + }, + "groupIds": ["str"], + "privateEndpoint": {"id": "str"}, + "provisioningState": "str", + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + } + ], + "replica": { + "capacity": 0, + "promoteMode": "str", + "promoteOption": "str", + "replicationState": "str", + "role": "str", + }, + "replicaCapacity": 0, + "replicationRole": "str", + "sourceServerResourceId": "str", + "state": "str", + "storage": { + "autoGrow": "str", + "iops": 0, + "storageSizeGB": 0, + "throughput": 0, + "tier": "str", + "type": "str", + }, + "version": "str", + }, + "sku": {"name": "str", "tier": "str"}, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "tags": {"str": "str"}, + "type": "str", + }, + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_servers_begin_update(self, resource_group): + response = await ( + await self.client.servers.begin_update( + resource_group_name=resource_group.name, + server_name="str", + parameters={ + "identity": { + "type": "str", + "principalId": "str", + "tenantId": "str", + "userAssignedIdentities": {"str": {"clientId": "str", "principalId": "str"}}, + }, + "properties": { + "administratorLogin": "str", + "administratorLoginPassword": "str", + "authConfig": {"activeDirectoryAuth": "str", "passwordAuth": "str", "tenantId": "str"}, + "availabilityZone": "str", + "backup": { + "backupRetentionDays": 0, + "earliestRestoreDate": "2020-02-20 00:00:00", + "geoRedundantBackup": "str", + }, + "cluster": {"clusterSize": 0, "defaultDatabaseName": "str"}, + "createMode": "str", + "dataEncryption": { + "geoBackupEncryptionKeyStatus": "str", + "geoBackupKeyURI": "str", + "geoBackupUserAssignedIdentityId": "str", + "primaryEncryptionKeyStatus": "str", + "primaryKeyURI": "str", + "primaryUserAssignedIdentityId": "str", + "type": "str", + }, + "highAvailability": {"mode": "str", "standbyAvailabilityZone": "str", "state": "str"}, + "maintenanceWindow": {"customWindow": "str", "dayOfWeek": 0, "startHour": 0, "startMinute": 0}, + "network": { + "delegatedSubnetResourceId": "str", + "privateDnsZoneArmResourceId": "str", + "publicNetworkAccess": "str", + }, + "replica": { + "capacity": 0, + "promoteMode": "str", + "promoteOption": "str", + "replicationState": "str", + "role": "str", + }, + "replicationRole": "str", + "storage": { + "autoGrow": "str", + "iops": 0, + "storageSizeGB": 0, + "throughput": 0, + "tier": "str", + "type": "str", + }, + "version": "str", + }, + "sku": {"name": "str", "tier": "str"}, + "tags": {"str": "str"}, + }, + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_servers_begin_delete(self, resource_group): + response = await ( + await self.client.servers.begin_delete( + resource_group_name=resource_group.name, + server_name="str", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_servers_list_by_resource_group(self, resource_group): + response = self.client.servers.list_by_resource_group( + resource_group_name=resource_group.name, + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_servers_list_by_subscription(self, resource_group): + response = self.client.servers.list_by_subscription() + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_servers_begin_restart(self, resource_group): + response = await ( + await self.client.servers.begin_restart( + resource_group_name=resource_group.name, + server_name="str", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_servers_begin_start(self, resource_group): + response = await ( + await self.client.servers.begin_start( + resource_group_name=resource_group.name, + server_name="str", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_servers_begin_stop(self, resource_group): + response = await ( + await self.client.servers.begin_stop( + resource_group_name=resource_group.name, + server_name="str", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_servers_begin_migrate_network_mode(self, resource_group): + response = await ( + await self.client.servers.begin_migrate_network_mode( + resource_group_name=resource_group.name, + server_name="str", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_tests/test_postgre_sql_management_tuning_options_operations.py b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_tests/test_postgre_sql_management_tuning_options_operations.py new file mode 100644 index 000000000000..bb444881d773 --- /dev/null +++ b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_tests/test_postgre_sql_management_tuning_options_operations.py @@ -0,0 +1,54 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.postgresqlflexibleservers import PostgreSQLManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestPostgreSQLManagementTuningOptionsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(PostgreSQLManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_tuning_options_get(self, resource_group): + response = self.client.tuning_options.get( + resource_group_name=resource_group.name, + server_name="str", + tuning_option="str", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_tuning_options_list_by_server(self, resource_group): + response = self.client.tuning_options.list_by_server( + resource_group_name=resource_group.name, + server_name="str", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_tuning_options_list_recommendations(self, resource_group): + response = self.client.tuning_options.list_recommendations( + resource_group_name=resource_group.name, + server_name="str", + tuning_option="str", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_tests/test_postgre_sql_management_tuning_options_operations_async.py b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_tests/test_postgre_sql_management_tuning_options_operations_async.py new file mode 100644 index 000000000000..1b078a468047 --- /dev/null +++ b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_tests/test_postgre_sql_management_tuning_options_operations_async.py @@ -0,0 +1,55 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.postgresqlflexibleservers.aio import PostgreSQLManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestPostgreSQLManagementTuningOptionsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(PostgreSQLManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_tuning_options_get(self, resource_group): + response = await self.client.tuning_options.get( + resource_group_name=resource_group.name, + server_name="str", + tuning_option="str", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_tuning_options_list_by_server(self, resource_group): + response = self.client.tuning_options.list_by_server( + resource_group_name=resource_group.name, + server_name="str", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_tuning_options_list_recommendations(self, resource_group): + response = self.client.tuning_options.list_recommendations( + resource_group_name=resource_group.name, + server_name="str", + tuning_option="str", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_tests/test_postgre_sql_management_virtual_endpoints_operations.py b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_tests/test_postgre_sql_management_virtual_endpoints_operations.py new file mode 100644 index 000000000000..b9f1ff6ceb5d --- /dev/null +++ b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_tests/test_postgre_sql_management_virtual_endpoints_operations.py @@ -0,0 +1,93 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.postgresqlflexibleservers import PostgreSQLManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestPostgreSQLManagementVirtualEndpointsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(PostgreSQLManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_virtual_endpoints_get(self, resource_group): + response = self.client.virtual_endpoints.get( + resource_group_name=resource_group.name, + server_name="str", + virtual_endpoint_name="str", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_virtual_endpoints_begin_create(self, resource_group): + response = self.client.virtual_endpoints.begin_create( + resource_group_name=resource_group.name, + server_name="str", + virtual_endpoint_name="str", + parameters={ + "id": "str", + "name": "str", + "properties": {"endpointType": "str", "members": ["str"], "virtualEndpoints": ["str"]}, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_virtual_endpoints_begin_update(self, resource_group): + response = self.client.virtual_endpoints.begin_update( + resource_group_name=resource_group.name, + server_name="str", + virtual_endpoint_name="str", + parameters={"properties": {"endpointType": "str", "members": ["str"], "virtualEndpoints": ["str"]}}, + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_virtual_endpoints_begin_delete(self, resource_group): + response = self.client.virtual_endpoints.begin_delete( + resource_group_name=resource_group.name, + server_name="str", + virtual_endpoint_name="str", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_virtual_endpoints_list_by_server(self, resource_group): + response = self.client.virtual_endpoints.list_by_server( + resource_group_name=resource_group.name, + server_name="str", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_tests/test_postgre_sql_management_virtual_endpoints_operations_async.py b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_tests/test_postgre_sql_management_virtual_endpoints_operations_async.py new file mode 100644 index 000000000000..b9f8f0bf3bf8 --- /dev/null +++ b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_tests/test_postgre_sql_management_virtual_endpoints_operations_async.py @@ -0,0 +1,100 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.postgresqlflexibleservers.aio import PostgreSQLManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestPostgreSQLManagementVirtualEndpointsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(PostgreSQLManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_virtual_endpoints_get(self, resource_group): + response = await self.client.virtual_endpoints.get( + resource_group_name=resource_group.name, + server_name="str", + virtual_endpoint_name="str", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_virtual_endpoints_begin_create(self, resource_group): + response = await ( + await self.client.virtual_endpoints.begin_create( + resource_group_name=resource_group.name, + server_name="str", + virtual_endpoint_name="str", + parameters={ + "id": "str", + "name": "str", + "properties": {"endpointType": "str", "members": ["str"], "virtualEndpoints": ["str"]}, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_virtual_endpoints_begin_update(self, resource_group): + response = await ( + await self.client.virtual_endpoints.begin_update( + resource_group_name=resource_group.name, + server_name="str", + virtual_endpoint_name="str", + parameters={"properties": {"endpointType": "str", "members": ["str"], "virtualEndpoints": ["str"]}}, + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_virtual_endpoints_begin_delete(self, resource_group): + response = await ( + await self.client.virtual_endpoints.begin_delete( + resource_group_name=resource_group.name, + server_name="str", + virtual_endpoint_name="str", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_virtual_endpoints_list_by_server(self, resource_group): + response = self.client.virtual_endpoints.list_by_server( + resource_group_name=resource_group.name, + server_name="str", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_tests/test_postgre_sql_management_virtual_network_subnet_usage_operations.py b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_tests/test_postgre_sql_management_virtual_network_subnet_usage_operations.py new file mode 100644 index 000000000000..5535b6f06c0d --- /dev/null +++ b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_tests/test_postgre_sql_management_virtual_network_subnet_usage_operations.py @@ -0,0 +1,30 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.postgresqlflexibleservers import PostgreSQLManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestPostgreSQLManagementVirtualNetworkSubnetUsageOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(PostgreSQLManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_virtual_network_subnet_usage_list(self, resource_group): + response = self.client.virtual_network_subnet_usage.list( + location_name="str", + parameters={"virtualNetworkArmResourceId": "str"}, + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_tests/test_postgre_sql_management_virtual_network_subnet_usage_operations_async.py b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_tests/test_postgre_sql_management_virtual_network_subnet_usage_operations_async.py new file mode 100644 index 000000000000..9d7e0dbe5968 --- /dev/null +++ b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/generated_tests/test_postgre_sql_management_virtual_network_subnet_usage_operations_async.py @@ -0,0 +1,31 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.postgresqlflexibleservers.aio import PostgreSQLManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestPostgreSQLManagementVirtualNetworkSubnetUsageOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(PostgreSQLManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_virtual_network_subnet_usage_list(self, resource_group): + response = await self.client.virtual_network_subnet_usage.list( + location_name="str", + parameters={"virtualNetworkArmResourceId": "str"}, + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/pyproject.toml b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/pyproject.toml index 19810f1f6b18..367fef8be4d1 100644 --- a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/pyproject.toml +++ b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/pyproject.toml @@ -13,7 +13,7 @@ authors = [ description = "Microsoft Azure Postgresqlflexibleservers Management Client Library for Python" license = "MIT" classifiers = [ - "Development Status :: 5 - Production/Stable", + "Development Status :: 4 - Beta", "Programming Language :: Python", "Programming Language :: Python :: 3 :: Only", "Programming Language :: Python :: 3", @@ -29,7 +29,7 @@ keywords = [ "azure sdk", ] dependencies = [ - "msrest>=0.7.1", + "isodate>=0.6.1", "azure-mgmt-core>=1.6.0", "typing-extensions>=4.6.0", ] @@ -79,7 +79,7 @@ package_name = "azure-mgmt-postgresqlflexibleservers" package_nspkg = "azure-mgmt-nspkg" package_pprint_name = "Postgresqlflexibleservers Management" package_doc_id = "" -is_stable = true +is_stable = false is_arm = true need_msrestazure = false need_azuremgmtcore = true diff --git a/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/tsp-location.yaml b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/tsp-location.yaml new file mode 100644 index 000000000000..5054212479f8 --- /dev/null +++ b/sdk/postgresqlflexibleservers/azure-mgmt-postgresqlflexibleservers/tsp-location.yaml @@ -0,0 +1,4 @@ +directory: specification/postgresql/DBforPostgreSQL.Management +commit: 3afef36df83f47abac337e0cbd850e3d1c00dc8e +repo: Azure/azure-rest-api-specs +additionalDirectories: