From c4007f19b5fc1a27e22d13428fd85c7eab80419f Mon Sep 17 00:00:00 2001 From: Praful Johari Date: Thu, 30 Apr 2026 16:30:28 -0500 Subject: [PATCH] Added generated Python SDK for 2026-04-01-preview --- .../azure_mgmt_cosmosdb/_configuration.py | 4 +- .../_cosmos_db_management_client.py | 295 +- .../azure_mgmt_cosmosdb/_patch.py | 39 +- .../azure_mgmt_cosmosdb/_version.py | 2 +- .../azure_mgmt_cosmosdb/aio/_configuration.py | 4 +- .../aio/_cosmos_db_management_client.py | 297 +- .../azure_mgmt_cosmosdb/aio/_patch.py | 39 +- .../aio/operations/__init__.py | 150 +- .../_cassandra_clusters_operations.py | 981 ++-- .../_cassandra_data_centers_operations.py | 249 +- .../_cassandra_resources_operations.py | 2145 ++++---- .../aio/operations/_chaos_fault_operations.py | 135 +- .../aio/operations/_collection_operations.py | 108 +- .../_collection_partition_operations.py | 16 +- ..._collection_partition_region_operations.py | 8 +- .../_collection_region_operations.py | 8 +- .../aio/operations/_copy_jobs_operations.py | 310 +- .../_data_transfer_jobs_operations.py | 314 +- .../_database_account_region_operations.py | 8 +- .../_database_accounts_operations.py | 1022 ++-- .../aio/operations/_database_operations.py | 106 +- .../operations/_fleet_analytics_operations.py | 15 +- .../aio/operations/_fleet_operations.py | 19 +- .../_fleetspace_account_operations.py | 24 +- .../aio/operations/_fleetspace_operations.py | 33 +- .../operations/_garnet_clusters_operations.py | 293 +- .../operations/_graph_resources_operations.py | 47 +- .../_gremlin_resources_operations.py | 1835 +++---- .../aio/operations/_locations_operations.py | 2 +- .../_mongo_db_resources_operations.py | 2897 ++++++----- .../_mongo_mi_resources_operations.py | 526 +- ...ity_perimeter_configurations_operations.py | 1 + .../_notebook_workspaces_operations.py | 64 +- .../aio/operations/_operations.py | 6 +- .../_partition_key_range_id_operations.py | 8 +- ...artition_key_range_id_region_operations.py | 8 +- .../aio/operations/_patch.py | 13 +- .../aio/operations/_percentile_operations.py | 8 +- .../_percentile_source_target_operations.py | 8 +- .../_percentile_target_operations.py | 8 +- ...private_endpoint_connections_operations.py | 36 +- .../_private_link_resources_operations.py | 14 +- ...restorable_database_accounts_operations.py | 120 +- ...restorable_gremlin_databases_operations.py | 2 +- .../_restorable_gremlin_graphs_operations.py | 2 +- ...restorable_gremlin_resources_operations.py | 2 +- ...storable_mongodb_collections_operations.py | 2 +- ...restorable_mongodb_databases_operations.py | 2 +- ...restorable_mongodb_resources_operations.py | 2 +- .../_restorable_sql_containers_operations.py | 2 +- .../_restorable_sql_databases_operations.py | 2 +- .../_restorable_sql_resources_operations.py | 2 +- .../_restorable_table_resources_operations.py | 2 +- .../_restorable_tables_operations.py | 2 +- .../aio/operations/_service_operations.py | 143 +- ...ft_deleted_database_accounts_operations.py | 580 +++ ..._soft_deleted_sql_containers_operations.py | 536 ++ .../_soft_deleted_sql_databases_operations.py | 511 ++ .../operations/_sql_resources_operations.py | 3822 +++++++------- .../operations/_table_resources_operations.py | 1688 +++--- .../_throughput_pool_account_operations.py | 19 +- .../operations/_throughput_pool_operations.py | 26 +- .../azure_mgmt_cosmosdb/models/__init__.py | 66 +- .../_cosmos_db_management_client_enums.py | 41 +- .../azure_mgmt_cosmosdb/models/_models_py3.py | 4516 +++++++++-------- .../azure_mgmt_cosmosdb/models/_patch.py | 13 +- .../operations/__init__.py | 150 +- .../_cassandra_clusters_operations.py | 1183 ++--- .../_cassandra_data_centers_operations.py | 277 +- .../_cassandra_resources_operations.py | 2749 +++++----- .../operations/_chaos_fault_operations.py | 155 +- .../operations/_collection_operations.py | 138 +- .../_collection_partition_operations.py | 20 +- ..._collection_partition_region_operations.py | 10 +- .../_collection_region_operations.py | 10 +- .../operations/_copy_jobs_operations.py | 366 +- .../_data_transfer_jobs_operations.py | 378 +- .../_database_account_region_operations.py | 10 +- .../_database_accounts_operations.py | 1402 ++--- .../operations/_database_operations.py | 148 +- .../operations/_fleet_analytics_operations.py | 23 +- .../operations/_fleet_operations.py | 31 +- .../_fleetspace_account_operations.py | 32 +- .../operations/_fleetspace_operations.py | 43 +- .../operations/_garnet_clusters_operations.py | 325 +- .../operations/_graph_resources_operations.py | 63 +- .../_gremlin_resources_operations.py | 2139 ++++---- .../operations/_locations_operations.py | 6 +- .../_mongo_db_resources_operations.py | 3223 ++++++------ .../_mongo_mi_resources_operations.py | 624 +-- ...ity_perimeter_configurations_operations.py | 7 +- .../_notebook_workspaces_operations.py | 78 +- .../operations/_operations.py | 8 +- .../_partition_key_range_id_operations.py | 10 +- ...artition_key_range_id_region_operations.py | 10 +- .../azure_mgmt_cosmosdb/operations/_patch.py | 13 +- .../operations/_percentile_operations.py | 10 +- .../_percentile_source_target_operations.py | 10 +- .../_percentile_target_operations.py | 10 +- ...private_endpoint_connections_operations.py | 44 +- .../_private_link_resources_operations.py | 18 +- ...restorable_database_accounts_operations.py | 140 +- ...restorable_gremlin_databases_operations.py | 4 +- .../_restorable_gremlin_graphs_operations.py | 4 +- ...restorable_gremlin_resources_operations.py | 4 +- ...storable_mongodb_collections_operations.py | 4 +- ...restorable_mongodb_databases_operations.py | 4 +- ...restorable_mongodb_resources_operations.py | 4 +- .../_restorable_sql_containers_operations.py | 4 +- .../_restorable_sql_databases_operations.py | 4 +- .../_restorable_sql_resources_operations.py | 4 +- .../_restorable_table_resources_operations.py | 4 +- .../_restorable_tables_operations.py | 4 +- .../operations/_service_operations.py | 165 +- ...ft_deleted_database_accounts_operations.py | 761 +++ ..._soft_deleted_sql_containers_operations.py | 709 +++ .../_soft_deleted_sql_databases_operations.py | 673 +++ .../operations/_sql_resources_operations.py | 4450 ++++++++-------- .../operations/_table_resources_operations.py | 1942 +++---- .../_throughput_pool_account_operations.py | 25 +- .../_throughput_pool_accounts_operations.py | 2 +- .../operations/_throughput_pool_operations.py | 34 +- .../_throughput_pools_operations.py | 4 +- 123 files changed, 26621 insertions(+), 20259 deletions(-) create mode 100644 src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/aio/operations/_soft_deleted_database_accounts_operations.py create mode 100644 src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/aio/operations/_soft_deleted_sql_containers_operations.py create mode 100644 src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/aio/operations/_soft_deleted_sql_databases_operations.py create mode 100644 src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/operations/_soft_deleted_database_accounts_operations.py create mode 100644 src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/operations/_soft_deleted_sql_containers_operations.py create mode 100644 src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/operations/_soft_deleted_sql_databases_operations.py diff --git a/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/_configuration.py b/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/_configuration.py index 0dbe4009a06..90f3c436df9 100644 --- a/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/_configuration.py +++ b/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/_configuration.py @@ -31,7 +31,7 @@ class CosmosDBManagementClientConfiguration: # pylint: disable=too-many-instanc :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-11-01-preview". Note that overriding + :keyword api_version: Api Version. Default value is "2026-04-01-preview". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ @@ -43,7 +43,7 @@ def __init__( cloud_setting: Optional["AzureClouds"] = None, **kwargs: Any ) -> None: - api_version: str = kwargs.pop("api_version", "2025-11-01-preview") + api_version: str = kwargs.pop("api_version", "2026-04-01-preview") if credential is None: raise ValueError("Parameter 'credential' must not be None.") diff --git a/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/_cosmos_db_management_client.py b/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/_cosmos_db_management_client.py index b61f0083855..f1689f59df2 100644 --- a/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/_cosmos_db_management_client.py +++ b/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/_cosmos_db_management_client.py @@ -67,6 +67,9 @@ RestorableTableResourcesOperations, RestorableTablesOperations, ServiceOperations, + SoftDeletedDatabaseAccountsOperations, + SoftDeletedSqlContainersOperations, + SoftDeletedSqlDatabasesOperations, SqlResourcesOperations, TableResourcesOperations, ThroughputPoolAccountOperations, @@ -81,124 +84,133 @@ class CosmosDBManagementClient: # pylint: disable=too-many-instance-attributes - """Azure Cosmos DB Role Based Access Control Resource Provider REST API. + """Azure Cosmos DB Throughput Pool REST API. + :ivar database_accounts: DatabaseAccountsOperations operations + :vartype database_accounts: azure.mgmt.cosmosdb.operations.DatabaseAccountsOperations + :ivar operations: Operations operations + :vartype operations: azure.mgmt.cosmosdb.operations.Operations + :ivar cassandra_clusters: CassandraClustersOperations operations + :vartype cassandra_clusters: azure.mgmt.cosmosdb.operations.CassandraClustersOperations + :ivar fleet: FleetOperations operations + :vartype fleet: azure.mgmt.cosmosdb.operations.FleetOperations + :ivar garnet_clusters: GarnetClustersOperations operations + :vartype garnet_clusters: azure.mgmt.cosmosdb.operations.GarnetClustersOperations + :ivar locations: LocationsOperations operations + :vartype locations: azure.mgmt.cosmosdb.operations.LocationsOperations + :ivar restorable_database_accounts: RestorableDatabaseAccountsOperations operations + :vartype restorable_database_accounts: + azure.mgmt.cosmosdb.operations.RestorableDatabaseAccountsOperations + :ivar restorable_gremlin_graphs: RestorableGremlinGraphsOperations operations + :vartype restorable_gremlin_graphs: + azure.mgmt.cosmosdb.operations.RestorableGremlinGraphsOperations + :ivar restorable_gremlin_databases: RestorableGremlinDatabasesOperations operations + :vartype restorable_gremlin_databases: + azure.mgmt.cosmosdb.operations.RestorableGremlinDatabasesOperations + :ivar restorable_gremlin_resources: RestorableGremlinResourcesOperations operations + :vartype restorable_gremlin_resources: + azure.mgmt.cosmosdb.operations.RestorableGremlinResourcesOperations + :ivar restorable_mongodb_collections: RestorableMongodbCollectionsOperations operations + :vartype restorable_mongodb_collections: + azure.mgmt.cosmosdb.operations.RestorableMongodbCollectionsOperations + :ivar restorable_mongodb_databases: RestorableMongodbDatabasesOperations operations + :vartype restorable_mongodb_databases: + azure.mgmt.cosmosdb.operations.RestorableMongodbDatabasesOperations + :ivar restorable_mongodb_resources: RestorableMongodbResourcesOperations operations + :vartype restorable_mongodb_resources: + azure.mgmt.cosmosdb.operations.RestorableMongodbResourcesOperations + :ivar restorable_sql_containers: RestorableSqlContainersOperations operations + :vartype restorable_sql_containers: + azure.mgmt.cosmosdb.operations.RestorableSqlContainersOperations + :ivar restorable_sql_databases: RestorableSqlDatabasesOperations operations + :vartype restorable_sql_databases: + azure.mgmt.cosmosdb.operations.RestorableSqlDatabasesOperations + :ivar restorable_sql_resources: RestorableSqlResourcesOperations operations + :vartype restorable_sql_resources: + azure.mgmt.cosmosdb.operations.RestorableSqlResourcesOperations + :ivar restorable_table_resources: RestorableTableResourcesOperations operations + :vartype restorable_table_resources: + azure.mgmt.cosmosdb.operations.RestorableTableResourcesOperations + :ivar restorable_tables: RestorableTablesOperations operations + :vartype restorable_tables: azure.mgmt.cosmosdb.operations.RestorableTablesOperations + :ivar soft_deleted_database_accounts: SoftDeletedDatabaseAccountsOperations operations + :vartype soft_deleted_database_accounts: + azure.mgmt.cosmosdb.operations.SoftDeletedDatabaseAccountsOperations + :ivar throughput_pools: ThroughputPoolsOperations operations + :vartype throughput_pools: azure.mgmt.cosmosdb.operations.ThroughputPoolsOperations + :ivar cassandra_data_centers: CassandraDataCentersOperations operations + :vartype cassandra_data_centers: azure.mgmt.cosmosdb.operations.CassandraDataCentersOperations :ivar cassandra_resources: CassandraResourcesOperations operations :vartype cassandra_resources: azure.mgmt.cosmosdb.operations.CassandraResourcesOperations :ivar chaos_fault: ChaosFaultOperations operations :vartype chaos_fault: azure.mgmt.cosmosdb.operations.ChaosFaultOperations :ivar copy_jobs: CopyJobsOperations operations :vartype copy_jobs: azure.mgmt.cosmosdb.operations.CopyJobsOperations - :ivar database_accounts: DatabaseAccountsOperations operations - :vartype database_accounts: azure.mgmt.cosmosdb.operations.DatabaseAccountsOperations - :ivar operations: Operations operations - :vartype operations: azure.mgmt.cosmosdb.operations.Operations - :ivar database: DatabaseOperations operations - :vartype database: azure.mgmt.cosmosdb.operations.DatabaseOperations + :ivar data_transfer_jobs: DataTransferJobsOperations operations + :vartype data_transfer_jobs: azure.mgmt.cosmosdb.operations.DataTransferJobsOperations :ivar collection: CollectionOperations operations :vartype collection: azure.mgmt.cosmosdb.operations.CollectionOperations - :ivar collection_region: CollectionRegionOperations operations - :vartype collection_region: azure.mgmt.cosmosdb.operations.CollectionRegionOperations - :ivar database_account_region: DatabaseAccountRegionOperations operations - :vartype database_account_region: - azure.mgmt.cosmosdb.operations.DatabaseAccountRegionOperations - :ivar percentile_source_target: PercentileSourceTargetOperations operations - :vartype percentile_source_target: - azure.mgmt.cosmosdb.operations.PercentileSourceTargetOperations - :ivar percentile_target: PercentileTargetOperations operations - :vartype percentile_target: azure.mgmt.cosmosdb.operations.PercentileTargetOperations - :ivar percentile: PercentileOperations operations - :vartype percentile: azure.mgmt.cosmosdb.operations.PercentileOperations - :ivar collection_partition_region: CollectionPartitionRegionOperations operations - :vartype collection_partition_region: - azure.mgmt.cosmosdb.operations.CollectionPartitionRegionOperations - :ivar collection_partition: CollectionPartitionOperations operations - :vartype collection_partition: azure.mgmt.cosmosdb.operations.CollectionPartitionOperations :ivar partition_key_range_id: PartitionKeyRangeIdOperations operations :vartype partition_key_range_id: azure.mgmt.cosmosdb.operations.PartitionKeyRangeIdOperations - :ivar partition_key_range_id_region: PartitionKeyRangeIdRegionOperations operations - :vartype partition_key_range_id_region: - azure.mgmt.cosmosdb.operations.PartitionKeyRangeIdRegionOperations + :ivar collection_partition: CollectionPartitionOperations operations + :vartype collection_partition: azure.mgmt.cosmosdb.operations.CollectionPartitionOperations + :ivar database: DatabaseOperations operations + :vartype database: azure.mgmt.cosmosdb.operations.DatabaseOperations :ivar graph_resources: GraphResourcesOperations operations :vartype graph_resources: azure.mgmt.cosmosdb.operations.GraphResourcesOperations - :ivar sql_resources: SqlResourcesOperations operations - :vartype sql_resources: azure.mgmt.cosmosdb.operations.SqlResourcesOperations - :ivar mongo_db_resources: MongoDBResourcesOperations operations - :vartype mongo_db_resources: azure.mgmt.cosmosdb.operations.MongoDBResourcesOperations - :ivar table_resources: TableResourcesOperations operations - :vartype table_resources: azure.mgmt.cosmosdb.operations.TableResourcesOperations :ivar gremlin_resources: GremlinResourcesOperations operations :vartype gremlin_resources: azure.mgmt.cosmosdb.operations.GremlinResourcesOperations - :ivar locations: LocationsOperations operations - :vartype locations: azure.mgmt.cosmosdb.operations.LocationsOperations - :ivar data_transfer_jobs: DataTransferJobsOperations operations - :vartype data_transfer_jobs: azure.mgmt.cosmosdb.operations.DataTransferJobsOperations - :ivar fleet: FleetOperations operations - :vartype fleet: azure.mgmt.cosmosdb.operations.FleetOperations - :ivar fleet_analytics: FleetAnalyticsOperations operations - :vartype fleet_analytics: azure.mgmt.cosmosdb.operations.FleetAnalyticsOperations - :ivar fleetspace: FleetspaceOperations operations - :vartype fleetspace: azure.mgmt.cosmosdb.operations.FleetspaceOperations - :ivar fleetspace_account: FleetspaceAccountOperations operations - :vartype fleetspace_account: azure.mgmt.cosmosdb.operations.FleetspaceAccountOperations - :ivar garnet_clusters: GarnetClustersOperations operations - :vartype garnet_clusters: azure.mgmt.cosmosdb.operations.GarnetClustersOperations - :ivar cassandra_clusters: CassandraClustersOperations operations - :vartype cassandra_clusters: azure.mgmt.cosmosdb.operations.CassandraClustersOperations - :ivar cassandra_data_centers: CassandraDataCentersOperations operations - :vartype cassandra_data_centers: azure.mgmt.cosmosdb.operations.CassandraDataCentersOperations :ivar mongo_mi_resources: MongoMIResourcesOperations operations :vartype mongo_mi_resources: azure.mgmt.cosmosdb.operations.MongoMIResourcesOperations + :ivar mongo_db_resources: MongoDBResourcesOperations operations + :vartype mongo_db_resources: azure.mgmt.cosmosdb.operations.MongoDBResourcesOperations :ivar network_security_perimeter_configurations: NetworkSecurityPerimeterConfigurationsOperations operations :vartype network_security_perimeter_configurations: azure.mgmt.cosmosdb.operations.NetworkSecurityPerimeterConfigurationsOperations :ivar notebook_workspaces: NotebookWorkspacesOperations operations :vartype notebook_workspaces: azure.mgmt.cosmosdb.operations.NotebookWorkspacesOperations + :ivar percentile: PercentileOperations operations + :vartype percentile: azure.mgmt.cosmosdb.operations.PercentileOperations :ivar private_endpoint_connections: PrivateEndpointConnectionsOperations operations :vartype private_endpoint_connections: azure.mgmt.cosmosdb.operations.PrivateEndpointConnectionsOperations :ivar private_link_resources: PrivateLinkResourcesOperations operations :vartype private_link_resources: azure.mgmt.cosmosdb.operations.PrivateLinkResourcesOperations - :ivar restorable_database_accounts: RestorableDatabaseAccountsOperations operations - :vartype restorable_database_accounts: - azure.mgmt.cosmosdb.operations.RestorableDatabaseAccountsOperations - :ivar restorable_sql_databases: RestorableSqlDatabasesOperations operations - :vartype restorable_sql_databases: - azure.mgmt.cosmosdb.operations.RestorableSqlDatabasesOperations - :ivar restorable_sql_containers: RestorableSqlContainersOperations operations - :vartype restorable_sql_containers: - azure.mgmt.cosmosdb.operations.RestorableSqlContainersOperations - :ivar restorable_sql_resources: RestorableSqlResourcesOperations operations - :vartype restorable_sql_resources: - azure.mgmt.cosmosdb.operations.RestorableSqlResourcesOperations - :ivar restorable_mongodb_databases: RestorableMongodbDatabasesOperations operations - :vartype restorable_mongodb_databases: - azure.mgmt.cosmosdb.operations.RestorableMongodbDatabasesOperations - :ivar restorable_mongodb_collections: RestorableMongodbCollectionsOperations operations - :vartype restorable_mongodb_collections: - azure.mgmt.cosmosdb.operations.RestorableMongodbCollectionsOperations - :ivar restorable_mongodb_resources: RestorableMongodbResourcesOperations operations - :vartype restorable_mongodb_resources: - azure.mgmt.cosmosdb.operations.RestorableMongodbResourcesOperations - :ivar restorable_gremlin_databases: RestorableGremlinDatabasesOperations operations - :vartype restorable_gremlin_databases: - azure.mgmt.cosmosdb.operations.RestorableGremlinDatabasesOperations - :ivar restorable_gremlin_graphs: RestorableGremlinGraphsOperations operations - :vartype restorable_gremlin_graphs: - azure.mgmt.cosmosdb.operations.RestorableGremlinGraphsOperations - :ivar restorable_gremlin_resources: RestorableGremlinResourcesOperations operations - :vartype restorable_gremlin_resources: - azure.mgmt.cosmosdb.operations.RestorableGremlinResourcesOperations - :ivar restorable_tables: RestorableTablesOperations operations - :vartype restorable_tables: azure.mgmt.cosmosdb.operations.RestorableTablesOperations - :ivar restorable_table_resources: RestorableTableResourcesOperations operations - :vartype restorable_table_resources: - azure.mgmt.cosmosdb.operations.RestorableTableResourcesOperations + :ivar collection_region: CollectionRegionOperations operations + :vartype collection_region: azure.mgmt.cosmosdb.operations.CollectionRegionOperations + :ivar partition_key_range_id_region: PartitionKeyRangeIdRegionOperations operations + :vartype partition_key_range_id_region: + azure.mgmt.cosmosdb.operations.PartitionKeyRangeIdRegionOperations + :ivar collection_partition_region: CollectionPartitionRegionOperations operations + :vartype collection_partition_region: + azure.mgmt.cosmosdb.operations.CollectionPartitionRegionOperations + :ivar database_account_region: DatabaseAccountRegionOperations operations + :vartype database_account_region: + azure.mgmt.cosmosdb.operations.DatabaseAccountRegionOperations :ivar service: ServiceOperations operations :vartype service: azure.mgmt.cosmosdb.operations.ServiceOperations - :ivar throughput_pools: ThroughputPoolsOperations operations - :vartype throughput_pools: azure.mgmt.cosmosdb.operations.ThroughputPoolsOperations + :ivar percentile_source_target: PercentileSourceTargetOperations operations + :vartype percentile_source_target: + azure.mgmt.cosmosdb.operations.PercentileSourceTargetOperations + :ivar sql_resources: SqlResourcesOperations operations + :vartype sql_resources: azure.mgmt.cosmosdb.operations.SqlResourcesOperations + :ivar table_resources: TableResourcesOperations operations + :vartype table_resources: azure.mgmt.cosmosdb.operations.TableResourcesOperations + :ivar percentile_target: PercentileTargetOperations operations + :vartype percentile_target: azure.mgmt.cosmosdb.operations.PercentileTargetOperations + :ivar fleet_analytics: FleetAnalyticsOperations operations + :vartype fleet_analytics: azure.mgmt.cosmosdb.operations.FleetAnalyticsOperations + :ivar fleetspace: FleetspaceOperations operations + :vartype fleetspace: azure.mgmt.cosmosdb.operations.FleetspaceOperations + :ivar fleetspace_account: FleetspaceAccountOperations operations + :vartype fleetspace_account: azure.mgmt.cosmosdb.operations.FleetspaceAccountOperations + :ivar soft_deleted_sql_databases: SoftDeletedSqlDatabasesOperations operations + :vartype soft_deleted_sql_databases: + azure.mgmt.cosmosdb.operations.SoftDeletedSqlDatabasesOperations + :ivar soft_deleted_sql_containers: SoftDeletedSqlContainersOperations operations + :vartype soft_deleted_sql_containers: + azure.mgmt.cosmosdb.operations.SoftDeletedSqlContainersOperations :ivar throughput_pool: ThroughputPoolOperations operations :vartype throughput_pool: azure.mgmt.cosmosdb.operations.ThroughputPoolOperations :ivar throughput_pool_accounts: ThroughputPoolAccountsOperations operations @@ -216,7 +228,7 @@ class CosmosDBManagementClient: # pylint: disable=too-many-instance-attributes :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-11-01-preview". Note that overriding + :keyword api_version: Api Version. Default value is "2026-04-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 @@ -269,121 +281,130 @@ def __init__( self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.cassandra_resources = CassandraResourcesOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.chaos_fault = ChaosFaultOperations(self._client, self._config, self._serialize, self._deserialize) - self.copy_jobs = CopyJobsOperations(self._client, self._config, self._serialize, self._deserialize) self.database_accounts = DatabaseAccountsOperations( self._client, self._config, self._serialize, self._deserialize ) self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) - self.database = DatabaseOperations(self._client, self._config, self._serialize, self._deserialize) - self.collection = CollectionOperations(self._client, self._config, self._serialize, self._deserialize) - self.collection_region = CollectionRegionOperations( + self.cassandra_clusters = CassandraClustersOperations( self._client, self._config, self._serialize, self._deserialize ) - self.database_account_region = DatabaseAccountRegionOperations( + self.fleet = FleetOperations(self._client, self._config, self._serialize, self._deserialize) + self.garnet_clusters = GarnetClustersOperations(self._client, self._config, self._serialize, self._deserialize) + self.locations = LocationsOperations(self._client, self._config, self._serialize, self._deserialize) + self.restorable_database_accounts = RestorableDatabaseAccountsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.percentile_source_target = PercentileSourceTargetOperations( + self.restorable_gremlin_graphs = RestorableGremlinGraphsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.percentile_target = PercentileTargetOperations( + self.restorable_gremlin_databases = RestorableGremlinDatabasesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.percentile = PercentileOperations(self._client, self._config, self._serialize, self._deserialize) - self.collection_partition_region = CollectionPartitionRegionOperations( + self.restorable_gremlin_resources = RestorableGremlinResourcesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.collection_partition = CollectionPartitionOperations( + self.restorable_mongodb_collections = RestorableMongodbCollectionsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.partition_key_range_id = PartitionKeyRangeIdOperations( + self.restorable_mongodb_databases = RestorableMongodbDatabasesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.partition_key_range_id_region = PartitionKeyRangeIdRegionOperations( + self.restorable_mongodb_resources = RestorableMongodbResourcesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.graph_resources = GraphResourcesOperations(self._client, self._config, self._serialize, self._deserialize) - self.sql_resources = SqlResourcesOperations(self._client, self._config, self._serialize, self._deserialize) - self.mongo_db_resources = MongoDBResourcesOperations( + self.restorable_sql_containers = RestorableSqlContainersOperations( self._client, self._config, self._serialize, self._deserialize ) - self.table_resources = TableResourcesOperations(self._client, self._config, self._serialize, self._deserialize) - self.gremlin_resources = GremlinResourcesOperations( + self.restorable_sql_databases = RestorableSqlDatabasesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.locations = LocationsOperations(self._client, self._config, self._serialize, self._deserialize) - self.data_transfer_jobs = DataTransferJobsOperations( + self.restorable_sql_resources = RestorableSqlResourcesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.fleet = FleetOperations(self._client, self._config, self._serialize, self._deserialize) - self.fleet_analytics = FleetAnalyticsOperations(self._client, self._config, self._serialize, self._deserialize) - self.fleetspace = FleetspaceOperations(self._client, self._config, self._serialize, self._deserialize) - self.fleetspace_account = FleetspaceAccountOperations( + self.restorable_table_resources = RestorableTableResourcesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.garnet_clusters = GarnetClustersOperations(self._client, self._config, self._serialize, self._deserialize) - self.cassandra_clusters = CassandraClustersOperations( + self.restorable_tables = RestorableTablesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.cassandra_data_centers = CassandraDataCentersOperations( + self.soft_deleted_database_accounts = SoftDeletedDatabaseAccountsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.mongo_mi_resources = MongoMIResourcesOperations( + self.throughput_pools = ThroughputPoolsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.network_security_perimeter_configurations = NetworkSecurityPerimeterConfigurationsOperations( + self.cassandra_data_centers = CassandraDataCentersOperations( self._client, self._config, self._serialize, self._deserialize ) - self.notebook_workspaces = NotebookWorkspacesOperations( + self.cassandra_resources = CassandraResourcesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.private_endpoint_connections = PrivateEndpointConnectionsOperations( + self.chaos_fault = ChaosFaultOperations(self._client, self._config, self._serialize, self._deserialize) + self.copy_jobs = CopyJobsOperations(self._client, self._config, self._serialize, self._deserialize) + self.data_transfer_jobs = DataTransferJobsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.private_link_resources = PrivateLinkResourcesOperations( + self.collection = CollectionOperations(self._client, self._config, self._serialize, self._deserialize) + self.partition_key_range_id = PartitionKeyRangeIdOperations( self._client, self._config, self._serialize, self._deserialize ) - self.restorable_database_accounts = RestorableDatabaseAccountsOperations( + self.collection_partition = CollectionPartitionOperations( self._client, self._config, self._serialize, self._deserialize ) - self.restorable_sql_databases = RestorableSqlDatabasesOperations( + self.database = DatabaseOperations(self._client, self._config, self._serialize, self._deserialize) + self.graph_resources = GraphResourcesOperations(self._client, self._config, self._serialize, self._deserialize) + self.gremlin_resources = GremlinResourcesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.restorable_sql_containers = RestorableSqlContainersOperations( + self.mongo_mi_resources = MongoMIResourcesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.restorable_sql_resources = RestorableSqlResourcesOperations( + self.mongo_db_resources = MongoDBResourcesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.restorable_mongodb_databases = RestorableMongodbDatabasesOperations( + self.network_security_perimeter_configurations = NetworkSecurityPerimeterConfigurationsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.restorable_mongodb_collections = RestorableMongodbCollectionsOperations( + self.notebook_workspaces = NotebookWorkspacesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.restorable_mongodb_resources = RestorableMongodbResourcesOperations( + self.percentile = PercentileOperations(self._client, self._config, self._serialize, self._deserialize) + self.private_endpoint_connections = PrivateEndpointConnectionsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.restorable_gremlin_databases = RestorableGremlinDatabasesOperations( + self.private_link_resources = PrivateLinkResourcesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.restorable_gremlin_graphs = RestorableGremlinGraphsOperations( + self.collection_region = CollectionRegionOperations( self._client, self._config, self._serialize, self._deserialize ) - self.restorable_gremlin_resources = RestorableGremlinResourcesOperations( + self.partition_key_range_id_region = PartitionKeyRangeIdRegionOperations( self._client, self._config, self._serialize, self._deserialize ) - self.restorable_tables = RestorableTablesOperations( + self.collection_partition_region = CollectionPartitionRegionOperations( self._client, self._config, self._serialize, self._deserialize ) - self.restorable_table_resources = RestorableTableResourcesOperations( + self.database_account_region = DatabaseAccountRegionOperations( self._client, self._config, self._serialize, self._deserialize ) self.service = ServiceOperations(self._client, self._config, self._serialize, self._deserialize) - self.throughput_pools = ThroughputPoolsOperations( + self.percentile_source_target = PercentileSourceTargetOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.sql_resources = SqlResourcesOperations(self._client, self._config, self._serialize, self._deserialize) + self.table_resources = TableResourcesOperations(self._client, self._config, self._serialize, self._deserialize) + self.percentile_target = PercentileTargetOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.fleet_analytics = FleetAnalyticsOperations(self._client, self._config, self._serialize, self._deserialize) + self.fleetspace = FleetspaceOperations(self._client, self._config, self._serialize, self._deserialize) + self.fleetspace_account = FleetspaceAccountOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.soft_deleted_sql_databases = SoftDeletedSqlDatabasesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.soft_deleted_sql_containers = SoftDeletedSqlContainersOperations( self._client, self._config, self._serialize, self._deserialize ) self.throughput_pool = ThroughputPoolOperations(self._client, self._config, self._serialize, self._deserialize) diff --git a/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/_patch.py b/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/_patch.py index 17dbc073e01..87676c65a8f 100644 --- a/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/_patch.py +++ b/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/_patch.py @@ -1,32 +1,21 @@ # coding=utf-8 # -------------------------------------------------------------------------- -# # Copyright (c) Microsoft Corporation. All rights reserved. -# -# The MIT License (MIT) -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the ""Software""), to -# deal in the Software without restriction, including without limitation the -# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or -# sell copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS -# IN THE SOFTWARE. -# +# 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 +""" + + +__all__: list[str] = [] # Add all objects you want publicly available to users at this package level -# This file is used for handwritten extensions to the generated code. Example: -# https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): - pass + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/_version.py b/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/_version.py index 5acb87b765a..426da22cd96 100644 --- a/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/_version.py +++ b/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "10.0.0b6" +VERSION = "10.0.0b7" diff --git a/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/aio/_configuration.py b/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/aio/_configuration.py index 71185c38210..c4c39188e26 100644 --- a/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/aio/_configuration.py +++ b/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/aio/_configuration.py @@ -31,7 +31,7 @@ class CosmosDBManagementClientConfiguration: # pylint: disable=too-many-instanc :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-11-01-preview". Note that overriding + :keyword api_version: Api Version. Default value is "2026-04-01-preview". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ @@ -43,7 +43,7 @@ def __init__( cloud_setting: Optional["AzureClouds"] = None, **kwargs: Any ) -> None: - api_version: str = kwargs.pop("api_version", "2025-11-01-preview") + api_version: str = kwargs.pop("api_version", "2026-04-01-preview") if credential is None: raise ValueError("Parameter 'credential' must not be None.") diff --git a/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/aio/_cosmos_db_management_client.py b/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/aio/_cosmos_db_management_client.py index 0c5a2411491..52b9a82b3e1 100644 --- a/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/aio/_cosmos_db_management_client.py +++ b/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/aio/_cosmos_db_management_client.py @@ -67,6 +67,9 @@ RestorableTableResourcesOperations, RestorableTablesOperations, ServiceOperations, + SoftDeletedDatabaseAccountsOperations, + SoftDeletedSqlContainersOperations, + SoftDeletedSqlDatabasesOperations, SqlResourcesOperations, TableResourcesOperations, ThroughputPoolAccountOperations, @@ -81,127 +84,136 @@ class CosmosDBManagementClient: # pylint: disable=too-many-instance-attributes - """Azure Cosmos DB Role Based Access Control Resource Provider REST API. + """Azure Cosmos DB Throughput Pool REST API. + :ivar database_accounts: DatabaseAccountsOperations operations + :vartype database_accounts: azure.mgmt.cosmosdb.aio.operations.DatabaseAccountsOperations + :ivar operations: Operations operations + :vartype operations: azure.mgmt.cosmosdb.aio.operations.Operations + :ivar cassandra_clusters: CassandraClustersOperations operations + :vartype cassandra_clusters: azure.mgmt.cosmosdb.aio.operations.CassandraClustersOperations + :ivar fleet: FleetOperations operations + :vartype fleet: azure.mgmt.cosmosdb.aio.operations.FleetOperations + :ivar garnet_clusters: GarnetClustersOperations operations + :vartype garnet_clusters: azure.mgmt.cosmosdb.aio.operations.GarnetClustersOperations + :ivar locations: LocationsOperations operations + :vartype locations: azure.mgmt.cosmosdb.aio.operations.LocationsOperations + :ivar restorable_database_accounts: RestorableDatabaseAccountsOperations operations + :vartype restorable_database_accounts: + azure.mgmt.cosmosdb.aio.operations.RestorableDatabaseAccountsOperations + :ivar restorable_gremlin_graphs: RestorableGremlinGraphsOperations operations + :vartype restorable_gremlin_graphs: + azure.mgmt.cosmosdb.aio.operations.RestorableGremlinGraphsOperations + :ivar restorable_gremlin_databases: RestorableGremlinDatabasesOperations operations + :vartype restorable_gremlin_databases: + azure.mgmt.cosmosdb.aio.operations.RestorableGremlinDatabasesOperations + :ivar restorable_gremlin_resources: RestorableGremlinResourcesOperations operations + :vartype restorable_gremlin_resources: + azure.mgmt.cosmosdb.aio.operations.RestorableGremlinResourcesOperations + :ivar restorable_mongodb_collections: RestorableMongodbCollectionsOperations operations + :vartype restorable_mongodb_collections: + azure.mgmt.cosmosdb.aio.operations.RestorableMongodbCollectionsOperations + :ivar restorable_mongodb_databases: RestorableMongodbDatabasesOperations operations + :vartype restorable_mongodb_databases: + azure.mgmt.cosmosdb.aio.operations.RestorableMongodbDatabasesOperations + :ivar restorable_mongodb_resources: RestorableMongodbResourcesOperations operations + :vartype restorable_mongodb_resources: + azure.mgmt.cosmosdb.aio.operations.RestorableMongodbResourcesOperations + :ivar restorable_sql_containers: RestorableSqlContainersOperations operations + :vartype restorable_sql_containers: + azure.mgmt.cosmosdb.aio.operations.RestorableSqlContainersOperations + :ivar restorable_sql_databases: RestorableSqlDatabasesOperations operations + :vartype restorable_sql_databases: + azure.mgmt.cosmosdb.aio.operations.RestorableSqlDatabasesOperations + :ivar restorable_sql_resources: RestorableSqlResourcesOperations operations + :vartype restorable_sql_resources: + azure.mgmt.cosmosdb.aio.operations.RestorableSqlResourcesOperations + :ivar restorable_table_resources: RestorableTableResourcesOperations operations + :vartype restorable_table_resources: + azure.mgmt.cosmosdb.aio.operations.RestorableTableResourcesOperations + :ivar restorable_tables: RestorableTablesOperations operations + :vartype restorable_tables: azure.mgmt.cosmosdb.aio.operations.RestorableTablesOperations + :ivar soft_deleted_database_accounts: SoftDeletedDatabaseAccountsOperations operations + :vartype soft_deleted_database_accounts: + azure.mgmt.cosmosdb.aio.operations.SoftDeletedDatabaseAccountsOperations + :ivar throughput_pools: ThroughputPoolsOperations operations + :vartype throughput_pools: azure.mgmt.cosmosdb.aio.operations.ThroughputPoolsOperations + :ivar cassandra_data_centers: CassandraDataCentersOperations operations + :vartype cassandra_data_centers: + azure.mgmt.cosmosdb.aio.operations.CassandraDataCentersOperations :ivar cassandra_resources: CassandraResourcesOperations operations :vartype cassandra_resources: azure.mgmt.cosmosdb.aio.operations.CassandraResourcesOperations :ivar chaos_fault: ChaosFaultOperations operations :vartype chaos_fault: azure.mgmt.cosmosdb.aio.operations.ChaosFaultOperations :ivar copy_jobs: CopyJobsOperations operations :vartype copy_jobs: azure.mgmt.cosmosdb.aio.operations.CopyJobsOperations - :ivar database_accounts: DatabaseAccountsOperations operations - :vartype database_accounts: azure.mgmt.cosmosdb.aio.operations.DatabaseAccountsOperations - :ivar operations: Operations operations - :vartype operations: azure.mgmt.cosmosdb.aio.operations.Operations - :ivar database: DatabaseOperations operations - :vartype database: azure.mgmt.cosmosdb.aio.operations.DatabaseOperations + :ivar data_transfer_jobs: DataTransferJobsOperations operations + :vartype data_transfer_jobs: azure.mgmt.cosmosdb.aio.operations.DataTransferJobsOperations :ivar collection: CollectionOperations operations :vartype collection: azure.mgmt.cosmosdb.aio.operations.CollectionOperations - :ivar collection_region: CollectionRegionOperations operations - :vartype collection_region: azure.mgmt.cosmosdb.aio.operations.CollectionRegionOperations - :ivar database_account_region: DatabaseAccountRegionOperations operations - :vartype database_account_region: - azure.mgmt.cosmosdb.aio.operations.DatabaseAccountRegionOperations - :ivar percentile_source_target: PercentileSourceTargetOperations operations - :vartype percentile_source_target: - azure.mgmt.cosmosdb.aio.operations.PercentileSourceTargetOperations - :ivar percentile_target: PercentileTargetOperations operations - :vartype percentile_target: azure.mgmt.cosmosdb.aio.operations.PercentileTargetOperations - :ivar percentile: PercentileOperations operations - :vartype percentile: azure.mgmt.cosmosdb.aio.operations.PercentileOperations - :ivar collection_partition_region: CollectionPartitionRegionOperations operations - :vartype collection_partition_region: - azure.mgmt.cosmosdb.aio.operations.CollectionPartitionRegionOperations - :ivar collection_partition: CollectionPartitionOperations operations - :vartype collection_partition: azure.mgmt.cosmosdb.aio.operations.CollectionPartitionOperations :ivar partition_key_range_id: PartitionKeyRangeIdOperations operations :vartype partition_key_range_id: azure.mgmt.cosmosdb.aio.operations.PartitionKeyRangeIdOperations - :ivar partition_key_range_id_region: PartitionKeyRangeIdRegionOperations operations - :vartype partition_key_range_id_region: - azure.mgmt.cosmosdb.aio.operations.PartitionKeyRangeIdRegionOperations + :ivar collection_partition: CollectionPartitionOperations operations + :vartype collection_partition: azure.mgmt.cosmosdb.aio.operations.CollectionPartitionOperations + :ivar database: DatabaseOperations operations + :vartype database: azure.mgmt.cosmosdb.aio.operations.DatabaseOperations :ivar graph_resources: GraphResourcesOperations operations :vartype graph_resources: azure.mgmt.cosmosdb.aio.operations.GraphResourcesOperations - :ivar sql_resources: SqlResourcesOperations operations - :vartype sql_resources: azure.mgmt.cosmosdb.aio.operations.SqlResourcesOperations - :ivar mongo_db_resources: MongoDBResourcesOperations operations - :vartype mongo_db_resources: azure.mgmt.cosmosdb.aio.operations.MongoDBResourcesOperations - :ivar table_resources: TableResourcesOperations operations - :vartype table_resources: azure.mgmt.cosmosdb.aio.operations.TableResourcesOperations :ivar gremlin_resources: GremlinResourcesOperations operations :vartype gremlin_resources: azure.mgmt.cosmosdb.aio.operations.GremlinResourcesOperations - :ivar locations: LocationsOperations operations - :vartype locations: azure.mgmt.cosmosdb.aio.operations.LocationsOperations - :ivar data_transfer_jobs: DataTransferJobsOperations operations - :vartype data_transfer_jobs: azure.mgmt.cosmosdb.aio.operations.DataTransferJobsOperations - :ivar fleet: FleetOperations operations - :vartype fleet: azure.mgmt.cosmosdb.aio.operations.FleetOperations - :ivar fleet_analytics: FleetAnalyticsOperations operations - :vartype fleet_analytics: azure.mgmt.cosmosdb.aio.operations.FleetAnalyticsOperations - :ivar fleetspace: FleetspaceOperations operations - :vartype fleetspace: azure.mgmt.cosmosdb.aio.operations.FleetspaceOperations - :ivar fleetspace_account: FleetspaceAccountOperations operations - :vartype fleetspace_account: azure.mgmt.cosmosdb.aio.operations.FleetspaceAccountOperations - :ivar garnet_clusters: GarnetClustersOperations operations - :vartype garnet_clusters: azure.mgmt.cosmosdb.aio.operations.GarnetClustersOperations - :ivar cassandra_clusters: CassandraClustersOperations operations - :vartype cassandra_clusters: azure.mgmt.cosmosdb.aio.operations.CassandraClustersOperations - :ivar cassandra_data_centers: CassandraDataCentersOperations operations - :vartype cassandra_data_centers: - azure.mgmt.cosmosdb.aio.operations.CassandraDataCentersOperations :ivar mongo_mi_resources: MongoMIResourcesOperations operations :vartype mongo_mi_resources: azure.mgmt.cosmosdb.aio.operations.MongoMIResourcesOperations + :ivar mongo_db_resources: MongoDBResourcesOperations operations + :vartype mongo_db_resources: azure.mgmt.cosmosdb.aio.operations.MongoDBResourcesOperations :ivar network_security_perimeter_configurations: NetworkSecurityPerimeterConfigurationsOperations operations :vartype network_security_perimeter_configurations: azure.mgmt.cosmosdb.aio.operations.NetworkSecurityPerimeterConfigurationsOperations :ivar notebook_workspaces: NotebookWorkspacesOperations operations :vartype notebook_workspaces: azure.mgmt.cosmosdb.aio.operations.NotebookWorkspacesOperations + :ivar percentile: PercentileOperations operations + :vartype percentile: azure.mgmt.cosmosdb.aio.operations.PercentileOperations :ivar private_endpoint_connections: PrivateEndpointConnectionsOperations operations :vartype private_endpoint_connections: azure.mgmt.cosmosdb.aio.operations.PrivateEndpointConnectionsOperations :ivar private_link_resources: PrivateLinkResourcesOperations operations :vartype private_link_resources: azure.mgmt.cosmosdb.aio.operations.PrivateLinkResourcesOperations - :ivar restorable_database_accounts: RestorableDatabaseAccountsOperations operations - :vartype restorable_database_accounts: - azure.mgmt.cosmosdb.aio.operations.RestorableDatabaseAccountsOperations - :ivar restorable_sql_databases: RestorableSqlDatabasesOperations operations - :vartype restorable_sql_databases: - azure.mgmt.cosmosdb.aio.operations.RestorableSqlDatabasesOperations - :ivar restorable_sql_containers: RestorableSqlContainersOperations operations - :vartype restorable_sql_containers: - azure.mgmt.cosmosdb.aio.operations.RestorableSqlContainersOperations - :ivar restorable_sql_resources: RestorableSqlResourcesOperations operations - :vartype restorable_sql_resources: - azure.mgmt.cosmosdb.aio.operations.RestorableSqlResourcesOperations - :ivar restorable_mongodb_databases: RestorableMongodbDatabasesOperations operations - :vartype restorable_mongodb_databases: - azure.mgmt.cosmosdb.aio.operations.RestorableMongodbDatabasesOperations - :ivar restorable_mongodb_collections: RestorableMongodbCollectionsOperations operations - :vartype restorable_mongodb_collections: - azure.mgmt.cosmosdb.aio.operations.RestorableMongodbCollectionsOperations - :ivar restorable_mongodb_resources: RestorableMongodbResourcesOperations operations - :vartype restorable_mongodb_resources: - azure.mgmt.cosmosdb.aio.operations.RestorableMongodbResourcesOperations - :ivar restorable_gremlin_databases: RestorableGremlinDatabasesOperations operations - :vartype restorable_gremlin_databases: - azure.mgmt.cosmosdb.aio.operations.RestorableGremlinDatabasesOperations - :ivar restorable_gremlin_graphs: RestorableGremlinGraphsOperations operations - :vartype restorable_gremlin_graphs: - azure.mgmt.cosmosdb.aio.operations.RestorableGremlinGraphsOperations - :ivar restorable_gremlin_resources: RestorableGremlinResourcesOperations operations - :vartype restorable_gremlin_resources: - azure.mgmt.cosmosdb.aio.operations.RestorableGremlinResourcesOperations - :ivar restorable_tables: RestorableTablesOperations operations - :vartype restorable_tables: azure.mgmt.cosmosdb.aio.operations.RestorableTablesOperations - :ivar restorable_table_resources: RestorableTableResourcesOperations operations - :vartype restorable_table_resources: - azure.mgmt.cosmosdb.aio.operations.RestorableTableResourcesOperations + :ivar collection_region: CollectionRegionOperations operations + :vartype collection_region: azure.mgmt.cosmosdb.aio.operations.CollectionRegionOperations + :ivar partition_key_range_id_region: PartitionKeyRangeIdRegionOperations operations + :vartype partition_key_range_id_region: + azure.mgmt.cosmosdb.aio.operations.PartitionKeyRangeIdRegionOperations + :ivar collection_partition_region: CollectionPartitionRegionOperations operations + :vartype collection_partition_region: + azure.mgmt.cosmosdb.aio.operations.CollectionPartitionRegionOperations + :ivar database_account_region: DatabaseAccountRegionOperations operations + :vartype database_account_region: + azure.mgmt.cosmosdb.aio.operations.DatabaseAccountRegionOperations :ivar service: ServiceOperations operations :vartype service: azure.mgmt.cosmosdb.aio.operations.ServiceOperations - :ivar throughput_pools: ThroughputPoolsOperations operations - :vartype throughput_pools: azure.mgmt.cosmosdb.aio.operations.ThroughputPoolsOperations + :ivar percentile_source_target: PercentileSourceTargetOperations operations + :vartype percentile_source_target: + azure.mgmt.cosmosdb.aio.operations.PercentileSourceTargetOperations + :ivar sql_resources: SqlResourcesOperations operations + :vartype sql_resources: azure.mgmt.cosmosdb.aio.operations.SqlResourcesOperations + :ivar table_resources: TableResourcesOperations operations + :vartype table_resources: azure.mgmt.cosmosdb.aio.operations.TableResourcesOperations + :ivar percentile_target: PercentileTargetOperations operations + :vartype percentile_target: azure.mgmt.cosmosdb.aio.operations.PercentileTargetOperations + :ivar fleet_analytics: FleetAnalyticsOperations operations + :vartype fleet_analytics: azure.mgmt.cosmosdb.aio.operations.FleetAnalyticsOperations + :ivar fleetspace: FleetspaceOperations operations + :vartype fleetspace: azure.mgmt.cosmosdb.aio.operations.FleetspaceOperations + :ivar fleetspace_account: FleetspaceAccountOperations operations + :vartype fleetspace_account: azure.mgmt.cosmosdb.aio.operations.FleetspaceAccountOperations + :ivar soft_deleted_sql_databases: SoftDeletedSqlDatabasesOperations operations + :vartype soft_deleted_sql_databases: + azure.mgmt.cosmosdb.aio.operations.SoftDeletedSqlDatabasesOperations + :ivar soft_deleted_sql_containers: SoftDeletedSqlContainersOperations operations + :vartype soft_deleted_sql_containers: + azure.mgmt.cosmosdb.aio.operations.SoftDeletedSqlContainersOperations :ivar throughput_pool: ThroughputPoolOperations operations :vartype throughput_pool: azure.mgmt.cosmosdb.aio.operations.ThroughputPoolOperations :ivar throughput_pool_accounts: ThroughputPoolAccountsOperations operations @@ -219,7 +231,7 @@ class CosmosDBManagementClient: # pylint: disable=too-many-instance-attributes :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-11-01-preview". Note that overriding + :keyword api_version: Api Version. Default value is "2026-04-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 @@ -274,121 +286,130 @@ def __init__( self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.cassandra_resources = CassandraResourcesOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.chaos_fault = ChaosFaultOperations(self._client, self._config, self._serialize, self._deserialize) - self.copy_jobs = CopyJobsOperations(self._client, self._config, self._serialize, self._deserialize) self.database_accounts = DatabaseAccountsOperations( self._client, self._config, self._serialize, self._deserialize ) self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) - self.database = DatabaseOperations(self._client, self._config, self._serialize, self._deserialize) - self.collection = CollectionOperations(self._client, self._config, self._serialize, self._deserialize) - self.collection_region = CollectionRegionOperations( + self.cassandra_clusters = CassandraClustersOperations( self._client, self._config, self._serialize, self._deserialize ) - self.database_account_region = DatabaseAccountRegionOperations( + self.fleet = FleetOperations(self._client, self._config, self._serialize, self._deserialize) + self.garnet_clusters = GarnetClustersOperations(self._client, self._config, self._serialize, self._deserialize) + self.locations = LocationsOperations(self._client, self._config, self._serialize, self._deserialize) + self.restorable_database_accounts = RestorableDatabaseAccountsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.percentile_source_target = PercentileSourceTargetOperations( + self.restorable_gremlin_graphs = RestorableGremlinGraphsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.percentile_target = PercentileTargetOperations( + self.restorable_gremlin_databases = RestorableGremlinDatabasesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.percentile = PercentileOperations(self._client, self._config, self._serialize, self._deserialize) - self.collection_partition_region = CollectionPartitionRegionOperations( + self.restorable_gremlin_resources = RestorableGremlinResourcesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.collection_partition = CollectionPartitionOperations( + self.restorable_mongodb_collections = RestorableMongodbCollectionsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.partition_key_range_id = PartitionKeyRangeIdOperations( + self.restorable_mongodb_databases = RestorableMongodbDatabasesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.partition_key_range_id_region = PartitionKeyRangeIdRegionOperations( + self.restorable_mongodb_resources = RestorableMongodbResourcesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.graph_resources = GraphResourcesOperations(self._client, self._config, self._serialize, self._deserialize) - self.sql_resources = SqlResourcesOperations(self._client, self._config, self._serialize, self._deserialize) - self.mongo_db_resources = MongoDBResourcesOperations( + self.restorable_sql_containers = RestorableSqlContainersOperations( self._client, self._config, self._serialize, self._deserialize ) - self.table_resources = TableResourcesOperations(self._client, self._config, self._serialize, self._deserialize) - self.gremlin_resources = GremlinResourcesOperations( + self.restorable_sql_databases = RestorableSqlDatabasesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.locations = LocationsOperations(self._client, self._config, self._serialize, self._deserialize) - self.data_transfer_jobs = DataTransferJobsOperations( + self.restorable_sql_resources = RestorableSqlResourcesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.fleet = FleetOperations(self._client, self._config, self._serialize, self._deserialize) - self.fleet_analytics = FleetAnalyticsOperations(self._client, self._config, self._serialize, self._deserialize) - self.fleetspace = FleetspaceOperations(self._client, self._config, self._serialize, self._deserialize) - self.fleetspace_account = FleetspaceAccountOperations( + self.restorable_table_resources = RestorableTableResourcesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.garnet_clusters = GarnetClustersOperations(self._client, self._config, self._serialize, self._deserialize) - self.cassandra_clusters = CassandraClustersOperations( + self.restorable_tables = RestorableTablesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.cassandra_data_centers = CassandraDataCentersOperations( + self.soft_deleted_database_accounts = SoftDeletedDatabaseAccountsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.mongo_mi_resources = MongoMIResourcesOperations( + self.throughput_pools = ThroughputPoolsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.network_security_perimeter_configurations = NetworkSecurityPerimeterConfigurationsOperations( + self.cassandra_data_centers = CassandraDataCentersOperations( self._client, self._config, self._serialize, self._deserialize ) - self.notebook_workspaces = NotebookWorkspacesOperations( + self.cassandra_resources = CassandraResourcesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.private_endpoint_connections = PrivateEndpointConnectionsOperations( + self.chaos_fault = ChaosFaultOperations(self._client, self._config, self._serialize, self._deserialize) + self.copy_jobs = CopyJobsOperations(self._client, self._config, self._serialize, self._deserialize) + self.data_transfer_jobs = DataTransferJobsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.private_link_resources = PrivateLinkResourcesOperations( + self.collection = CollectionOperations(self._client, self._config, self._serialize, self._deserialize) + self.partition_key_range_id = PartitionKeyRangeIdOperations( self._client, self._config, self._serialize, self._deserialize ) - self.restorable_database_accounts = RestorableDatabaseAccountsOperations( + self.collection_partition = CollectionPartitionOperations( self._client, self._config, self._serialize, self._deserialize ) - self.restorable_sql_databases = RestorableSqlDatabasesOperations( + self.database = DatabaseOperations(self._client, self._config, self._serialize, self._deserialize) + self.graph_resources = GraphResourcesOperations(self._client, self._config, self._serialize, self._deserialize) + self.gremlin_resources = GremlinResourcesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.restorable_sql_containers = RestorableSqlContainersOperations( + self.mongo_mi_resources = MongoMIResourcesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.restorable_sql_resources = RestorableSqlResourcesOperations( + self.mongo_db_resources = MongoDBResourcesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.restorable_mongodb_databases = RestorableMongodbDatabasesOperations( + self.network_security_perimeter_configurations = NetworkSecurityPerimeterConfigurationsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.restorable_mongodb_collections = RestorableMongodbCollectionsOperations( + self.notebook_workspaces = NotebookWorkspacesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.restorable_mongodb_resources = RestorableMongodbResourcesOperations( + self.percentile = PercentileOperations(self._client, self._config, self._serialize, self._deserialize) + self.private_endpoint_connections = PrivateEndpointConnectionsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.restorable_gremlin_databases = RestorableGremlinDatabasesOperations( + self.private_link_resources = PrivateLinkResourcesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.restorable_gremlin_graphs = RestorableGremlinGraphsOperations( + self.collection_region = CollectionRegionOperations( self._client, self._config, self._serialize, self._deserialize ) - self.restorable_gremlin_resources = RestorableGremlinResourcesOperations( + self.partition_key_range_id_region = PartitionKeyRangeIdRegionOperations( self._client, self._config, self._serialize, self._deserialize ) - self.restorable_tables = RestorableTablesOperations( + self.collection_partition_region = CollectionPartitionRegionOperations( self._client, self._config, self._serialize, self._deserialize ) - self.restorable_table_resources = RestorableTableResourcesOperations( + self.database_account_region = DatabaseAccountRegionOperations( self._client, self._config, self._serialize, self._deserialize ) self.service = ServiceOperations(self._client, self._config, self._serialize, self._deserialize) - self.throughput_pools = ThroughputPoolsOperations( + self.percentile_source_target = PercentileSourceTargetOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.sql_resources = SqlResourcesOperations(self._client, self._config, self._serialize, self._deserialize) + self.table_resources = TableResourcesOperations(self._client, self._config, self._serialize, self._deserialize) + self.percentile_target = PercentileTargetOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.fleet_analytics = FleetAnalyticsOperations(self._client, self._config, self._serialize, self._deserialize) + self.fleetspace = FleetspaceOperations(self._client, self._config, self._serialize, self._deserialize) + self.fleetspace_account = FleetspaceAccountOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.soft_deleted_sql_databases = SoftDeletedSqlDatabasesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.soft_deleted_sql_containers = SoftDeletedSqlContainersOperations( self._client, self._config, self._serialize, self._deserialize ) self.throughput_pool = ThroughputPoolOperations(self._client, self._config, self._serialize, self._deserialize) diff --git a/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/aio/_patch.py b/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/aio/_patch.py index 17dbc073e01..87676c65a8f 100644 --- a/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/aio/_patch.py +++ b/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/aio/_patch.py @@ -1,32 +1,21 @@ # coding=utf-8 # -------------------------------------------------------------------------- -# # Copyright (c) Microsoft Corporation. All rights reserved. -# -# The MIT License (MIT) -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the ""Software""), to -# deal in the Software without restriction, including without limitation the -# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or -# sell copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS -# IN THE SOFTWARE. -# +# 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 +""" + + +__all__: list[str] = [] # Add all objects you want publicly available to users at this package level -# This file is used for handwritten extensions to the generated code. Example: -# https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): - pass + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/aio/operations/__init__.py b/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/aio/operations/__init__.py index 295ed2a7e9f..06a3aa3ef61 100644 --- a/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/aio/operations/__init__.py +++ b/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/aio/operations/__init__.py @@ -13,55 +13,58 @@ if TYPE_CHECKING: from ._patch import * # pylint: disable=unused-wildcard-import +from ._database_accounts_operations import DatabaseAccountsOperations # type: ignore +from ._operations import Operations # type: ignore +from ._cassandra_clusters_operations import CassandraClustersOperations # type: ignore +from ._fleet_operations import FleetOperations # type: ignore +from ._garnet_clusters_operations import GarnetClustersOperations # type: ignore +from ._locations_operations import LocationsOperations # type: ignore +from ._restorable_database_accounts_operations import RestorableDatabaseAccountsOperations # type: ignore +from ._restorable_gremlin_graphs_operations import RestorableGremlinGraphsOperations # type: ignore +from ._restorable_gremlin_databases_operations import RestorableGremlinDatabasesOperations # type: ignore +from ._restorable_gremlin_resources_operations import RestorableGremlinResourcesOperations # type: ignore +from ._restorable_mongodb_collections_operations import RestorableMongodbCollectionsOperations # type: ignore +from ._restorable_mongodb_databases_operations import RestorableMongodbDatabasesOperations # type: ignore +from ._restorable_mongodb_resources_operations import RestorableMongodbResourcesOperations # type: ignore +from ._restorable_sql_containers_operations import RestorableSqlContainersOperations # type: ignore +from ._restorable_sql_databases_operations import RestorableSqlDatabasesOperations # type: ignore +from ._restorable_sql_resources_operations import RestorableSqlResourcesOperations # type: ignore +from ._restorable_table_resources_operations import RestorableTableResourcesOperations # type: ignore +from ._restorable_tables_operations import RestorableTablesOperations # type: ignore +from ._soft_deleted_database_accounts_operations import SoftDeletedDatabaseAccountsOperations # type: ignore +from ._throughput_pools_operations import ThroughputPoolsOperations # type: ignore +from ._cassandra_data_centers_operations import CassandraDataCentersOperations # type: ignore from ._cassandra_resources_operations import CassandraResourcesOperations # type: ignore from ._chaos_fault_operations import ChaosFaultOperations # type: ignore from ._copy_jobs_operations import CopyJobsOperations # type: ignore -from ._database_accounts_operations import DatabaseAccountsOperations # type: ignore -from ._operations import Operations # type: ignore -from ._database_operations import DatabaseOperations # type: ignore +from ._data_transfer_jobs_operations import DataTransferJobsOperations # type: ignore from ._collection_operations import CollectionOperations # type: ignore -from ._collection_region_operations import CollectionRegionOperations # type: ignore -from ._database_account_region_operations import DatabaseAccountRegionOperations # type: ignore -from ._percentile_source_target_operations import PercentileSourceTargetOperations # type: ignore -from ._percentile_target_operations import PercentileTargetOperations # type: ignore -from ._percentile_operations import PercentileOperations # type: ignore -from ._collection_partition_region_operations import CollectionPartitionRegionOperations # type: ignore -from ._collection_partition_operations import CollectionPartitionOperations # type: ignore from ._partition_key_range_id_operations import PartitionKeyRangeIdOperations # type: ignore -from ._partition_key_range_id_region_operations import PartitionKeyRangeIdRegionOperations # type: ignore +from ._collection_partition_operations import CollectionPartitionOperations # type: ignore +from ._database_operations import DatabaseOperations # type: ignore from ._graph_resources_operations import GraphResourcesOperations # type: ignore -from ._sql_resources_operations import SqlResourcesOperations # type: ignore -from ._mongo_db_resources_operations import MongoDBResourcesOperations # type: ignore -from ._table_resources_operations import TableResourcesOperations # type: ignore from ._gremlin_resources_operations import GremlinResourcesOperations # type: ignore -from ._locations_operations import LocationsOperations # type: ignore -from ._data_transfer_jobs_operations import DataTransferJobsOperations # type: ignore -from ._fleet_operations import FleetOperations # type: ignore -from ._fleet_analytics_operations import FleetAnalyticsOperations # type: ignore -from ._fleetspace_operations import FleetspaceOperations # type: ignore -from ._fleetspace_account_operations import FleetspaceAccountOperations # type: ignore -from ._garnet_clusters_operations import GarnetClustersOperations # type: ignore -from ._cassandra_clusters_operations import CassandraClustersOperations # type: ignore -from ._cassandra_data_centers_operations import CassandraDataCentersOperations # type: ignore from ._mongo_mi_resources_operations import MongoMIResourcesOperations # type: ignore +from ._mongo_db_resources_operations import MongoDBResourcesOperations # type: ignore from ._network_security_perimeter_configurations_operations import NetworkSecurityPerimeterConfigurationsOperations # type: ignore from ._notebook_workspaces_operations import NotebookWorkspacesOperations # type: ignore +from ._percentile_operations import PercentileOperations # type: ignore from ._private_endpoint_connections_operations import PrivateEndpointConnectionsOperations # type: ignore from ._private_link_resources_operations import PrivateLinkResourcesOperations # type: ignore -from ._restorable_database_accounts_operations import RestorableDatabaseAccountsOperations # type: ignore -from ._restorable_sql_databases_operations import RestorableSqlDatabasesOperations # type: ignore -from ._restorable_sql_containers_operations import RestorableSqlContainersOperations # type: ignore -from ._restorable_sql_resources_operations import RestorableSqlResourcesOperations # type: ignore -from ._restorable_mongodb_databases_operations import RestorableMongodbDatabasesOperations # type: ignore -from ._restorable_mongodb_collections_operations import RestorableMongodbCollectionsOperations # type: ignore -from ._restorable_mongodb_resources_operations import RestorableMongodbResourcesOperations # type: ignore -from ._restorable_gremlin_databases_operations import RestorableGremlinDatabasesOperations # type: ignore -from ._restorable_gremlin_graphs_operations import RestorableGremlinGraphsOperations # type: ignore -from ._restorable_gremlin_resources_operations import RestorableGremlinResourcesOperations # type: ignore -from ._restorable_tables_operations import RestorableTablesOperations # type: ignore -from ._restorable_table_resources_operations import RestorableTableResourcesOperations # type: ignore +from ._collection_region_operations import CollectionRegionOperations # type: ignore +from ._partition_key_range_id_region_operations import PartitionKeyRangeIdRegionOperations # type: ignore +from ._collection_partition_region_operations import CollectionPartitionRegionOperations # type: ignore +from ._database_account_region_operations import DatabaseAccountRegionOperations # type: ignore from ._service_operations import ServiceOperations # type: ignore -from ._throughput_pools_operations import ThroughputPoolsOperations # type: ignore +from ._percentile_source_target_operations import PercentileSourceTargetOperations # type: ignore +from ._sql_resources_operations import SqlResourcesOperations # type: ignore +from ._table_resources_operations import TableResourcesOperations # type: ignore +from ._percentile_target_operations import PercentileTargetOperations # type: ignore +from ._fleet_analytics_operations import FleetAnalyticsOperations # type: ignore +from ._fleetspace_operations import FleetspaceOperations # type: ignore +from ._fleetspace_account_operations import FleetspaceAccountOperations # type: ignore +from ._soft_deleted_sql_databases_operations import SoftDeletedSqlDatabasesOperations # type: ignore +from ._soft_deleted_sql_containers_operations import SoftDeletedSqlContainersOperations # type: ignore from ._throughput_pool_operations import ThroughputPoolOperations # type: ignore from ._throughput_pool_accounts_operations import ThroughputPoolAccountsOperations # type: ignore from ._throughput_pool_account_operations import ThroughputPoolAccountOperations # type: ignore @@ -71,55 +74,58 @@ from ._patch import patch_sdk as _patch_sdk __all__ = [ + "DatabaseAccountsOperations", + "Operations", + "CassandraClustersOperations", + "FleetOperations", + "GarnetClustersOperations", + "LocationsOperations", + "RestorableDatabaseAccountsOperations", + "RestorableGremlinGraphsOperations", + "RestorableGremlinDatabasesOperations", + "RestorableGremlinResourcesOperations", + "RestorableMongodbCollectionsOperations", + "RestorableMongodbDatabasesOperations", + "RestorableMongodbResourcesOperations", + "RestorableSqlContainersOperations", + "RestorableSqlDatabasesOperations", + "RestorableSqlResourcesOperations", + "RestorableTableResourcesOperations", + "RestorableTablesOperations", + "SoftDeletedDatabaseAccountsOperations", + "ThroughputPoolsOperations", + "CassandraDataCentersOperations", "CassandraResourcesOperations", "ChaosFaultOperations", "CopyJobsOperations", - "DatabaseAccountsOperations", - "Operations", - "DatabaseOperations", + "DataTransferJobsOperations", "CollectionOperations", - "CollectionRegionOperations", - "DatabaseAccountRegionOperations", - "PercentileSourceTargetOperations", - "PercentileTargetOperations", - "PercentileOperations", - "CollectionPartitionRegionOperations", - "CollectionPartitionOperations", "PartitionKeyRangeIdOperations", - "PartitionKeyRangeIdRegionOperations", + "CollectionPartitionOperations", + "DatabaseOperations", "GraphResourcesOperations", - "SqlResourcesOperations", - "MongoDBResourcesOperations", - "TableResourcesOperations", "GremlinResourcesOperations", - "LocationsOperations", - "DataTransferJobsOperations", - "FleetOperations", - "FleetAnalyticsOperations", - "FleetspaceOperations", - "FleetspaceAccountOperations", - "GarnetClustersOperations", - "CassandraClustersOperations", - "CassandraDataCentersOperations", "MongoMIResourcesOperations", + "MongoDBResourcesOperations", "NetworkSecurityPerimeterConfigurationsOperations", "NotebookWorkspacesOperations", + "PercentileOperations", "PrivateEndpointConnectionsOperations", "PrivateLinkResourcesOperations", - "RestorableDatabaseAccountsOperations", - "RestorableSqlDatabasesOperations", - "RestorableSqlContainersOperations", - "RestorableSqlResourcesOperations", - "RestorableMongodbDatabasesOperations", - "RestorableMongodbCollectionsOperations", - "RestorableMongodbResourcesOperations", - "RestorableGremlinDatabasesOperations", - "RestorableGremlinGraphsOperations", - "RestorableGremlinResourcesOperations", - "RestorableTablesOperations", - "RestorableTableResourcesOperations", + "CollectionRegionOperations", + "PartitionKeyRangeIdRegionOperations", + "CollectionPartitionRegionOperations", + "DatabaseAccountRegionOperations", "ServiceOperations", - "ThroughputPoolsOperations", + "PercentileSourceTargetOperations", + "SqlResourcesOperations", + "TableResourcesOperations", + "PercentileTargetOperations", + "FleetAnalyticsOperations", + "FleetspaceOperations", + "FleetspaceAccountOperations", + "SoftDeletedSqlDatabasesOperations", + "SoftDeletedSqlContainersOperations", "ThroughputPoolOperations", "ThroughputPoolAccountsOperations", "ThroughputPoolAccountOperations", diff --git a/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/aio/operations/_cassandra_clusters_operations.py b/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/aio/operations/_cassandra_clusters_operations.py index 61073f9b404..4d059787d3d 100644 --- a/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/aio/operations/_cassandra_clusters_operations.py +++ b/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/aio/operations/_cassandra_clusters_operations.py @@ -132,7 +132,7 @@ async def extract_data(pipeline_response): list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore - return None, AsyncList(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): _request = prepare_request(next_link) @@ -212,7 +212,7 @@ async def extract_data(pipeline_response): list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore - return None, AsyncList(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): _request = prepare_request(next_link) @@ -286,107 +286,6 @@ async def get(self, resource_group_name: str, cluster_name: str, **kwargs: Any) return deserialized # type: ignore - async def _delete_initial(self, resource_group_name: str, cluster_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, - cluster_name=cluster_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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def begin_delete(self, resource_group_name: str, cluster_name: str, **kwargs: Any) -> AsyncLROPoller[None]: - """Deletes a managed Cassandra cluster. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param cluster_name: Managed Cassandra cluster name. Required. - :type cluster_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, - cluster_name=cluster_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, **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 _create_update_initial( self, resource_group_name: str, @@ -446,10 +345,15 @@ async def _create_update_initial( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) + response_headers = {} + if response.status_code == 201: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @@ -568,7 +472,9 @@ def get_long_running_output(pipeline_response): return deserialized if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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: @@ -643,10 +549,15 @@ async def _update_initial( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @@ -760,7 +671,9 @@ def get_long_running_output(pipeline_response): return deserialized if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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: @@ -776,13 +689,7 @@ def get_long_running_output(pipeline_response): self._client, raw_result, get_long_running_output, polling_method # type: ignore ) - async def _invoke_command_initial( - self, - resource_group_name: str, - cluster_name: str, - body: Union[_models.CommandPostBody, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: + async def _delete_initial(self, resource_group_name: str, cluster_name: str, **kwargs: Any) -> AsyncIterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -791,29 +698,17 @@ async def _invoke_command_initial( } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = case_insensitive_dict(kwargs.pop("headers", {}) 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)) - 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(body, (IOBase, bytes)): - _content = body - else: - _json = self._serialize.body(body, "CommandPostBody") - - _request = build_invoke_command_request( + _request = build_delete_request( resource_group_name=resource_group_name, cluster_name=cluster_name, subscription_id=self._config.subscription_id, api_version=api_version, - content_type=content_type, - json=_json, - content=_content, headers=_headers, params=_params, ) @@ -827,7 +722,7 @@ async def _invoke_command_initial( response = pipeline_response.http_response - if response.status_code not in [202]: + if response.status_code not in [202, 204]: try: await response.read() # Load the body in memory and close the socket except (StreamConsumedError, StreamClosedError): @@ -835,108 +730,44 @@ async def _invoke_command_initial( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore - @overload - async def begin_invoke_command( - self, - resource_group_name: str, - cluster_name: str, - body: _models.CommandPostBody, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.CommandOutput]: - """Invoke a command like nodetool for cassandra maintenance. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param cluster_name: Managed Cassandra cluster name. Required. - :type cluster_name: str - :param body: Specification which command to run where. Required. - :type body: ~azure.mgmt.cosmosdb.models.CommandPostBody - :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 CommandOutput or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.CommandOutput] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_invoke_command( - self, - resource_group_name: str, - cluster_name: str, - body: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.CommandOutput]: - """Invoke a command like nodetool for cassandra maintenance. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param cluster_name: Managed Cassandra cluster name. Required. - :type cluster_name: str - :param body: Specification which command to run where. Required. - :type body: 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 CommandOutput or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.CommandOutput] - :raises ~azure.core.exceptions.HttpResponseError: - """ - @distributed_trace_async - async def begin_invoke_command( - self, - resource_group_name: str, - cluster_name: str, - body: Union[_models.CommandPostBody, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.CommandOutput]: - """Invoke a command like nodetool for cassandra maintenance. + async def begin_delete(self, resource_group_name: str, cluster_name: str, **kwargs: Any) -> AsyncLROPoller[None]: + """Deletes a managed Cassandra cluster. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param cluster_name: Managed Cassandra cluster name. Required. :type cluster_name: str - :param body: Specification which command to run where. Is either a CommandPostBody type or a - IO[bytes] type. Required. - :type body: ~azure.mgmt.cosmosdb.models.CommandPostBody or IO[bytes] - :return: An instance of AsyncLROPoller that returns either CommandOutput or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.CommandOutput] + :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 {}) + _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)) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.CommandOutput] = kwargs.pop("cls", 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._invoke_command_initial( + raw_result = await self._delete_initial( resource_group_name=resource_group_name, cluster_name=cluster_name, - body=body, api_version=api_version, - content_type=content_type, cls=lambda x, y, z: x, headers=_headers, params=_params, @@ -945,254 +776,47 @@ async def begin_invoke_command( await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("CommandOutput", pipeline_response.http_response) + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return cls(pipeline_response, None, {}) # type: ignore if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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.CommandOutput].from_continuation_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[_models.CommandOutput]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _invoke_command_async_initial( - self, - resource_group_name: str, - cluster_name: str, - body: Union[_models.CommandAsyncPostBody, 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(body, (IOBase, bytes)): - _content = body - else: - _json = self._serialize.body(body, "CommandAsyncPostBody") - - _request = build_invoke_command_async_request( - resource_group_name=resource_group_name, - cluster_name=cluster_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["azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("azure-AsyncOperation") - ) - response_headers["location"] = self._deserialize("str", response.headers.get("location")) - - 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_invoke_command_async( - self, - resource_group_name: str, - cluster_name: str, - body: _models.CommandAsyncPostBody, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.CommandPublicResource]: - """Invoke a command like nodetool for cassandra maintenance asynchronously. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param cluster_name: Managed Cassandra cluster name. Required. - :type cluster_name: str - :param body: Specification which command to run where. Required. - :type body: ~azure.mgmt.cosmosdb.models.CommandAsyncPostBody - :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 CommandPublicResource or the result - of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.CommandPublicResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_invoke_command_async( - self, - resource_group_name: str, - cluster_name: str, - body: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.CommandPublicResource]: - """Invoke a command like nodetool for cassandra maintenance asynchronously. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param cluster_name: Managed Cassandra cluster name. Required. - :type cluster_name: str - :param body: Specification which command to run where. Required. - :type body: 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 CommandPublicResource or the result - of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.CommandPublicResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_invoke_command_async( - self, - resource_group_name: str, - cluster_name: str, - body: Union[_models.CommandAsyncPostBody, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.CommandPublicResource]: - """Invoke a command like nodetool for cassandra maintenance asynchronously. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param cluster_name: Managed Cassandra cluster name. Required. - :type cluster_name: str - :param body: Specification which command to run where. Is either a CommandAsyncPostBody type or - a IO[bytes] type. Required. - :type body: ~azure.mgmt.cosmosdb.models.CommandAsyncPostBody or IO[bytes] - :return: An instance of AsyncLROPoller that returns either CommandPublicResource or the result - of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.CommandPublicResource] - :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.CommandPublicResource] = 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._invoke_command_async_initial( - resource_group_name=resource_group_name, - cluster_name=cluster_name, - body=body, - 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("CommandPublicResource", 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, **kwargs)) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[_models.CommandPublicResource].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.CommandPublicResource]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore @distributed_trace - def list_command( + def list_backups( self, resource_group_name: str, cluster_name: str, **kwargs: Any - ) -> AsyncItemPaged["_models.CommandPublicResource"]: - """List all commands currently running on ring info. + ) -> AsyncItemPaged["_models.BackupResource"]: + """List the backups of this cluster that are available to restore. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param cluster_name: Managed Cassandra cluster name. Required. :type cluster_name: str - :return: An iterator like instance of either CommandPublicResource or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.CommandPublicResource] + :return: An iterator like instance of either BackupResource or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.BackupResource] :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.ListCommands] = kwargs.pop("cls", None) + cls: ClsType[_models.ListBackups] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -1205,7 +829,7 @@ def list_command( def prepare_request(next_link=None): if not next_link: - _request = build_list_command_request( + _request = build_list_backups_request( resource_group_name=resource_group_name, cluster_name=cluster_name, subscription_id=self._config.subscription_id, @@ -1233,11 +857,11 @@ def prepare_request(next_link=None): return _request async def extract_data(pipeline_response): - deserialized = self._deserialize("ListCommands", pipeline_response) + deserialized = self._deserialize("ListBackups", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore - return None, AsyncList(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): _request = prepare_request(next_link) @@ -1257,20 +881,20 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) @distributed_trace_async - async def get_command_async( - self, resource_group_name: str, cluster_name: str, command_id: str, **kwargs: Any - ) -> _models.CommandPublicResource: - """Get details about a specified command that was run asynchronously. + async def get_backup( + self, resource_group_name: str, cluster_name: str, backup_id: str, **kwargs: Any + ) -> _models.BackupResource: + """Get the properties of an individual backup of this cluster that is available to restore. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param cluster_name: Managed Cassandra cluster name. Required. :type cluster_name: str - :param command_id: Managed Cassandra cluster command id. Required. - :type command_id: str - :return: CommandPublicResource or the result of cls(response) - :rtype: ~azure.mgmt.cosmosdb.models.CommandPublicResource + :param backup_id: Id of a restorable backup of a Cassandra cluster. Required. + :type backup_id: str + :return: BackupResource or the result of cls(response) + :rtype: ~azure.mgmt.cosmosdb.models.BackupResource :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -1285,12 +909,12 @@ async def get_command_async( _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.CommandPublicResource] = kwargs.pop("cls", None) + cls: ClsType[_models.BackupResource] = kwargs.pop("cls", None) - _request = build_get_command_async_request( + _request = build_get_backup_request( resource_group_name=resource_group_name, cluster_name=cluster_name, - command_id=command_id, + backup_id=backup_id, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, @@ -1309,7 +933,7 @@ async def get_command_async( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("CommandPublicResource", pipeline_response.http_response) + deserialized = self._deserialize("BackupResource", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -1317,25 +941,27 @@ async def get_command_async( return deserialized # type: ignore @distributed_trace - def list_backups( + def list_command( self, resource_group_name: str, cluster_name: str, **kwargs: Any - ) -> AsyncItemPaged["_models.BackupResource"]: - """List the backups of this cluster that are available to restore. + ) -> AsyncItemPaged["_models.CommandPublicResource"]: + """List all commands currently running on ring info. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param cluster_name: Managed Cassandra cluster name. Required. :type cluster_name: str - :return: An iterator like instance of either BackupResource or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.BackupResource] + :return: An iterator like instance of either CommandPublicResource or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.CommandPublicResource] :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.ListBackups] = kwargs.pop("cls", None) + cls: ClsType[_models.ListCommands] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -1348,7 +974,7 @@ def list_backups( def prepare_request(next_link=None): if not next_link: - _request = build_list_backups_request( + _request = build_list_command_request( resource_group_name=resource_group_name, cluster_name=cluster_name, subscription_id=self._config.subscription_id, @@ -1376,11 +1002,11 @@ def prepare_request(next_link=None): return _request async def extract_data(pipeline_response): - deserialized = self._deserialize("ListBackups", pipeline_response) + deserialized = self._deserialize("ListCommands", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore - return None, AsyncList(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): _request = prepare_request(next_link) @@ -1400,23 +1026,23 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) @distributed_trace_async - async def get_backup( - self, resource_group_name: str, cluster_name: str, backup_id: str, **kwargs: Any - ) -> _models.BackupResource: - """Get the properties of an individual backup of this cluster that is available to restore. + async def get_command_async( + self, resource_group_name: str, cluster_name: str, command_id: str, **kwargs: Any + ) -> _models.CommandPublicResource: + """Get details about a specified command that was run asynchronously. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param cluster_name: Managed Cassandra cluster name. Required. :type cluster_name: str - :param backup_id: Id of a restorable backup of a Cassandra cluster. Required. - :type backup_id: str - :return: BackupResource or the result of cls(response) - :rtype: ~azure.mgmt.cosmosdb.models.BackupResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { + :param command_id: Managed Cassandra cluster command id. Required. + :type command_id: str + :return: CommandPublicResource or the result of cls(response) + :rtype: ~azure.mgmt.cosmosdb.models.CommandPublicResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1428,12 +1054,12 @@ async def get_backup( _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.BackupResource] = kwargs.pop("cls", None) + cls: ClsType[_models.CommandPublicResource] = kwargs.pop("cls", None) - _request = build_get_backup_request( + _request = build_get_command_async_request( resource_group_name=resource_group_name, cluster_name=cluster_name, - backup_id=backup_id, + command_id=command_id, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, @@ -1452,7 +1078,7 @@ async def get_backup( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("BackupResource", pipeline_response.http_response) + deserialized = self._deserialize("CommandPublicResource", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -1503,10 +1129,14 @@ async def _deallocate_initial( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) + response_headers = {} + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @@ -1558,7 +1188,9 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- return cls(pipeline_response, None, {}) # type: ignore if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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: @@ -1572,6 +1204,411 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- ) return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + async def _invoke_command_initial( + self, + resource_group_name: str, + cluster_name: str, + body: Union[_models.CommandPostBody, 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(body, (IOBase, bytes)): + _content = body + else: + _json = self._serialize.body(body, "CommandPostBody") + + _request = build_invoke_command_request( + resource_group_name=resource_group_name, + cluster_name=cluster_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + 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_invoke_command( + self, + resource_group_name: str, + cluster_name: str, + body: _models.CommandPostBody, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.CommandOutput]: + """Invoke a command like nodetool for cassandra maintenance. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_name: Managed Cassandra cluster name. Required. + :type cluster_name: str + :param body: Specification which command to run where. Required. + :type body: ~azure.mgmt.cosmosdb.models.CommandPostBody + :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 CommandOutput or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.CommandOutput] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_invoke_command( + self, + resource_group_name: str, + cluster_name: str, + body: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.CommandOutput]: + """Invoke a command like nodetool for cassandra maintenance. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_name: Managed Cassandra cluster name. Required. + :type cluster_name: str + :param body: Specification which command to run where. Required. + :type body: 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 CommandOutput or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.CommandOutput] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_invoke_command( + self, + resource_group_name: str, + cluster_name: str, + body: Union[_models.CommandPostBody, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.CommandOutput]: + """Invoke a command like nodetool for cassandra maintenance. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_name: Managed Cassandra cluster name. Required. + :type cluster_name: str + :param body: Specification which command to run where. Is either a CommandPostBody type or a + IO[bytes] type. Required. + :type body: ~azure.mgmt.cosmosdb.models.CommandPostBody or IO[bytes] + :return: An instance of AsyncLROPoller that returns either CommandOutput or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.CommandOutput] + :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.CommandOutput] = 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._invoke_command_initial( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + body=body, + 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("CommandOutput", 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": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.CommandOutput].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.CommandOutput]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + async def _invoke_command_async_initial( + self, + resource_group_name: str, + cluster_name: str, + body: Union[_models.CommandAsyncPostBody, 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(body, (IOBase, bytes)): + _content = body + else: + _json = self._serialize.body(body, "CommandAsyncPostBody") + + _request = build_invoke_command_async_request( + resource_group_name=resource_group_name, + cluster_name=cluster_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["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.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_invoke_command_async( + self, + resource_group_name: str, + cluster_name: str, + body: _models.CommandAsyncPostBody, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.CommandPublicResource]: + """Invoke a command like nodetool for cassandra maintenance asynchronously. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_name: Managed Cassandra cluster name. Required. + :type cluster_name: str + :param body: Specification which command to run where. Required. + :type body: ~azure.mgmt.cosmosdb.models.CommandAsyncPostBody + :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 CommandPublicResource or the result + of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.CommandPublicResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_invoke_command_async( + self, + resource_group_name: str, + cluster_name: str, + body: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.CommandPublicResource]: + """Invoke a command like nodetool for cassandra maintenance asynchronously. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_name: Managed Cassandra cluster name. Required. + :type cluster_name: str + :param body: Specification which command to run where. Required. + :type body: 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 CommandPublicResource or the result + of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.CommandPublicResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_invoke_command_async( + self, + resource_group_name: str, + cluster_name: str, + body: Union[_models.CommandAsyncPostBody, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.CommandPublicResource]: + """Invoke a command like nodetool for cassandra maintenance asynchronously. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_name: Managed Cassandra cluster name. Required. + :type cluster_name: str + :param body: Specification which command to run where. Is either a CommandAsyncPostBody type or + a IO[bytes] type. Required. + :type body: ~azure.mgmt.cosmosdb.models.CommandAsyncPostBody or IO[bytes] + :return: An instance of AsyncLROPoller that returns either CommandPublicResource or the result + of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.CommandPublicResource] + :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.CommandPublicResource] = 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._invoke_command_async_initial( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + body=body, + 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("CommandPublicResource", 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": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.CommandPublicResource].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.CommandPublicResource]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + async def _start_initial(self, resource_group_name: str, cluster_name: str, **kwargs: Any) -> AsyncIterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -1613,10 +1650,14 @@ async def _start_initial(self, resource_group_name: str, cluster_name: str, **kw map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) + response_headers = {} + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @@ -1661,7 +1702,9 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- return cls(pipeline_response, None, {}) # type: ignore if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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: diff --git a/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/aio/operations/_cassandra_data_centers_operations.py b/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/aio/operations/_cassandra_data_centers_operations.py index e8bee4f25f2..f31873f7610 100644 --- a/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/aio/operations/_cassandra_data_centers_operations.py +++ b/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/aio/operations/_cassandra_data_centers_operations.py @@ -130,7 +130,7 @@ async def extract_data(pipeline_response): list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore - return None, AsyncList(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): _request = prepare_request(next_link) @@ -209,115 +209,6 @@ async def get( return deserialized # type: ignore - async def _delete_initial( - self, resource_group_name: str, cluster_name: str, data_center_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, - cluster_name=cluster_name, - data_center_name=data_center_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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def begin_delete( - self, resource_group_name: str, cluster_name: str, data_center_name: str, **kwargs: Any - ) -> AsyncLROPoller[None]: - """Delete a managed Cassandra data center. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param cluster_name: Managed Cassandra cluster name. Required. - :type cluster_name: str - :param data_center_name: Data center name in a managed Cassandra cluster. Required. - :type data_center_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, - cluster_name=cluster_name, - data_center_name=data_center_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, **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 _create_update_initial( self, resource_group_name: str, @@ -379,10 +270,15 @@ async def _create_update_initial( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) + response_headers = {} + if response.status_code == 201: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @@ -509,7 +405,9 @@ def get_long_running_output(pipeline_response): return deserialized if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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: @@ -586,10 +484,15 @@ async def _update_initial( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @@ -713,7 +616,9 @@ def get_long_running_output(pipeline_response): return deserialized if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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: @@ -728,3 +633,119 @@ def get_long_running_output(pipeline_response): return AsyncLROPoller[_models.DataCenterResource]( self._client, raw_result, get_long_running_output, polling_method # type: ignore ) + + async def _delete_initial( + self, resource_group_name: str, cluster_name: str, data_center_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, + cluster_name=cluster_name, + data_center_name=data_center_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + 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, cluster_name: str, data_center_name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Delete a managed Cassandra data center. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_name: Managed Cassandra cluster name. Required. + :type cluster_name: str + :param data_center_name: Data center name in a managed Cassandra cluster. Required. + :type data_center_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, + cluster_name=cluster_name, + data_center_name=data_center_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/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/aio/operations/_cassandra_resources_operations.py b/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/aio/operations/_cassandra_resources_operations.py index 5b7916f8974..65ae0db63c2 100644 --- a/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/aio/operations/_cassandra_resources_operations.py +++ b/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/aio/operations/_cassandra_resources_operations.py @@ -94,22 +94,111 @@ def __init__(self, *args, **kwargs) -> None: 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_cassandra_keyspaces( + self, resource_group_name: str, account_name: str, **kwargs: Any + ) -> AsyncItemPaged["_models.CassandraKeyspaceGetResults"]: + """Lists the Cassandra keyspaces under an existing Azure Cosmos DB database account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :return: An iterator like instance of either CassandraKeyspaceGetResults or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.CassandraKeyspaceGetResults] + :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.CassandraKeyspaceListResult] = 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_cassandra_keyspaces_request( + resource_group_name=resource_group_name, + account_name=account_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("CassandraKeyspaceListResult", 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_cassandra_role_definition( - self, resource_group_name: str, account_name: str, role_definition_id: str, **kwargs: Any - ) -> _models.CassandraRoleDefinitionResource: - """Retrieves the properties of an existing Azure Cosmos DB Cassandra Role Definition with the - given Id. + async def get_cassandra_keyspace( + self, resource_group_name: str, account_name: str, keyspace_name: str, **kwargs: Any + ) -> _models.CassandraKeyspaceGetResults: + """Gets the Cassandra keyspaces under an existing Azure Cosmos DB database account with the + provided name. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param role_definition_id: The GUID for the Role Definition. Required. - :type role_definition_id: str - :return: CassandraRoleDefinitionResource or the result of cls(response) - :rtype: ~azure.mgmt.cosmosdb.models.CassandraRoleDefinitionResource + :param keyspace_name: Cosmos DB keyspace name. Required. + :type keyspace_name: str + :return: CassandraKeyspaceGetResults or the result of cls(response) + :rtype: ~azure.mgmt.cosmosdb.models.CassandraKeyspaceGetResults :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -124,12 +213,12 @@ async def get_cassandra_role_definition( _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.CassandraRoleDefinitionResource] = kwargs.pop("cls", None) + cls: ClsType[_models.CassandraKeyspaceGetResults] = kwargs.pop("cls", None) - _request = build_get_cassandra_role_definition_request( + _request = build_get_cassandra_keyspace_request( resource_group_name=resource_group_name, account_name=account_name, - role_definition_id=role_definition_id, + keyspace_name=keyspace_name, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, @@ -152,19 +241,19 @@ async def get_cassandra_role_definition( ) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("CassandraRoleDefinitionResource", pipeline_response.http_response) + deserialized = self._deserialize("CassandraKeyspaceGetResults", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - async def _create_update_cassandra_role_definition_initial( # pylint: disable=name-too-long + async def _create_update_cassandra_keyspace_initial( # pylint: disable=name-too-long self, resource_group_name: str, account_name: str, - role_definition_id: str, - create_update_cassandra_role_definition_parameters: Union[_models.CassandraRoleDefinitionResource, IO[bytes]], + keyspace_name: str, + create_update_cassandra_keyspace_parameters: Union[_models.CassandraKeyspaceCreateUpdateParameters, IO[bytes]], **kwargs: Any ) -> AsyncIterator[bytes]: error_map: MutableMapping = { @@ -185,17 +274,17 @@ async def _create_update_cassandra_role_definition_initial( # pylint: disable=n content_type = content_type or "application/json" _json = None _content = None - if isinstance(create_update_cassandra_role_definition_parameters, (IOBase, bytes)): - _content = create_update_cassandra_role_definition_parameters + if isinstance(create_update_cassandra_keyspace_parameters, (IOBase, bytes)): + _content = create_update_cassandra_keyspace_parameters else: _json = self._serialize.body( - create_update_cassandra_role_definition_parameters, "CassandraRoleDefinitionResource" + create_update_cassandra_keyspace_parameters, "CassandraKeyspaceCreateUpdateParameters" ) - _request = build_create_update_cassandra_role_definition_request( + _request = build_create_update_cassandra_keyspace_request( resource_group_name=resource_group_name, account_name=account_name, - role_definition_id=role_definition_id, + keyspace_name=keyspace_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, @@ -228,10 +317,11 @@ async def _create_update_cassandra_role_definition_initial( # pylint: disable=n response_headers = {} if response.status_code == 202: - response_headers["azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("azure-AsyncOperation") + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") ) - response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) @@ -241,99 +331,99 @@ async def _create_update_cassandra_role_definition_initial( # pylint: disable=n return deserialized # type: ignore @overload - async def begin_create_update_cassandra_role_definition( # pylint: disable=name-too-long + async def begin_create_update_cassandra_keyspace( self, resource_group_name: str, account_name: str, - role_definition_id: str, - create_update_cassandra_role_definition_parameters: _models.CassandraRoleDefinitionResource, + keyspace_name: str, + create_update_cassandra_keyspace_parameters: _models.CassandraKeyspaceCreateUpdateParameters, *, content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller[_models.CassandraRoleDefinitionResource]: - """Creates or updates an Azure Cosmos DB Cassandra Role Definition. + ) -> AsyncLROPoller[_models.CassandraKeyspaceGetResults]: + """Create or update an Azure Cosmos DB Cassandra keyspace. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param role_definition_id: The GUID for the Role Definition. Required. - :type role_definition_id: str - :param create_update_cassandra_role_definition_parameters: The properties required to create or - update a Role Definition. Required. - :type create_update_cassandra_role_definition_parameters: - ~azure.mgmt.cosmosdb.models.CassandraRoleDefinitionResource + :param keyspace_name: Cosmos DB keyspace name. Required. + :type keyspace_name: str + :param create_update_cassandra_keyspace_parameters: The parameters to provide for the current + Cassandra keyspace. Required. + :type create_update_cassandra_keyspace_parameters: + ~azure.mgmt.cosmosdb.models.CassandraKeyspaceCreateUpdateParameters :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 CassandraRoleDefinitionResource or - the result of cls(response) + :return: An instance of AsyncLROPoller that returns either CassandraKeyspaceGetResults or the + result of cls(response) :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.CassandraRoleDefinitionResource] + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.CassandraKeyspaceGetResults] :raises ~azure.core.exceptions.HttpResponseError: """ @overload - async def begin_create_update_cassandra_role_definition( # pylint: disable=name-too-long + async def begin_create_update_cassandra_keyspace( self, resource_group_name: str, account_name: str, - role_definition_id: str, - create_update_cassandra_role_definition_parameters: IO[bytes], + keyspace_name: str, + create_update_cassandra_keyspace_parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller[_models.CassandraRoleDefinitionResource]: - """Creates or updates an Azure Cosmos DB Cassandra Role Definition. + ) -> AsyncLROPoller[_models.CassandraKeyspaceGetResults]: + """Create or update an Azure Cosmos DB Cassandra keyspace. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param role_definition_id: The GUID for the Role Definition. Required. - :type role_definition_id: str - :param create_update_cassandra_role_definition_parameters: The properties required to create or - update a Role Definition. Required. - :type create_update_cassandra_role_definition_parameters: IO[bytes] + :param keyspace_name: Cosmos DB keyspace name. Required. + :type keyspace_name: str + :param create_update_cassandra_keyspace_parameters: The parameters to provide for the current + Cassandra keyspace. Required. + :type create_update_cassandra_keyspace_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 CassandraRoleDefinitionResource or - the result of cls(response) + :return: An instance of AsyncLROPoller that returns either CassandraKeyspaceGetResults or the + result of cls(response) :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.CassandraRoleDefinitionResource] + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.CassandraKeyspaceGetResults] :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace_async - async def begin_create_update_cassandra_role_definition( # pylint: disable=name-too-long + async def begin_create_update_cassandra_keyspace( self, resource_group_name: str, account_name: str, - role_definition_id: str, - create_update_cassandra_role_definition_parameters: Union[_models.CassandraRoleDefinitionResource, IO[bytes]], + keyspace_name: str, + create_update_cassandra_keyspace_parameters: Union[_models.CassandraKeyspaceCreateUpdateParameters, IO[bytes]], **kwargs: Any - ) -> AsyncLROPoller[_models.CassandraRoleDefinitionResource]: - """Creates or updates an Azure Cosmos DB Cassandra Role Definition. + ) -> AsyncLROPoller[_models.CassandraKeyspaceGetResults]: + """Create or update an Azure Cosmos DB Cassandra keyspace. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param role_definition_id: The GUID for the Role Definition. Required. - :type role_definition_id: str - :param create_update_cassandra_role_definition_parameters: The properties required to create or - update a Role Definition. Is either a CassandraRoleDefinitionResource type or a IO[bytes] type. - Required. - :type create_update_cassandra_role_definition_parameters: - ~azure.mgmt.cosmosdb.models.CassandraRoleDefinitionResource or IO[bytes] - :return: An instance of AsyncLROPoller that returns either CassandraRoleDefinitionResource or - the result of cls(response) + :param keyspace_name: Cosmos DB keyspace name. Required. + :type keyspace_name: str + :param create_update_cassandra_keyspace_parameters: The parameters to provide for the current + Cassandra keyspace. Is either a CassandraKeyspaceCreateUpdateParameters type or a IO[bytes] + type. Required. + :type create_update_cassandra_keyspace_parameters: + ~azure.mgmt.cosmosdb.models.CassandraKeyspaceCreateUpdateParameters or IO[bytes] + :return: An instance of AsyncLROPoller that returns either CassandraKeyspaceGetResults or the + result of cls(response) :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.CassandraRoleDefinitionResource] + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.CassandraKeyspaceGetResults] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -341,16 +431,16 @@ async def begin_create_update_cassandra_role_definition( # pylint: disable=name 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.CassandraRoleDefinitionResource] = kwargs.pop("cls", None) + cls: ClsType[_models.CassandraKeyspaceGetResults] = 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_update_cassandra_role_definition_initial( + raw_result = await self._create_update_cassandra_keyspace_initial( resource_group_name=resource_group_name, account_name=account_name, - role_definition_id=role_definition_id, - create_update_cassandra_role_definition_parameters=create_update_cassandra_role_definition_parameters, + keyspace_name=keyspace_name, + create_update_cassandra_keyspace_parameters=create_update_cassandra_keyspace_parameters, api_version=api_version, content_type=content_type, cls=lambda x, y, z: x, @@ -362,30 +452,32 @@ async def begin_create_update_cassandra_role_definition( # pylint: disable=name kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("CassandraRoleDefinitionResource", pipeline_response.http_response) + deserialized = self._deserialize("CassandraKeyspaceGetResults", 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, **kwargs)) + 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.CassandraRoleDefinitionResource].from_continuation_token( + return AsyncLROPoller[_models.CassandraKeyspaceGetResults].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller[_models.CassandraRoleDefinitionResource]( + return AsyncLROPoller[_models.CassandraKeyspaceGetResults]( self._client, raw_result, get_long_running_output, polling_method # type: ignore ) - async def _delete_cassandra_role_definition_initial( # pylint: disable=name-too-long - self, resource_group_name: str, account_name: str, role_definition_id: str, **kwargs: Any + async def _delete_cassandra_keyspace_initial( + self, resource_group_name: str, account_name: str, keyspace_name: str, **kwargs: Any ) -> AsyncIterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -401,10 +493,10 @@ async def _delete_cassandra_role_definition_initial( # pylint: disable=name-too 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_cassandra_role_definition_request( + _request = build_delete_cassandra_keyspace_request( resource_group_name=resource_group_name, account_name=account_name, - role_definition_id=role_definition_id, + keyspace_name=keyspace_name, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, @@ -420,7 +512,7 @@ async def _delete_cassandra_role_definition_initial( # pylint: disable=name-too response = pipeline_response.http_response - if response.status_code not in [200, 202, 204]: + if response.status_code not in [202, 204]: try: await response.read() # Load the body in memory and close the socket except (StreamConsumedError, StreamClosedError): @@ -434,10 +526,10 @@ async def _delete_cassandra_role_definition_initial( # pylint: disable=name-too response_headers = {} if response.status_code == 202: - response_headers["azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("azure-AsyncOperation") + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") ) - response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) @@ -447,18 +539,18 @@ async def _delete_cassandra_role_definition_initial( # pylint: disable=name-too return deserialized # type: ignore @distributed_trace_async - async def begin_delete_cassandra_role_definition( - self, resource_group_name: str, account_name: str, role_definition_id: str, **kwargs: Any + async def begin_delete_cassandra_keyspace( + self, resource_group_name: str, account_name: str, keyspace_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: - """Deletes an existing Azure Cosmos DB Cassandra Role Definition. + """Deletes an existing Azure Cosmos DB Cassandra keyspace. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param role_definition_id: The GUID for the Role Definition. Required. - :type role_definition_id: str + :param keyspace_name: Cosmos DB keyspace name. Required. + :type keyspace_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: @@ -472,10 +564,10 @@ async def begin_delete_cassandra_role_definition( 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_cassandra_role_definition_initial( + raw_result = await self._delete_cassandra_keyspace_initial( resource_group_name=resource_group_name, account_name=account_name, - role_definition_id=role_definition_id, + keyspace_name=keyspace_name, api_version=api_version, cls=lambda x, y, z: x, headers=_headers, @@ -490,7 +582,9 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- return cls(pipeline_response, None, {}) # type: ignore if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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: @@ -505,27 +599,29 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore @distributed_trace - def list_cassandra_role_definitions( - self, resource_group_name: str, account_name: str, **kwargs: Any - ) -> AsyncItemPaged["_models.CassandraRoleDefinitionResource"]: - """Retrieves the list of all Azure Cosmos DB Cassandra Role Definitions. + def list_cassandra_tables( + self, resource_group_name: str, account_name: str, keyspace_name: str, **kwargs: Any + ) -> AsyncItemPaged["_models.CassandraTableGetResults"]: + """Lists the Cassandra table under an existing Azure Cosmos DB database account. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param account_name: Cosmos DB database account name. Required. :type account_name: str - :return: An iterator like instance of either CassandraRoleDefinitionResource or the result of + :param keyspace_name: Cosmos DB keyspace name. Required. + :type keyspace_name: str + :return: An iterator like instance of either CassandraTableGetResults or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.CassandraRoleDefinitionResource] + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.CassandraTableGetResults] :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.CassandraRoleDefinitionListResult] = kwargs.pop("cls", None) + cls: ClsType[_models.CassandraTableListResult] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -538,9 +634,10 @@ def list_cassandra_role_definitions( def prepare_request(next_link=None): if not next_link: - _request = build_list_cassandra_role_definitions_request( + _request = build_list_cassandra_tables_request( resource_group_name=resource_group_name, account_name=account_name, + keyspace_name=keyspace_name, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, @@ -566,11 +663,11 @@ def prepare_request(next_link=None): return _request async def extract_data(pipeline_response): - deserialized = self._deserialize("CassandraRoleDefinitionListResult", pipeline_response) + deserialized = self._deserialize("CassandraTableListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore - return None, AsyncList(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): _request = prepare_request(next_link) @@ -594,21 +691,22 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) @distributed_trace_async - async def get_cassandra_role_assignment( - self, resource_group_name: str, account_name: str, role_assignment_id: str, **kwargs: Any - ) -> _models.CassandraRoleAssignmentResource: - """Retrieves the properties of an existing Azure Cosmos DB Cassandra Role Assignment with the - given Id. + async def get_cassandra_table( + self, resource_group_name: str, account_name: str, keyspace_name: str, table_name: str, **kwargs: Any + ) -> _models.CassandraTableGetResults: + """Gets the Cassandra table under an existing Azure Cosmos DB database account. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param role_assignment_id: The GUID for the Role Assignment. Required. - :type role_assignment_id: str - :return: CassandraRoleAssignmentResource or the result of cls(response) - :rtype: ~azure.mgmt.cosmosdb.models.CassandraRoleAssignmentResource + :param keyspace_name: Cosmos DB keyspace name. Required. + :type keyspace_name: str + :param table_name: Cosmos DB table name. Required. + :type table_name: str + :return: CassandraTableGetResults or the result of cls(response) + :rtype: ~azure.mgmt.cosmosdb.models.CassandraTableGetResults :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -623,12 +721,13 @@ async def get_cassandra_role_assignment( _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.CassandraRoleAssignmentResource] = kwargs.pop("cls", None) + cls: ClsType[_models.CassandraTableGetResults] = kwargs.pop("cls", None) - _request = build_get_cassandra_role_assignment_request( + _request = build_get_cassandra_table_request( resource_group_name=resource_group_name, account_name=account_name, - role_assignment_id=role_assignment_id, + keyspace_name=keyspace_name, + table_name=table_name, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, @@ -651,19 +750,20 @@ async def get_cassandra_role_assignment( ) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("CassandraRoleAssignmentResource", pipeline_response.http_response) + deserialized = self._deserialize("CassandraTableGetResults", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - async def _create_update_cassandra_role_assignment_initial( # pylint: disable=name-too-long + async def _create_update_cassandra_table_initial( self, resource_group_name: str, account_name: str, - role_assignment_id: str, - create_update_cassandra_role_assignment_parameters: Union[_models.CassandraRoleAssignmentResource, IO[bytes]], + keyspace_name: str, + table_name: str, + create_update_cassandra_table_parameters: Union[_models.CassandraTableCreateUpdateParameters, IO[bytes]], **kwargs: Any ) -> AsyncIterator[bytes]: error_map: MutableMapping = { @@ -684,17 +784,18 @@ async def _create_update_cassandra_role_assignment_initial( # pylint: disable=n content_type = content_type or "application/json" _json = None _content = None - if isinstance(create_update_cassandra_role_assignment_parameters, (IOBase, bytes)): - _content = create_update_cassandra_role_assignment_parameters + if isinstance(create_update_cassandra_table_parameters, (IOBase, bytes)): + _content = create_update_cassandra_table_parameters else: _json = self._serialize.body( - create_update_cassandra_role_assignment_parameters, "CassandraRoleAssignmentResource" + create_update_cassandra_table_parameters, "CassandraTableCreateUpdateParameters" ) - _request = build_create_update_cassandra_role_assignment_request( + _request = build_create_update_cassandra_table_request( resource_group_name=resource_group_name, account_name=account_name, - role_assignment_id=role_assignment_id, + keyspace_name=keyspace_name, + table_name=table_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, @@ -727,10 +828,11 @@ async def _create_update_cassandra_role_assignment_initial( # pylint: disable=n response_headers = {} if response.status_code == 202: - response_headers["azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("azure-AsyncOperation") + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") ) - response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) @@ -740,99 +842,108 @@ async def _create_update_cassandra_role_assignment_initial( # pylint: disable=n return deserialized # type: ignore @overload - async def begin_create_update_cassandra_role_assignment( # pylint: disable=name-too-long + async def begin_create_update_cassandra_table( self, resource_group_name: str, account_name: str, - role_assignment_id: str, - create_update_cassandra_role_assignment_parameters: _models.CassandraRoleAssignmentResource, + keyspace_name: str, + table_name: str, + create_update_cassandra_table_parameters: _models.CassandraTableCreateUpdateParameters, *, content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller[_models.CassandraRoleAssignmentResource]: - """Creates or updates an Azure Cosmos DB Cassandra Role Assignment. + ) -> AsyncLROPoller[_models.CassandraTableGetResults]: + """Create or update an Azure Cosmos DB Cassandra Table. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param role_assignment_id: The GUID for the Role Assignment. Required. - :type role_assignment_id: str - :param create_update_cassandra_role_assignment_parameters: The properties required to create or - update a Role Assignment. Required. - :type create_update_cassandra_role_assignment_parameters: - ~azure.mgmt.cosmosdb.models.CassandraRoleAssignmentResource + :param keyspace_name: Cosmos DB keyspace name. Required. + :type keyspace_name: str + :param table_name: Cosmos DB table name. Required. + :type table_name: str + :param create_update_cassandra_table_parameters: The parameters to provide for the current + Cassandra Table. Required. + :type create_update_cassandra_table_parameters: + ~azure.mgmt.cosmosdb.models.CassandraTableCreateUpdateParameters :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 CassandraRoleAssignmentResource or - the result of cls(response) + :return: An instance of AsyncLROPoller that returns either CassandraTableGetResults or the + result of cls(response) :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.CassandraRoleAssignmentResource] + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.CassandraTableGetResults] :raises ~azure.core.exceptions.HttpResponseError: """ @overload - async def begin_create_update_cassandra_role_assignment( # pylint: disable=name-too-long + async def begin_create_update_cassandra_table( self, resource_group_name: str, account_name: str, - role_assignment_id: str, - create_update_cassandra_role_assignment_parameters: IO[bytes], + keyspace_name: str, + table_name: str, + create_update_cassandra_table_parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller[_models.CassandraRoleAssignmentResource]: - """Creates or updates an Azure Cosmos DB Cassandra Role Assignment. + ) -> AsyncLROPoller[_models.CassandraTableGetResults]: + """Create or update an Azure Cosmos DB Cassandra Table. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param role_assignment_id: The GUID for the Role Assignment. Required. - :type role_assignment_id: str - :param create_update_cassandra_role_assignment_parameters: The properties required to create or - update a Role Assignment. Required. - :type create_update_cassandra_role_assignment_parameters: IO[bytes] + :param keyspace_name: Cosmos DB keyspace name. Required. + :type keyspace_name: str + :param table_name: Cosmos DB table name. Required. + :type table_name: str + :param create_update_cassandra_table_parameters: The parameters to provide for the current + Cassandra Table. Required. + :type create_update_cassandra_table_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 CassandraRoleAssignmentResource or - the result of cls(response) + :return: An instance of AsyncLROPoller that returns either CassandraTableGetResults or the + result of cls(response) :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.CassandraRoleAssignmentResource] + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.CassandraTableGetResults] :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace_async - async def begin_create_update_cassandra_role_assignment( # pylint: disable=name-too-long + async def begin_create_update_cassandra_table( self, resource_group_name: str, account_name: str, - role_assignment_id: str, - create_update_cassandra_role_assignment_parameters: Union[_models.CassandraRoleAssignmentResource, IO[bytes]], + keyspace_name: str, + table_name: str, + create_update_cassandra_table_parameters: Union[_models.CassandraTableCreateUpdateParameters, IO[bytes]], **kwargs: Any - ) -> AsyncLROPoller[_models.CassandraRoleAssignmentResource]: - """Creates or updates an Azure Cosmos DB Cassandra Role Assignment. + ) -> AsyncLROPoller[_models.CassandraTableGetResults]: + """Create or update an Azure Cosmos DB Cassandra Table. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param role_assignment_id: The GUID for the Role Assignment. Required. - :type role_assignment_id: str - :param create_update_cassandra_role_assignment_parameters: The properties required to create or - update a Role Assignment. Is either a CassandraRoleAssignmentResource type or a IO[bytes] type. + :param keyspace_name: Cosmos DB keyspace name. Required. + :type keyspace_name: str + :param table_name: Cosmos DB table name. Required. + :type table_name: str + :param create_update_cassandra_table_parameters: The parameters to provide for the current + Cassandra Table. Is either a CassandraTableCreateUpdateParameters type or a IO[bytes] type. Required. - :type create_update_cassandra_role_assignment_parameters: - ~azure.mgmt.cosmosdb.models.CassandraRoleAssignmentResource or IO[bytes] - :return: An instance of AsyncLROPoller that returns either CassandraRoleAssignmentResource or - the result of cls(response) + :type create_update_cassandra_table_parameters: + ~azure.mgmt.cosmosdb.models.CassandraTableCreateUpdateParameters or IO[bytes] + :return: An instance of AsyncLROPoller that returns either CassandraTableGetResults or the + result of cls(response) :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.CassandraRoleAssignmentResource] + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.CassandraTableGetResults] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -840,16 +951,17 @@ async def begin_create_update_cassandra_role_assignment( # pylint: disable=name 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.CassandraRoleAssignmentResource] = kwargs.pop("cls", None) + cls: ClsType[_models.CassandraTableGetResults] = 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_update_cassandra_role_assignment_initial( + raw_result = await self._create_update_cassandra_table_initial( resource_group_name=resource_group_name, account_name=account_name, - role_assignment_id=role_assignment_id, - create_update_cassandra_role_assignment_parameters=create_update_cassandra_role_assignment_parameters, + keyspace_name=keyspace_name, + table_name=table_name, + create_update_cassandra_table_parameters=create_update_cassandra_table_parameters, api_version=api_version, content_type=content_type, cls=lambda x, y, z: x, @@ -861,30 +973,32 @@ async def begin_create_update_cassandra_role_assignment( # pylint: disable=name kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("CassandraRoleAssignmentResource", pipeline_response.http_response) + deserialized = self._deserialize("CassandraTableGetResults", 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, **kwargs)) + 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.CassandraRoleAssignmentResource].from_continuation_token( + return AsyncLROPoller[_models.CassandraTableGetResults].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller[_models.CassandraRoleAssignmentResource]( + return AsyncLROPoller[_models.CassandraTableGetResults]( self._client, raw_result, get_long_running_output, polling_method # type: ignore ) - async def _delete_cassandra_role_assignment_initial( # pylint: disable=name-too-long - self, resource_group_name: str, account_name: str, role_assignment_id: str, **kwargs: Any + async def _delete_cassandra_table_initial( + self, resource_group_name: str, account_name: str, keyspace_name: str, table_name: str, **kwargs: Any ) -> AsyncIterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -900,10 +1014,11 @@ async def _delete_cassandra_role_assignment_initial( # pylint: disable=name-too 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_cassandra_role_assignment_request( + _request = build_delete_cassandra_table_request( resource_group_name=resource_group_name, account_name=account_name, - role_assignment_id=role_assignment_id, + keyspace_name=keyspace_name, + table_name=table_name, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, @@ -919,7 +1034,7 @@ async def _delete_cassandra_role_assignment_initial( # pylint: disable=name-too response = pipeline_response.http_response - if response.status_code not in [200, 202, 204]: + if response.status_code not in [202, 204]: try: await response.read() # Load the body in memory and close the socket except (StreamConsumedError, StreamClosedError): @@ -933,10 +1048,10 @@ async def _delete_cassandra_role_assignment_initial( # pylint: disable=name-too response_headers = {} if response.status_code == 202: - response_headers["azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("azure-AsyncOperation") + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") ) - response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) @@ -946,18 +1061,20 @@ async def _delete_cassandra_role_assignment_initial( # pylint: disable=name-too return deserialized # type: ignore @distributed_trace_async - async def begin_delete_cassandra_role_assignment( - self, resource_group_name: str, account_name: str, role_assignment_id: str, **kwargs: Any + async def begin_delete_cassandra_table( + self, resource_group_name: str, account_name: str, keyspace_name: str, table_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: - """Deletes an existing Azure Cosmos DB Cassandra Role Assignment. + """Deletes an existing Azure Cosmos DB Cassandra table. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param role_assignment_id: The GUID for the Role Assignment. Required. - :type role_assignment_id: str + :param keyspace_name: Cosmos DB keyspace name. Required. + :type keyspace_name: str + :param table_name: Cosmos DB table name. Required. + :type table_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: @@ -971,10 +1088,11 @@ async def begin_delete_cassandra_role_assignment( 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_cassandra_role_assignment_initial( + raw_result = await self._delete_cassandra_table_initial( resource_group_name=resource_group_name, account_name=account_name, - role_assignment_id=role_assignment_id, + keyspace_name=keyspace_name, + table_name=table_name, api_version=api_version, cls=lambda x, y, z: x, headers=_headers, @@ -989,7 +1107,9 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- return cls(pipeline_response, None, {}) # type: ignore if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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: @@ -1003,29 +1123,26 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- ) return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - @distributed_trace - def list_cassandra_role_assignments( - self, resource_group_name: str, account_name: str, **kwargs: Any - ) -> AsyncItemPaged["_models.CassandraRoleAssignmentResource"]: - """Retrieves the list of all Azure Cosmos DB Cassandra Role Assignments. + @distributed_trace_async + async def get_cassandra_table_throughput( + self, resource_group_name: str, account_name: str, keyspace_name: str, table_name: str, **kwargs: Any + ) -> _models.ThroughputSettingsGetResults: + """Gets the RUs per second of the Cassandra table under an existing Azure Cosmos DB database + account with the provided name. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param account_name: Cosmos DB database account name. Required. :type account_name: str - :return: An iterator like instance of either CassandraRoleAssignmentResource or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.CassandraRoleAssignmentResource] + :param keyspace_name: Cosmos DB keyspace name. Required. + :type keyspace_name: str + :param table_name: Cosmos DB table name. Required. + :type table_name: str + :return: ThroughputSettingsGetResults or the result of cls(response) + :rtype: ~azure.mgmt.cosmosdb.models.ThroughputSettingsGetResults :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.CassandraRoleAssignmentListResult] = kwargs.pop("cls", None) - error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -1034,185 +1151,17 @@ def list_cassandra_role_assignments( } error_map.update(kwargs.pop("error_map", {}) or {}) - def prepare_request(next_link=None): - if not next_link: + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _request = build_list_cassandra_role_assignments_request( - resource_group_name=resource_group_name, - account_name=account_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.ThroughputSettingsGetResults] = kwargs.pop("cls", None) - 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("CassandraRoleAssignmentListResult", 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) - - @distributed_trace - def list_cassandra_keyspaces( - self, resource_group_name: str, account_name: str, **kwargs: Any - ) -> AsyncItemPaged["_models.CassandraKeyspaceGetResults"]: - """Lists the Cassandra keyspaces under an existing Azure Cosmos DB database account. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param account_name: Cosmos DB database account name. Required. - :type account_name: str - :return: An iterator like instance of either CassandraKeyspaceGetResults or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.CassandraKeyspaceGetResults] - :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.CassandraKeyspaceListResult] = 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_cassandra_keyspaces_request( - resource_group_name=resource_group_name, - account_name=account_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("CassandraKeyspaceListResult", 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace_async - async def get_cassandra_keyspace( - self, resource_group_name: str, account_name: str, keyspace_name: str, **kwargs: Any - ) -> _models.CassandraKeyspaceGetResults: - """Gets the Cassandra keyspaces under an existing Azure Cosmos DB database account with the - provided name. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param account_name: Cosmos DB database account name. Required. - :type account_name: str - :param keyspace_name: Cosmos DB keyspace name. Required. - :type keyspace_name: str - :return: CassandraKeyspaceGetResults or the result of cls(response) - :rtype: ~azure.mgmt.cosmosdb.models.CassandraKeyspaceGetResults - :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.CassandraKeyspaceGetResults] = kwargs.pop("cls", None) - - _request = build_get_cassandra_keyspace_request( + _request = build_get_cassandra_table_throughput_request( resource_group_name=resource_group_name, account_name=account_name, keyspace_name=keyspace_name, + table_name=table_name, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, @@ -1229,21 +1178,26 @@ async def get_cassandra_keyspace( if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("CassandraKeyspaceGetResults", pipeline_response.http_response) + deserialized = self._deserialize("ThroughputSettingsGetResults", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - async def _create_update_cassandra_keyspace_initial( # pylint: disable=name-too-long + async def _update_cassandra_table_throughput_initial( # pylint: disable=name-too-long self, resource_group_name: str, account_name: str, keyspace_name: str, - create_update_cassandra_keyspace_parameters: Union[_models.CassandraKeyspaceCreateUpdateParameters, IO[bytes]], + table_name: str, + update_throughput_parameters: Union[_models.ThroughputSettingsUpdateParameters, IO[bytes]], **kwargs: Any ) -> AsyncIterator[bytes]: error_map: MutableMapping = { @@ -1264,17 +1218,16 @@ async def _create_update_cassandra_keyspace_initial( # pylint: disable=name-too content_type = content_type or "application/json" _json = None _content = None - if isinstance(create_update_cassandra_keyspace_parameters, (IOBase, bytes)): - _content = create_update_cassandra_keyspace_parameters + if isinstance(update_throughput_parameters, (IOBase, bytes)): + _content = update_throughput_parameters else: - _json = self._serialize.body( - create_update_cassandra_keyspace_parameters, "CassandraKeyspaceCreateUpdateParameters" - ) + _json = self._serialize.body(update_throughput_parameters, "ThroughputSettingsUpdateParameters") - _request = build_create_update_cassandra_keyspace_request( + _request = build_update_cassandra_table_throughput_request( resource_group_name=resource_group_name, account_name=account_name, keyspace_name=keyspace_name, + table_name=table_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, @@ -1299,14 +1252,19 @@ async def _create_update_cassandra_keyspace_initial( # pylint: disable=name-too except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + 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["azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("azure-AsyncOperation") + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") ) - response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) @@ -1316,17 +1274,18 @@ async def _create_update_cassandra_keyspace_initial( # pylint: disable=name-too return deserialized # type: ignore @overload - async def begin_create_update_cassandra_keyspace( + async def begin_update_cassandra_table_throughput( self, resource_group_name: str, account_name: str, keyspace_name: str, - create_update_cassandra_keyspace_parameters: _models.CassandraKeyspaceCreateUpdateParameters, + table_name: str, + update_throughput_parameters: _models.ThroughputSettingsUpdateParameters, *, content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller[_models.CassandraKeyspaceGetResults]: - """Create or update an Azure Cosmos DB Cassandra keyspace. + ) -> AsyncLROPoller[_models.ThroughputSettingsGetResults]: + """Update RUs per second of an Azure Cosmos DB Cassandra table. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -1335,32 +1294,35 @@ async def begin_create_update_cassandra_keyspace( :type account_name: str :param keyspace_name: Cosmos DB keyspace name. Required. :type keyspace_name: str - :param create_update_cassandra_keyspace_parameters: The parameters to provide for the current - Cassandra keyspace. Required. - :type create_update_cassandra_keyspace_parameters: - ~azure.mgmt.cosmosdb.models.CassandraKeyspaceCreateUpdateParameters + :param table_name: Cosmos DB table name. Required. + :type table_name: str + :param update_throughput_parameters: The RUs per second of the parameters to provide for the + current Cassandra table. Required. + :type update_throughput_parameters: + ~azure.mgmt.cosmosdb.models.ThroughputSettingsUpdateParameters :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 CassandraKeyspaceGetResults or the + :return: An instance of AsyncLROPoller that returns either ThroughputSettingsGetResults or the result of cls(response) :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.CassandraKeyspaceGetResults] + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.ThroughputSettingsGetResults] :raises ~azure.core.exceptions.HttpResponseError: """ @overload - async def begin_create_update_cassandra_keyspace( + async def begin_update_cassandra_table_throughput( self, resource_group_name: str, account_name: str, keyspace_name: str, - create_update_cassandra_keyspace_parameters: IO[bytes], + table_name: str, + update_throughput_parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller[_models.CassandraKeyspaceGetResults]: - """Create or update an Azure Cosmos DB Cassandra keyspace. + ) -> AsyncLROPoller[_models.ThroughputSettingsGetResults]: + """Update RUs per second of an Azure Cosmos DB Cassandra table. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -1369,29 +1331,32 @@ async def begin_create_update_cassandra_keyspace( :type account_name: str :param keyspace_name: Cosmos DB keyspace name. Required. :type keyspace_name: str - :param create_update_cassandra_keyspace_parameters: The parameters to provide for the current - Cassandra keyspace. Required. - :type create_update_cassandra_keyspace_parameters: IO[bytes] + :param table_name: Cosmos DB table name. Required. + :type table_name: str + :param update_throughput_parameters: The RUs per second of the parameters to provide for the + current Cassandra table. Required. + :type update_throughput_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 CassandraKeyspaceGetResults or the + :return: An instance of AsyncLROPoller that returns either ThroughputSettingsGetResults or the result of cls(response) :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.CassandraKeyspaceGetResults] + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.ThroughputSettingsGetResults] :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace_async - async def begin_create_update_cassandra_keyspace( + async def begin_update_cassandra_table_throughput( self, resource_group_name: str, account_name: str, keyspace_name: str, - create_update_cassandra_keyspace_parameters: Union[_models.CassandraKeyspaceCreateUpdateParameters, IO[bytes]], + table_name: str, + update_throughput_parameters: Union[_models.ThroughputSettingsUpdateParameters, IO[bytes]], **kwargs: Any - ) -> AsyncLROPoller[_models.CassandraKeyspaceGetResults]: - """Create or update an Azure Cosmos DB Cassandra keyspace. + ) -> AsyncLROPoller[_models.ThroughputSettingsGetResults]: + """Update RUs per second of an Azure Cosmos DB Cassandra table. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -1400,15 +1365,17 @@ async def begin_create_update_cassandra_keyspace( :type account_name: str :param keyspace_name: Cosmos DB keyspace name. Required. :type keyspace_name: str - :param create_update_cassandra_keyspace_parameters: The parameters to provide for the current - Cassandra keyspace. Is either a CassandraKeyspaceCreateUpdateParameters type or a IO[bytes] + :param table_name: Cosmos DB table name. Required. + :type table_name: str + :param update_throughput_parameters: The RUs per second of the parameters to provide for the + current Cassandra table. Is either a ThroughputSettingsUpdateParameters type or a IO[bytes] type. Required. - :type create_update_cassandra_keyspace_parameters: - ~azure.mgmt.cosmosdb.models.CassandraKeyspaceCreateUpdateParameters or IO[bytes] - :return: An instance of AsyncLROPoller that returns either CassandraKeyspaceGetResults or the + :type update_throughput_parameters: + ~azure.mgmt.cosmosdb.models.ThroughputSettingsUpdateParameters or IO[bytes] + :return: An instance of AsyncLROPoller that returns either ThroughputSettingsGetResults or the result of cls(response) :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.CassandraKeyspaceGetResults] + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.ThroughputSettingsGetResults] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -1416,16 +1383,17 @@ async def begin_create_update_cassandra_keyspace( 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.CassandraKeyspaceGetResults] = kwargs.pop("cls", None) + cls: ClsType[_models.ThroughputSettingsGetResults] = 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_update_cassandra_keyspace_initial( + raw_result = await self._update_cassandra_table_throughput_initial( resource_group_name=resource_group_name, account_name=account_name, keyspace_name=keyspace_name, - create_update_cassandra_keyspace_parameters=create_update_cassandra_keyspace_parameters, + table_name=table_name, + update_throughput_parameters=update_throughput_parameters, api_version=api_version, content_type=content_type, cls=lambda x, y, z: x, @@ -1437,30 +1405,32 @@ async def begin_create_update_cassandra_keyspace( kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("CassandraKeyspaceGetResults", pipeline_response.http_response) + deserialized = self._deserialize("ThroughputSettingsGetResults", 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, **kwargs)) + 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.CassandraKeyspaceGetResults].from_continuation_token( + return AsyncLROPoller[_models.ThroughputSettingsGetResults].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller[_models.CassandraKeyspaceGetResults]( + return AsyncLROPoller[_models.ThroughputSettingsGetResults]( self._client, raw_result, get_long_running_output, polling_method # type: ignore ) - async def _delete_cassandra_keyspace_initial( - self, resource_group_name: str, account_name: str, keyspace_name: str, **kwargs: Any + async def _migrate_cassandra_table_to_autoscale_initial( # pylint: disable=name-too-long + self, resource_group_name: str, account_name: str, keyspace_name: str, table_name: str, **kwargs: Any ) -> AsyncIterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -1476,10 +1446,11 @@ async def _delete_cassandra_keyspace_initial( 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_cassandra_keyspace_request( + _request = build_migrate_cassandra_table_to_autoscale_request( resource_group_name=resource_group_name, account_name=account_name, keyspace_name=keyspace_name, + table_name=table_name, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, @@ -1495,7 +1466,7 @@ async def _delete_cassandra_keyspace_initial( response = pipeline_response.http_response - if response.status_code not in [202, 204]: + if response.status_code not in [200, 202]: try: await response.read() # Load the body in memory and close the socket except (StreamConsumedError, StreamClosedError): @@ -1505,10 +1476,11 @@ async def _delete_cassandra_keyspace_initial( response_headers = {} if response.status_code == 202: - response_headers["azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("azure-AsyncOperation") + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") ) - response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) @@ -1518,10 +1490,10 @@ async def _delete_cassandra_keyspace_initial( return deserialized # type: ignore @distributed_trace_async - async def begin_delete_cassandra_keyspace( - self, resource_group_name: str, account_name: str, keyspace_name: str, **kwargs: Any - ) -> AsyncLROPoller[None]: - """Deletes an existing Azure Cosmos DB Cassandra keyspace. + async def begin_migrate_cassandra_table_to_autoscale( # pylint: disable=name-too-long + self, resource_group_name: str, account_name: str, keyspace_name: str, table_name: str, **kwargs: Any + ) -> AsyncLROPoller[_models.ThroughputSettingsGetResults]: + """Migrate an Azure Cosmos DB Cassandra table from manual throughput to autoscale. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -1530,23 +1502,28 @@ async def begin_delete_cassandra_keyspace( :type account_name: str :param keyspace_name: Cosmos DB keyspace name. Required. :type keyspace_name: str - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] + :param table_name: Cosmos DB table name. Required. + :type table_name: str + :return: An instance of AsyncLROPoller that returns either ThroughputSettingsGetResults or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.ThroughputSettingsGetResults] :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) + cls: ClsType[_models.ThroughputSettingsGetResults] = 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_cassandra_keyspace_initial( + raw_result = await self._migrate_cassandra_table_to_autoscale_initial( resource_group_name=resource_group_name, account_name=account_name, keyspace_name=keyspace_name, + table_name=table_name, api_version=api_version, cls=lambda x, y, z: x, headers=_headers, @@ -1556,24 +1533,159 @@ async def begin_delete_cassandra_keyspace( 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 + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("ThroughputSettingsGetResults", pipeline_response.http_response) if cls: - return cls(pipeline_response, None, {}) # type: ignore + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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( + return AsyncLROPoller[_models.ThroughputSettingsGetResults].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 + return AsyncLROPoller[_models.ThroughputSettingsGetResults]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + async def _migrate_cassandra_table_to_manual_throughput_initial( # pylint: disable=name-too-long + self, resource_group_name: str, account_name: str, keyspace_name: str, table_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_migrate_cassandra_table_to_manual_throughput_request( + resource_group_name=resource_group_name, + account_name=account_name, + keyspace_name=keyspace_name, + table_name=table_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) + raise HttpResponseError(response=response, 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.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_migrate_cassandra_table_to_manual_throughput( # pylint: disable=name-too-long + self, resource_group_name: str, account_name: str, keyspace_name: str, table_name: str, **kwargs: Any + ) -> AsyncLROPoller[_models.ThroughputSettingsGetResults]: + """Migrate an Azure Cosmos DB Cassandra table from autoscale to manual throughput. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param keyspace_name: Cosmos DB keyspace name. Required. + :type keyspace_name: str + :param table_name: Cosmos DB table name. Required. + :type table_name: str + :return: An instance of AsyncLROPoller that returns either ThroughputSettingsGetResults or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.ThroughputSettingsGetResults] + :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.ThroughputSettingsGetResults] = 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_cassandra_table_to_manual_throughput_initial( + resource_group_name=resource_group_name, + account_name=account_name, + keyspace_name=keyspace_name, + table_name=table_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("ThroughputSettingsGetResults", 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": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.ThroughputSettingsGetResults].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.ThroughputSettingsGetResults]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) @distributed_trace_async async def get_cassandra_keyspace_throughput( @@ -1627,7 +1739,11 @@ async def get_cassandra_keyspace_throughput( if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("ThroughputSettingsGetResults", pipeline_response.http_response) @@ -1695,14 +1811,19 @@ async def _update_cassandra_keyspace_throughput_initial( # pylint: disable=name except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + 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["azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("azure-AsyncOperation") + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") ) - response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) @@ -1839,7 +1960,9 @@ def get_long_running_output(pipeline_response): return deserialized if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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: @@ -1901,10 +2024,11 @@ async def _migrate_cassandra_keyspace_to_autoscale_initial( # pylint: disable=n response_headers = {} if response.status_code == 202: - response_headers["azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("azure-AsyncOperation") + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") ) - response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) @@ -1961,7 +2085,9 @@ def get_long_running_output(pipeline_response): return deserialized if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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: @@ -2023,10 +2149,11 @@ async def _migrate_cassandra_keyspace_to_manual_throughput_initial( # pylint: d response_headers = {} if response.status_code == 202: - response_headers["azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("azure-AsyncOperation") + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") ) - response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) @@ -2083,7 +2210,9 @@ def get_long_running_output(pipeline_response): return deserialized if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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: @@ -2100,10 +2229,10 @@ def get_long_running_output(pipeline_response): ) @distributed_trace - def list_cassandra_tables( + def list_cassandra_views( self, resource_group_name: str, account_name: str, keyspace_name: str, **kwargs: Any - ) -> AsyncItemPaged["_models.CassandraTableGetResults"]: - """Lists the Cassandra table under an existing Azure Cosmos DB database account. + ) -> AsyncItemPaged["_models.CassandraViewGetResults"]: + """Lists the Cassandra materialized views under an existing Azure Cosmos DB database account. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -2112,17 +2241,17 @@ def list_cassandra_tables( :type account_name: str :param keyspace_name: Cosmos DB keyspace name. Required. :type keyspace_name: str - :return: An iterator like instance of either CassandraTableGetResults or the result of + :return: An iterator like instance of either CassandraViewGetResults or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.CassandraTableGetResults] + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.CassandraViewGetResults] :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.CassandraTableListResult] = kwargs.pop("cls", None) + cls: ClsType[_models.CassandraViewListResult] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -2135,7 +2264,7 @@ def list_cassandra_tables( def prepare_request(next_link=None): if not next_link: - _request = build_list_cassandra_tables_request( + _request = build_list_cassandra_views_request( resource_group_name=resource_group_name, account_name=account_name, keyspace_name=keyspace_name, @@ -2164,11 +2293,11 @@ def prepare_request(next_link=None): return _request async def extract_data(pipeline_response): - deserialized = self._deserialize("CassandraTableListResult", pipeline_response) + deserialized = self._deserialize("CassandraViewListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore - return None, AsyncList(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): _request = prepare_request(next_link) @@ -2181,17 +2310,21 @@ 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + 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_cassandra_table( - self, resource_group_name: str, account_name: str, keyspace_name: str, table_name: str, **kwargs: Any - ) -> _models.CassandraTableGetResults: - """Gets the Cassandra table under an existing Azure Cosmos DB database account. + async def get_cassandra_view( + self, resource_group_name: str, account_name: str, keyspace_name: str, view_name: str, **kwargs: Any + ) -> _models.CassandraViewGetResults: + """Gets the Cassandra view under an existing Azure Cosmos DB database account. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -2200,10 +2333,10 @@ async def get_cassandra_table( :type account_name: str :param keyspace_name: Cosmos DB keyspace name. Required. :type keyspace_name: str - :param table_name: Cosmos DB table name. Required. - :type table_name: str - :return: CassandraTableGetResults or the result of cls(response) - :rtype: ~azure.mgmt.cosmosdb.models.CassandraTableGetResults + :param view_name: Cosmos DB view name. Required. + :type view_name: str + :return: CassandraViewGetResults or the result of cls(response) + :rtype: ~azure.mgmt.cosmosdb.models.CassandraViewGetResults :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -2218,13 +2351,13 @@ async def get_cassandra_table( _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.CassandraTableGetResults] = kwargs.pop("cls", None) + cls: ClsType[_models.CassandraViewGetResults] = kwargs.pop("cls", None) - _request = build_get_cassandra_table_request( + _request = build_get_cassandra_view_request( resource_group_name=resource_group_name, account_name=account_name, keyspace_name=keyspace_name, - table_name=table_name, + view_name=view_name, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, @@ -2241,22 +2374,26 @@ async def get_cassandra_table( if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("CassandraTableGetResults", pipeline_response.http_response) + deserialized = self._deserialize("CassandraViewGetResults", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - async def _create_update_cassandra_table_initial( + async def _create_update_cassandra_view_initial( self, resource_group_name: str, account_name: str, keyspace_name: str, - table_name: str, - create_update_cassandra_table_parameters: Union[_models.CassandraTableCreateUpdateParameters, IO[bytes]], + view_name: str, + create_update_cassandra_view_parameters: Union[_models.CassandraViewCreateUpdateParameters, IO[bytes]], **kwargs: Any ) -> AsyncIterator[bytes]: error_map: MutableMapping = { @@ -2277,18 +2414,16 @@ async def _create_update_cassandra_table_initial( content_type = content_type or "application/json" _json = None _content = None - if isinstance(create_update_cassandra_table_parameters, (IOBase, bytes)): - _content = create_update_cassandra_table_parameters + if isinstance(create_update_cassandra_view_parameters, (IOBase, bytes)): + _content = create_update_cassandra_view_parameters else: - _json = self._serialize.body( - create_update_cassandra_table_parameters, "CassandraTableCreateUpdateParameters" - ) + _json = self._serialize.body(create_update_cassandra_view_parameters, "CassandraViewCreateUpdateParameters") - _request = build_create_update_cassandra_table_request( + _request = build_create_update_cassandra_view_request( resource_group_name=resource_group_name, account_name=account_name, keyspace_name=keyspace_name, - table_name=table_name, + view_name=view_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, @@ -2313,14 +2448,19 @@ async def _create_update_cassandra_table_initial( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - + 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["azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("azure-AsyncOperation") + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") ) - response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) @@ -2330,18 +2470,18 @@ async def _create_update_cassandra_table_initial( return deserialized # type: ignore @overload - async def begin_create_update_cassandra_table( + async def begin_create_update_cassandra_view( self, resource_group_name: str, account_name: str, keyspace_name: str, - table_name: str, - create_update_cassandra_table_parameters: _models.CassandraTableCreateUpdateParameters, + view_name: str, + create_update_cassandra_view_parameters: _models.CassandraViewCreateUpdateParameters, *, content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller[_models.CassandraTableGetResults]: - """Create or update an Azure Cosmos DB Cassandra Table. + ) -> AsyncLROPoller[_models.CassandraViewGetResults]: + """Create or update an Azure Cosmos DB Cassandra View. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -2350,35 +2490,34 @@ async def begin_create_update_cassandra_table( :type account_name: str :param keyspace_name: Cosmos DB keyspace name. Required. :type keyspace_name: str - :param table_name: Cosmos DB table name. Required. - :type table_name: str - :param create_update_cassandra_table_parameters: The parameters to provide for the current - Cassandra Table. Required. - :type create_update_cassandra_table_parameters: - ~azure.mgmt.cosmosdb.models.CassandraTableCreateUpdateParameters + :param view_name: Cosmos DB view name. Required. + :type view_name: str + :param create_update_cassandra_view_parameters: The parameters to provide for the current + Cassandra View. Required. + :type create_update_cassandra_view_parameters: + ~azure.mgmt.cosmosdb.models.CassandraViewCreateUpdateParameters :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 CassandraTableGetResults or the + :return: An instance of AsyncLROPoller that returns either CassandraViewGetResults or the result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.CassandraTableGetResults] + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.CassandraViewGetResults] :raises ~azure.core.exceptions.HttpResponseError: """ @overload - async def begin_create_update_cassandra_table( + async def begin_create_update_cassandra_view( self, resource_group_name: str, account_name: str, keyspace_name: str, - table_name: str, - create_update_cassandra_table_parameters: IO[bytes], + view_name: str, + create_update_cassandra_view_parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller[_models.CassandraTableGetResults]: - """Create or update an Azure Cosmos DB Cassandra Table. + ) -> AsyncLROPoller[_models.CassandraViewGetResults]: + """Create or update an Azure Cosmos DB Cassandra View. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -2387,32 +2526,31 @@ async def begin_create_update_cassandra_table( :type account_name: str :param keyspace_name: Cosmos DB keyspace name. Required. :type keyspace_name: str - :param table_name: Cosmos DB table name. Required. - :type table_name: str - :param create_update_cassandra_table_parameters: The parameters to provide for the current - Cassandra Table. Required. - :type create_update_cassandra_table_parameters: IO[bytes] + :param view_name: Cosmos DB view name. Required. + :type view_name: str + :param create_update_cassandra_view_parameters: The parameters to provide for the current + Cassandra View. Required. + :type create_update_cassandra_view_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 CassandraTableGetResults or the + :return: An instance of AsyncLROPoller that returns either CassandraViewGetResults or the result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.CassandraTableGetResults] + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.CassandraViewGetResults] :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace_async - async def begin_create_update_cassandra_table( + async def begin_create_update_cassandra_view( self, resource_group_name: str, account_name: str, keyspace_name: str, - table_name: str, - create_update_cassandra_table_parameters: Union[_models.CassandraTableCreateUpdateParameters, IO[bytes]], + view_name: str, + create_update_cassandra_view_parameters: Union[_models.CassandraViewCreateUpdateParameters, IO[bytes]], **kwargs: Any - ) -> AsyncLROPoller[_models.CassandraTableGetResults]: - """Create or update an Azure Cosmos DB Cassandra Table. + ) -> AsyncLROPoller[_models.CassandraViewGetResults]: + """Create or update an Azure Cosmos DB Cassandra View. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -2421,17 +2559,16 @@ async def begin_create_update_cassandra_table( :type account_name: str :param keyspace_name: Cosmos DB keyspace name. Required. :type keyspace_name: str - :param table_name: Cosmos DB table name. Required. - :type table_name: str - :param create_update_cassandra_table_parameters: The parameters to provide for the current - Cassandra Table. Is either a CassandraTableCreateUpdateParameters type or a IO[bytes] type. + :param view_name: Cosmos DB view name. Required. + :type view_name: str + :param create_update_cassandra_view_parameters: The parameters to provide for the current + Cassandra View. Is either a CassandraViewCreateUpdateParameters type or a IO[bytes] type. Required. - :type create_update_cassandra_table_parameters: - ~azure.mgmt.cosmosdb.models.CassandraTableCreateUpdateParameters or IO[bytes] - :return: An instance of AsyncLROPoller that returns either CassandraTableGetResults or the + :type create_update_cassandra_view_parameters: + ~azure.mgmt.cosmosdb.models.CassandraViewCreateUpdateParameters or IO[bytes] + :return: An instance of AsyncLROPoller that returns either CassandraViewGetResults or the result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.CassandraTableGetResults] + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.CassandraViewGetResults] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -2439,17 +2576,17 @@ async def begin_create_update_cassandra_table( 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.CassandraTableGetResults] = kwargs.pop("cls", None) + cls: ClsType[_models.CassandraViewGetResults] = 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_update_cassandra_table_initial( + raw_result = await self._create_update_cassandra_view_initial( resource_group_name=resource_group_name, account_name=account_name, keyspace_name=keyspace_name, - table_name=table_name, - create_update_cassandra_table_parameters=create_update_cassandra_table_parameters, + view_name=view_name, + create_update_cassandra_view_parameters=create_update_cassandra_view_parameters, api_version=api_version, content_type=content_type, cls=lambda x, y, z: x, @@ -2461,30 +2598,32 @@ async def begin_create_update_cassandra_table( kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("CassandraTableGetResults", pipeline_response.http_response) + deserialized = self._deserialize("CassandraViewGetResults", 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, **kwargs)) + 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.CassandraTableGetResults].from_continuation_token( + return AsyncLROPoller[_models.CassandraViewGetResults].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller[_models.CassandraTableGetResults]( + return AsyncLROPoller[_models.CassandraViewGetResults]( self._client, raw_result, get_long_running_output, polling_method # type: ignore ) - async def _delete_cassandra_table_initial( - self, resource_group_name: str, account_name: str, keyspace_name: str, table_name: str, **kwargs: Any + async def _delete_cassandra_view_initial( + self, resource_group_name: str, account_name: str, keyspace_name: str, view_name: str, **kwargs: Any ) -> AsyncIterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -2500,11 +2639,11 @@ async def _delete_cassandra_table_initial( 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_cassandra_table_request( + _request = build_delete_cassandra_view_request( resource_group_name=resource_group_name, account_name=account_name, keyspace_name=keyspace_name, - table_name=table_name, + view_name=view_name, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, @@ -2520,20 +2659,25 @@ async def _delete_cassandra_table_initial( response = pipeline_response.http_response - if response.status_code not in [202, 204]: + if response.status_code not in [200, 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + 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["azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("azure-AsyncOperation") + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") ) - response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) @@ -2543,10 +2687,10 @@ async def _delete_cassandra_table_initial( return deserialized # type: ignore @distributed_trace_async - async def begin_delete_cassandra_table( - self, resource_group_name: str, account_name: str, keyspace_name: str, table_name: str, **kwargs: Any + async def begin_delete_cassandra_view( + self, resource_group_name: str, account_name: str, keyspace_name: str, view_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: - """Deletes an existing Azure Cosmos DB Cassandra table. + """Deletes an existing Azure Cosmos DB Cassandra view. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -2555,8 +2699,8 @@ async def begin_delete_cassandra_table( :type account_name: str :param keyspace_name: Cosmos DB keyspace name. Required. :type keyspace_name: str - :param table_name: Cosmos DB table name. Required. - :type table_name: str + :param view_name: Cosmos DB view name. Required. + :type view_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: @@ -2570,11 +2714,11 @@ async def begin_delete_cassandra_table( 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_cassandra_table_initial( + raw_result = await self._delete_cassandra_view_initial( resource_group_name=resource_group_name, account_name=account_name, keyspace_name=keyspace_name, - table_name=table_name, + view_name=view_name, api_version=api_version, cls=lambda x, y, z: x, headers=_headers, @@ -2589,7 +2733,9 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- return cls(pipeline_response, None, {}) # type: ignore if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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: @@ -2604,10 +2750,10 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore @distributed_trace_async - async def get_cassandra_table_throughput( - self, resource_group_name: str, account_name: str, keyspace_name: str, table_name: str, **kwargs: Any + async def get_cassandra_view_throughput( + self, resource_group_name: str, account_name: str, keyspace_name: str, view_name: str, **kwargs: Any ) -> _models.ThroughputSettingsGetResults: - """Gets the RUs per second of the Cassandra table under an existing Azure Cosmos DB database + """Gets the RUs per second of the Cassandra view under an existing Azure Cosmos DB database account with the provided name. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -2617,8 +2763,8 @@ async def get_cassandra_table_throughput( :type account_name: str :param keyspace_name: Cosmos DB keyspace name. Required. :type keyspace_name: str - :param table_name: Cosmos DB table name. Required. - :type table_name: str + :param view_name: Cosmos DB view name. Required. + :type view_name: str :return: ThroughputSettingsGetResults or the result of cls(response) :rtype: ~azure.mgmt.cosmosdb.models.ThroughputSettingsGetResults :raises ~azure.core.exceptions.HttpResponseError: @@ -2637,11 +2783,11 @@ async def get_cassandra_table_throughput( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ThroughputSettingsGetResults] = kwargs.pop("cls", None) - _request = build_get_cassandra_table_throughput_request( + _request = build_get_cassandra_view_throughput_request( resource_group_name=resource_group_name, account_name=account_name, keyspace_name=keyspace_name, - table_name=table_name, + view_name=view_name, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, @@ -2658,7 +2804,11 @@ async def get_cassandra_table_throughput( if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("ThroughputSettingsGetResults", pipeline_response.http_response) @@ -2667,12 +2817,12 @@ async def get_cassandra_table_throughput( return deserialized # type: ignore - async def _update_cassandra_table_throughput_initial( # pylint: disable=name-too-long + async def _update_cassandra_view_throughput_initial( # pylint: disable=name-too-long self, resource_group_name: str, account_name: str, keyspace_name: str, - table_name: str, + view_name: str, update_throughput_parameters: Union[_models.ThroughputSettingsUpdateParameters, IO[bytes]], **kwargs: Any ) -> AsyncIterator[bytes]: @@ -2699,11 +2849,11 @@ async def _update_cassandra_table_throughput_initial( # pylint: disable=name-to else: _json = self._serialize.body(update_throughput_parameters, "ThroughputSettingsUpdateParameters") - _request = build_update_cassandra_table_throughput_request( + _request = build_update_cassandra_view_throughput_request( resource_group_name=resource_group_name, account_name=account_name, keyspace_name=keyspace_name, - table_name=table_name, + view_name=view_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, @@ -2728,14 +2878,19 @@ async def _update_cassandra_table_throughput_initial( # pylint: disable=name-to except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + 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["azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("azure-AsyncOperation") + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") ) - response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) @@ -2745,18 +2900,18 @@ async def _update_cassandra_table_throughput_initial( # pylint: disable=name-to return deserialized # type: ignore @overload - async def begin_update_cassandra_table_throughput( + async def begin_update_cassandra_view_throughput( self, resource_group_name: str, account_name: str, keyspace_name: str, - table_name: str, + view_name: str, update_throughput_parameters: _models.ThroughputSettingsUpdateParameters, *, content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[_models.ThroughputSettingsGetResults]: - """Update RUs per second of an Azure Cosmos DB Cassandra table. + """Update RUs per second of an Azure Cosmos DB Cassandra view. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -2765,10 +2920,10 @@ async def begin_update_cassandra_table_throughput( :type account_name: str :param keyspace_name: Cosmos DB keyspace name. Required. :type keyspace_name: str - :param table_name: Cosmos DB table name. Required. - :type table_name: str + :param view_name: Cosmos DB view name. Required. + :type view_name: str :param update_throughput_parameters: The RUs per second of the parameters to provide for the - current Cassandra table. Required. + current Cassandra view. Required. :type update_throughput_parameters: ~azure.mgmt.cosmosdb.models.ThroughputSettingsUpdateParameters :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. @@ -2782,18 +2937,18 @@ async def begin_update_cassandra_table_throughput( """ @overload - async def begin_update_cassandra_table_throughput( + async def begin_update_cassandra_view_throughput( self, resource_group_name: str, account_name: str, keyspace_name: str, - table_name: str, + view_name: str, update_throughput_parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[_models.ThroughputSettingsGetResults]: - """Update RUs per second of an Azure Cosmos DB Cassandra table. + """Update RUs per second of an Azure Cosmos DB Cassandra view. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -2802,10 +2957,10 @@ async def begin_update_cassandra_table_throughput( :type account_name: str :param keyspace_name: Cosmos DB keyspace name. Required. :type keyspace_name: str - :param table_name: Cosmos DB table name. Required. - :type table_name: str + :param view_name: Cosmos DB view name. Required. + :type view_name: str :param update_throughput_parameters: The RUs per second of the parameters to provide for the - current Cassandra table. Required. + current Cassandra view. Required. :type update_throughput_parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". @@ -2818,16 +2973,16 @@ async def begin_update_cassandra_table_throughput( """ @distributed_trace_async - async def begin_update_cassandra_table_throughput( + async def begin_update_cassandra_view_throughput( self, resource_group_name: str, account_name: str, keyspace_name: str, - table_name: str, + view_name: str, update_throughput_parameters: Union[_models.ThroughputSettingsUpdateParameters, IO[bytes]], **kwargs: Any ) -> AsyncLROPoller[_models.ThroughputSettingsGetResults]: - """Update RUs per second of an Azure Cosmos DB Cassandra table. + """Update RUs per second of an Azure Cosmos DB Cassandra view. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -2836,10 +2991,10 @@ async def begin_update_cassandra_table_throughput( :type account_name: str :param keyspace_name: Cosmos DB keyspace name. Required. :type keyspace_name: str - :param table_name: Cosmos DB table name. Required. - :type table_name: str + :param view_name: Cosmos DB view name. Required. + :type view_name: str :param update_throughput_parameters: The RUs per second of the parameters to provide for the - current Cassandra table. Is either a ThroughputSettingsUpdateParameters type or a IO[bytes] + current Cassandra view. Is either a ThroughputSettingsUpdateParameters type or a IO[bytes] type. Required. :type update_throughput_parameters: ~azure.mgmt.cosmosdb.models.ThroughputSettingsUpdateParameters or IO[bytes] @@ -2859,11 +3014,11 @@ async def begin_update_cassandra_table_throughput( 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_cassandra_table_throughput_initial( + raw_result = await self._update_cassandra_view_throughput_initial( resource_group_name=resource_group_name, account_name=account_name, keyspace_name=keyspace_name, - table_name=table_name, + view_name=view_name, update_throughput_parameters=update_throughput_parameters, api_version=api_version, content_type=content_type, @@ -2882,7 +3037,9 @@ def get_long_running_output(pipeline_response): return deserialized if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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: @@ -2898,8 +3055,8 @@ def get_long_running_output(pipeline_response): self._client, raw_result, get_long_running_output, polling_method # type: ignore ) - async def _migrate_cassandra_table_to_autoscale_initial( # pylint: disable=name-too-long - self, resource_group_name: str, account_name: str, keyspace_name: str, table_name: str, **kwargs: Any + async def _migrate_cassandra_view_to_autoscale_initial( # pylint: disable=name-too-long + self, resource_group_name: str, account_name: str, keyspace_name: str, view_name: str, **kwargs: Any ) -> AsyncIterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -2915,11 +3072,11 @@ async def _migrate_cassandra_table_to_autoscale_initial( # pylint: disable=name 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_migrate_cassandra_table_to_autoscale_request( + _request = build_migrate_cassandra_view_to_autoscale_request( resource_group_name=resource_group_name, account_name=account_name, keyspace_name=keyspace_name, - table_name=table_name, + view_name=view_name, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, @@ -2945,10 +3102,11 @@ async def _migrate_cassandra_table_to_autoscale_initial( # pylint: disable=name response_headers = {} if response.status_code == 202: - response_headers["azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("azure-AsyncOperation") + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") ) - response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) @@ -2958,10 +3116,10 @@ async def _migrate_cassandra_table_to_autoscale_initial( # pylint: disable=name return deserialized # type: ignore @distributed_trace_async - async def begin_migrate_cassandra_table_to_autoscale( # pylint: disable=name-too-long - self, resource_group_name: str, account_name: str, keyspace_name: str, table_name: str, **kwargs: Any + async def begin_migrate_cassandra_view_to_autoscale( # pylint: disable=name-too-long + self, resource_group_name: str, account_name: str, keyspace_name: str, view_name: str, **kwargs: Any ) -> AsyncLROPoller[_models.ThroughputSettingsGetResults]: - """Migrate an Azure Cosmos DB Cassandra table from manual throughput to autoscale. + """Migrate an Azure Cosmos DB Cassandra view from manual throughput to autoscale. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -2970,8 +3128,8 @@ async def begin_migrate_cassandra_table_to_autoscale( # pylint: disable=name-to :type account_name: str :param keyspace_name: Cosmos DB keyspace name. Required. :type keyspace_name: str - :param table_name: Cosmos DB table name. Required. - :type table_name: str + :param view_name: Cosmos DB view name. Required. + :type view_name: str :return: An instance of AsyncLROPoller that returns either ThroughputSettingsGetResults or the result of cls(response) :rtype: @@ -2987,11 +3145,11 @@ async def begin_migrate_cassandra_table_to_autoscale( # pylint: disable=name-to 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_cassandra_table_to_autoscale_initial( + raw_result = await self._migrate_cassandra_view_to_autoscale_initial( resource_group_name=resource_group_name, account_name=account_name, keyspace_name=keyspace_name, - table_name=table_name, + view_name=view_name, api_version=api_version, cls=lambda x, y, z: x, headers=_headers, @@ -3008,7 +3166,9 @@ def get_long_running_output(pipeline_response): return deserialized if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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: @@ -3024,8 +3184,8 @@ def get_long_running_output(pipeline_response): self._client, raw_result, get_long_running_output, polling_method # type: ignore ) - async def _migrate_cassandra_table_to_manual_throughput_initial( # pylint: disable=name-too-long - self, resource_group_name: str, account_name: str, keyspace_name: str, table_name: str, **kwargs: Any + async def _migrate_cassandra_view_to_manual_throughput_initial( # pylint: disable=name-too-long + self, resource_group_name: str, account_name: str, keyspace_name: str, view_name: str, **kwargs: Any ) -> AsyncIterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -3041,11 +3201,11 @@ async def _migrate_cassandra_table_to_manual_throughput_initial( # pylint: disa 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_migrate_cassandra_table_to_manual_throughput_request( + _request = build_migrate_cassandra_view_to_manual_throughput_request( resource_group_name=resource_group_name, account_name=account_name, keyspace_name=keyspace_name, - table_name=table_name, + view_name=view_name, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, @@ -3071,10 +3231,11 @@ async def _migrate_cassandra_table_to_manual_throughput_initial( # pylint: disa response_headers = {} if response.status_code == 202: - response_headers["azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("azure-AsyncOperation") + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") ) - response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) @@ -3084,10 +3245,10 @@ async def _migrate_cassandra_table_to_manual_throughput_initial( # pylint: disa return deserialized # type: ignore @distributed_trace_async - async def begin_migrate_cassandra_table_to_manual_throughput( # pylint: disable=name-too-long - self, resource_group_name: str, account_name: str, keyspace_name: str, table_name: str, **kwargs: Any + async def begin_migrate_cassandra_view_to_manual_throughput( # pylint: disable=name-too-long + self, resource_group_name: str, account_name: str, keyspace_name: str, view_name: str, **kwargs: Any ) -> AsyncLROPoller[_models.ThroughputSettingsGetResults]: - """Migrate an Azure Cosmos DB Cassandra table from autoscale to manual throughput. + """Migrate an Azure Cosmos DB Cassandra view from autoscale to manual throughput. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -3096,8 +3257,8 @@ async def begin_migrate_cassandra_table_to_manual_throughput( # pylint: disable :type account_name: str :param keyspace_name: Cosmos DB keyspace name. Required. :type keyspace_name: str - :param table_name: Cosmos DB table name. Required. - :type table_name: str + :param view_name: Cosmos DB view name. Required. + :type view_name: str :return: An instance of AsyncLROPoller that returns either ThroughputSettingsGetResults or the result of cls(response) :rtype: @@ -3113,11 +3274,11 @@ async def begin_migrate_cassandra_table_to_manual_throughput( # pylint: disable 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_cassandra_table_to_manual_throughput_initial( + raw_result = await self._migrate_cassandra_view_to_manual_throughput_initial( resource_group_name=resource_group_name, account_name=account_name, keyspace_name=keyspace_name, - table_name=table_name, + view_name=view_name, api_version=api_version, cls=lambda x, y, z: x, headers=_headers, @@ -3134,7 +3295,9 @@ def get_long_running_output(pipeline_response): return deserialized if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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: @@ -3151,29 +3314,27 @@ def get_long_running_output(pipeline_response): ) @distributed_trace - def list_cassandra_views( - self, resource_group_name: str, account_name: str, keyspace_name: str, **kwargs: Any - ) -> AsyncItemPaged["_models.CassandraViewGetResults"]: - """Lists the Cassandra materialized views under an existing Azure Cosmos DB database account. + def list_cassandra_role_assignments( + self, resource_group_name: str, account_name: str, **kwargs: Any + ) -> AsyncItemPaged["_models.CassandraRoleAssignmentResource"]: + """Retrieves the list of all Azure Cosmos DB Cassandra Role Assignments. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param keyspace_name: Cosmos DB keyspace name. Required. - :type keyspace_name: str - :return: An iterator like instance of either CassandraViewGetResults or the result of + :return: An iterator like instance of either CassandraRoleAssignmentResource or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.CassandraViewGetResults] + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.CassandraRoleAssignmentResource] :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.CassandraViewListResult] = kwargs.pop("cls", None) + cls: ClsType[_models.CassandraRoleAssignmentListResult] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -3186,10 +3347,9 @@ def list_cassandra_views( def prepare_request(next_link=None): if not next_link: - _request = build_list_cassandra_views_request( + _request = build_list_cassandra_role_assignments_request( resource_group_name=resource_group_name, account_name=account_name, - keyspace_name=keyspace_name, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, @@ -3215,11 +3375,11 @@ def prepare_request(next_link=None): return _request async def extract_data(pipeline_response): - deserialized = self._deserialize("CassandraViewListResult", pipeline_response) + deserialized = self._deserialize("CassandraRoleAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore - return None, AsyncList(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): _request = prepare_request(next_link) @@ -3232,29 +3392,32 @@ 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + 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_cassandra_view( - self, resource_group_name: str, account_name: str, keyspace_name: str, view_name: str, **kwargs: Any - ) -> _models.CassandraViewGetResults: - """Gets the Cassandra view under an existing Azure Cosmos DB database account. + async def get_cassandra_role_assignment( + self, resource_group_name: str, account_name: str, role_assignment_id: str, **kwargs: Any + ) -> _models.CassandraRoleAssignmentResource: + """Retrieves the properties of an existing Azure Cosmos DB Cassandra Role Assignment with the + given Id. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param keyspace_name: Cosmos DB keyspace name. Required. - :type keyspace_name: str - :param view_name: Cosmos DB view name. Required. - :type view_name: str - :return: CassandraViewGetResults or the result of cls(response) - :rtype: ~azure.mgmt.cosmosdb.models.CassandraViewGetResults + :param role_assignment_id: The GUID for the Role Assignment. Required. + :type role_assignment_id: str + :return: CassandraRoleAssignmentResource or the result of cls(response) + :rtype: ~azure.mgmt.cosmosdb.models.CassandraRoleAssignmentResource :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -3269,13 +3432,12 @@ async def get_cassandra_view( _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.CassandraViewGetResults] = kwargs.pop("cls", None) + cls: ClsType[_models.CassandraRoleAssignmentResource] = kwargs.pop("cls", None) - _request = build_get_cassandra_view_request( + _request = build_get_cassandra_role_assignment_request( resource_group_name=resource_group_name, account_name=account_name, - keyspace_name=keyspace_name, - view_name=view_name, + role_assignment_id=role_assignment_id, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, @@ -3292,22 +3454,25 @@ async def get_cassandra_view( if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("CassandraViewGetResults", pipeline_response.http_response) + deserialized = self._deserialize("CassandraRoleAssignmentResource", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - async def _create_update_cassandra_view_initial( + async def _create_update_cassandra_role_assignment_initial( # pylint: disable=name-too-long self, resource_group_name: str, account_name: str, - keyspace_name: str, - view_name: str, - create_update_cassandra_view_parameters: Union[_models.CassandraViewCreateUpdateParameters, IO[bytes]], + role_assignment_id: str, + create_update_cassandra_role_assignment_parameters: Union[_models.CassandraRoleAssignmentResource, IO[bytes]], **kwargs: Any ) -> AsyncIterator[bytes]: error_map: MutableMapping = { @@ -3328,16 +3493,17 @@ async def _create_update_cassandra_view_initial( content_type = content_type or "application/json" _json = None _content = None - if isinstance(create_update_cassandra_view_parameters, (IOBase, bytes)): - _content = create_update_cassandra_view_parameters + if isinstance(create_update_cassandra_role_assignment_parameters, (IOBase, bytes)): + _content = create_update_cassandra_role_assignment_parameters else: - _json = self._serialize.body(create_update_cassandra_view_parameters, "CassandraViewCreateUpdateParameters") + _json = self._serialize.body( + create_update_cassandra_role_assignment_parameters, "CassandraRoleAssignmentResource" + ) - _request = build_create_update_cassandra_view_request( + _request = build_create_update_cassandra_role_assignment_request( resource_group_name=resource_group_name, account_name=account_name, - keyspace_name=keyspace_name, - view_name=view_name, + role_assignment_id=role_assignment_id, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, @@ -3362,14 +3528,19 @@ async def _create_update_cassandra_view_initial( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + 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["azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("azure-AsyncOperation") + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") ) - response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) @@ -3379,105 +3550,99 @@ async def _create_update_cassandra_view_initial( return deserialized # type: ignore @overload - async def begin_create_update_cassandra_view( + async def begin_create_update_cassandra_role_assignment( # pylint: disable=name-too-long self, resource_group_name: str, account_name: str, - keyspace_name: str, - view_name: str, - create_update_cassandra_view_parameters: _models.CassandraViewCreateUpdateParameters, + role_assignment_id: str, + create_update_cassandra_role_assignment_parameters: _models.CassandraRoleAssignmentResource, *, content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller[_models.CassandraViewGetResults]: - """Create or update an Azure Cosmos DB Cassandra View. + ) -> AsyncLROPoller[_models.CassandraRoleAssignmentResource]: + """Creates or updates an Azure Cosmos DB Cassandra Role Assignment. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param keyspace_name: Cosmos DB keyspace name. Required. - :type keyspace_name: str - :param view_name: Cosmos DB view name. Required. - :type view_name: str - :param create_update_cassandra_view_parameters: The parameters to provide for the current - Cassandra View. Required. - :type create_update_cassandra_view_parameters: - ~azure.mgmt.cosmosdb.models.CassandraViewCreateUpdateParameters + :param role_assignment_id: The GUID for the Role Assignment. Required. + :type role_assignment_id: str + :param create_update_cassandra_role_assignment_parameters: The properties required to create or + update a Role Assignment. Required. + :type create_update_cassandra_role_assignment_parameters: + ~azure.mgmt.cosmosdb.models.CassandraRoleAssignmentResource :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 CassandraViewGetResults or the - result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.CassandraViewGetResults] + :return: An instance of AsyncLROPoller that returns either CassandraRoleAssignmentResource or + the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.CassandraRoleAssignmentResource] :raises ~azure.core.exceptions.HttpResponseError: """ @overload - async def begin_create_update_cassandra_view( + async def begin_create_update_cassandra_role_assignment( # pylint: disable=name-too-long self, resource_group_name: str, account_name: str, - keyspace_name: str, - view_name: str, - create_update_cassandra_view_parameters: IO[bytes], + role_assignment_id: str, + create_update_cassandra_role_assignment_parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller[_models.CassandraViewGetResults]: - """Create or update an Azure Cosmos DB Cassandra View. + ) -> AsyncLROPoller[_models.CassandraRoleAssignmentResource]: + """Creates or updates an Azure Cosmos DB Cassandra Role Assignment. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param keyspace_name: Cosmos DB keyspace name. Required. - :type keyspace_name: str - :param view_name: Cosmos DB view name. Required. - :type view_name: str - :param create_update_cassandra_view_parameters: The parameters to provide for the current - Cassandra View. Required. - :type create_update_cassandra_view_parameters: IO[bytes] + :param role_assignment_id: The GUID for the Role Assignment. Required. + :type role_assignment_id: str + :param create_update_cassandra_role_assignment_parameters: The properties required to create or + update a Role Assignment. Required. + :type create_update_cassandra_role_assignment_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 CassandraViewGetResults or the - result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.CassandraViewGetResults] + :return: An instance of AsyncLROPoller that returns either CassandraRoleAssignmentResource or + the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.CassandraRoleAssignmentResource] :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace_async - async def begin_create_update_cassandra_view( + async def begin_create_update_cassandra_role_assignment( # pylint: disable=name-too-long self, resource_group_name: str, account_name: str, - keyspace_name: str, - view_name: str, - create_update_cassandra_view_parameters: Union[_models.CassandraViewCreateUpdateParameters, IO[bytes]], + role_assignment_id: str, + create_update_cassandra_role_assignment_parameters: Union[_models.CassandraRoleAssignmentResource, IO[bytes]], **kwargs: Any - ) -> AsyncLROPoller[_models.CassandraViewGetResults]: - """Create or update an Azure Cosmos DB Cassandra View. + ) -> AsyncLROPoller[_models.CassandraRoleAssignmentResource]: + """Creates or updates an Azure Cosmos DB Cassandra Role Assignment. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param keyspace_name: Cosmos DB keyspace name. Required. - :type keyspace_name: str - :param view_name: Cosmos DB view name. Required. - :type view_name: str - :param create_update_cassandra_view_parameters: The parameters to provide for the current - Cassandra View. Is either a CassandraViewCreateUpdateParameters type or a IO[bytes] type. + :param role_assignment_id: The GUID for the Role Assignment. Required. + :type role_assignment_id: str + :param create_update_cassandra_role_assignment_parameters: The properties required to create or + update a Role Assignment. Is either a CassandraRoleAssignmentResource type or a IO[bytes] type. Required. - :type create_update_cassandra_view_parameters: - ~azure.mgmt.cosmosdb.models.CassandraViewCreateUpdateParameters or IO[bytes] - :return: An instance of AsyncLROPoller that returns either CassandraViewGetResults or the - result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.CassandraViewGetResults] + :type create_update_cassandra_role_assignment_parameters: + ~azure.mgmt.cosmosdb.models.CassandraRoleAssignmentResource or IO[bytes] + :return: An instance of AsyncLROPoller that returns either CassandraRoleAssignmentResource or + the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.CassandraRoleAssignmentResource] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -3485,17 +3650,16 @@ async def begin_create_update_cassandra_view( 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.CassandraViewGetResults] = kwargs.pop("cls", None) + cls: ClsType[_models.CassandraRoleAssignmentResource] = 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_update_cassandra_view_initial( + raw_result = await self._create_update_cassandra_role_assignment_initial( resource_group_name=resource_group_name, account_name=account_name, - keyspace_name=keyspace_name, - view_name=view_name, - create_update_cassandra_view_parameters=create_update_cassandra_view_parameters, + role_assignment_id=role_assignment_id, + create_update_cassandra_role_assignment_parameters=create_update_cassandra_role_assignment_parameters, api_version=api_version, content_type=content_type, cls=lambda x, y, z: x, @@ -3507,30 +3671,32 @@ async def begin_create_update_cassandra_view( kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("CassandraViewGetResults", pipeline_response.http_response) + deserialized = self._deserialize("CassandraRoleAssignmentResource", 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, **kwargs)) + 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.CassandraViewGetResults].from_continuation_token( + return AsyncLROPoller[_models.CassandraRoleAssignmentResource].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller[_models.CassandraViewGetResults]( + return AsyncLROPoller[_models.CassandraRoleAssignmentResource]( self._client, raw_result, get_long_running_output, polling_method # type: ignore ) - async def _delete_cassandra_view_initial( - self, resource_group_name: str, account_name: str, keyspace_name: str, view_name: str, **kwargs: Any + async def _delete_cassandra_role_assignment_initial( # pylint: disable=name-too-long + self, resource_group_name: str, account_name: str, role_assignment_id: str, **kwargs: Any ) -> AsyncIterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -3546,11 +3712,10 @@ async def _delete_cassandra_view_initial( 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_cassandra_view_request( + _request = build_delete_cassandra_role_assignment_request( resource_group_name=resource_group_name, account_name=account_name, - keyspace_name=keyspace_name, - view_name=view_name, + role_assignment_id=role_assignment_id, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, @@ -3572,14 +3737,18 @@ async def _delete_cassandra_view_initial( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + 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["azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("azure-AsyncOperation") + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") ) - response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) @@ -3589,20 +3758,18 @@ async def _delete_cassandra_view_initial( return deserialized # type: ignore @distributed_trace_async - async def begin_delete_cassandra_view( - self, resource_group_name: str, account_name: str, keyspace_name: str, view_name: str, **kwargs: Any + async def begin_delete_cassandra_role_assignment( + self, resource_group_name: str, account_name: str, role_assignment_id: str, **kwargs: Any ) -> AsyncLROPoller[None]: - """Deletes an existing Azure Cosmos DB Cassandra view. + """Deletes an existing Azure Cosmos DB Cassandra Role Assignment. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param keyspace_name: Cosmos DB keyspace name. Required. - :type keyspace_name: str - :param view_name: Cosmos DB view name. Required. - :type view_name: str + :param role_assignment_id: The GUID for the Role Assignment. Required. + :type role_assignment_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: @@ -3616,11 +3783,10 @@ async def begin_delete_cassandra_view( 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_cassandra_view_initial( + raw_result = await self._delete_cassandra_role_assignment_initial( resource_group_name=resource_group_name, account_name=account_name, - keyspace_name=keyspace_name, - view_name=view_name, + role_assignment_id=role_assignment_id, api_version=api_version, cls=lambda x, y, z: x, headers=_headers, @@ -3635,7 +3801,9 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- return cls(pipeline_response, None, {}) # type: ignore if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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: @@ -3649,26 +3817,29 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- ) return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - @distributed_trace_async - async def get_cassandra_view_throughput( - self, resource_group_name: str, account_name: str, keyspace_name: str, view_name: str, **kwargs: Any - ) -> _models.ThroughputSettingsGetResults: - """Gets the RUs per second of the Cassandra view under an existing Azure Cosmos DB database - account with the provided name. + @distributed_trace + def list_cassandra_role_definitions( + self, resource_group_name: str, account_name: str, **kwargs: Any + ) -> AsyncItemPaged["_models.CassandraRoleDefinitionResource"]: + """Retrieves the list of all Azure Cosmos DB Cassandra Role Definitions. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param keyspace_name: Cosmos DB keyspace name. Required. - :type keyspace_name: str - :param view_name: Cosmos DB view name. Required. - :type view_name: str - :return: ThroughputSettingsGetResults or the result of cls(response) - :rtype: ~azure.mgmt.cosmosdb.models.ThroughputSettingsGetResults + :return: An iterator like instance of either CassandraRoleDefinitionResource or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.CassandraRoleDefinitionResource] :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.CassandraRoleDefinitionListResult] = kwargs.pop("cls", None) + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -3677,17 +3848,100 @@ async def get_cassandra_view_throughput( } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_cassandra_role_definitions_request( + resource_group_name=resource_group_name, + account_name=account_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("CassandraRoleDefinitionListResult", 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_cassandra_role_definition( + self, resource_group_name: str, account_name: str, role_definition_id: str, **kwargs: Any + ) -> _models.CassandraRoleDefinitionResource: + """Retrieves the properties of an existing Azure Cosmos DB Cassandra Role Definition with the + given Id. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param role_definition_id: The GUID for the Role Definition. Required. + :type role_definition_id: str + :return: CassandraRoleDefinitionResource or the result of cls(response) + :rtype: ~azure.mgmt.cosmosdb.models.CassandraRoleDefinitionResource + :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.ThroughputSettingsGetResults] = kwargs.pop("cls", None) + cls: ClsType[_models.CassandraRoleDefinitionResource] = kwargs.pop("cls", None) - _request = build_get_cassandra_view_throughput_request( + _request = build_get_cassandra_role_definition_request( resource_group_name=resource_group_name, account_name=account_name, - keyspace_name=keyspace_name, - view_name=view_name, + role_definition_id=role_definition_id, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, @@ -3704,22 +3958,25 @@ async def get_cassandra_view_throughput( if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("ThroughputSettingsGetResults", pipeline_response.http_response) + deserialized = self._deserialize("CassandraRoleDefinitionResource", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - async def _update_cassandra_view_throughput_initial( # pylint: disable=name-too-long + async def _create_update_cassandra_role_definition_initial( # pylint: disable=name-too-long self, resource_group_name: str, account_name: str, - keyspace_name: str, - view_name: str, - update_throughput_parameters: Union[_models.ThroughputSettingsUpdateParameters, IO[bytes]], + role_definition_id: str, + create_update_cassandra_role_definition_parameters: Union[_models.CassandraRoleDefinitionResource, IO[bytes]], **kwargs: Any ) -> AsyncIterator[bytes]: error_map: MutableMapping = { @@ -3740,16 +3997,17 @@ async def _update_cassandra_view_throughput_initial( # pylint: disable=name-too content_type = content_type or "application/json" _json = None _content = None - if isinstance(update_throughput_parameters, (IOBase, bytes)): - _content = update_throughput_parameters + if isinstance(create_update_cassandra_role_definition_parameters, (IOBase, bytes)): + _content = create_update_cassandra_role_definition_parameters else: - _json = self._serialize.body(update_throughput_parameters, "ThroughputSettingsUpdateParameters") + _json = self._serialize.body( + create_update_cassandra_role_definition_parameters, "CassandraRoleDefinitionResource" + ) - _request = build_update_cassandra_view_throughput_request( + _request = build_create_update_cassandra_role_definition_request( resource_group_name=resource_group_name, account_name=account_name, - keyspace_name=keyspace_name, - view_name=view_name, + role_definition_id=role_definition_id, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, @@ -3774,14 +4032,19 @@ async def _update_cassandra_view_throughput_initial( # pylint: disable=name-too except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + 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["azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("azure-AsyncOperation") + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") ) - response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) @@ -3791,108 +4054,99 @@ async def _update_cassandra_view_throughput_initial( # pylint: disable=name-too return deserialized # type: ignore @overload - async def begin_update_cassandra_view_throughput( + async def begin_create_update_cassandra_role_definition( # pylint: disable=name-too-long self, resource_group_name: str, account_name: str, - keyspace_name: str, - view_name: str, - update_throughput_parameters: _models.ThroughputSettingsUpdateParameters, + role_definition_id: str, + create_update_cassandra_role_definition_parameters: _models.CassandraRoleDefinitionResource, *, content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller[_models.ThroughputSettingsGetResults]: - """Update RUs per second of an Azure Cosmos DB Cassandra view. + ) -> AsyncLROPoller[_models.CassandraRoleDefinitionResource]: + """Creates or updates an Azure Cosmos DB Cassandra Role Definition. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param keyspace_name: Cosmos DB keyspace name. Required. - :type keyspace_name: str - :param view_name: Cosmos DB view name. Required. - :type view_name: str - :param update_throughput_parameters: The RUs per second of the parameters to provide for the - current Cassandra view. Required. - :type update_throughput_parameters: - ~azure.mgmt.cosmosdb.models.ThroughputSettingsUpdateParameters + :param role_definition_id: The GUID for the Role Definition. Required. + :type role_definition_id: str + :param create_update_cassandra_role_definition_parameters: The properties required to create or + update a Role Definition. Required. + :type create_update_cassandra_role_definition_parameters: + ~azure.mgmt.cosmosdb.models.CassandraRoleDefinitionResource :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 ThroughputSettingsGetResults or the - result of cls(response) + :return: An instance of AsyncLROPoller that returns either CassandraRoleDefinitionResource or + the result of cls(response) :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.ThroughputSettingsGetResults] + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.CassandraRoleDefinitionResource] :raises ~azure.core.exceptions.HttpResponseError: """ @overload - async def begin_update_cassandra_view_throughput( + async def begin_create_update_cassandra_role_definition( # pylint: disable=name-too-long self, resource_group_name: str, account_name: str, - keyspace_name: str, - view_name: str, - update_throughput_parameters: IO[bytes], + role_definition_id: str, + create_update_cassandra_role_definition_parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller[_models.ThroughputSettingsGetResults]: - """Update RUs per second of an Azure Cosmos DB Cassandra view. + ) -> AsyncLROPoller[_models.CassandraRoleDefinitionResource]: + """Creates or updates an Azure Cosmos DB Cassandra Role Definition. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param keyspace_name: Cosmos DB keyspace name. Required. - :type keyspace_name: str - :param view_name: Cosmos DB view name. Required. - :type view_name: str - :param update_throughput_parameters: The RUs per second of the parameters to provide for the - current Cassandra view. Required. - :type update_throughput_parameters: IO[bytes] + :param role_definition_id: The GUID for the Role Definition. Required. + :type role_definition_id: str + :param create_update_cassandra_role_definition_parameters: The properties required to create or + update a Role Definition. Required. + :type create_update_cassandra_role_definition_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 ThroughputSettingsGetResults or the - result of cls(response) + :return: An instance of AsyncLROPoller that returns either CassandraRoleDefinitionResource or + the result of cls(response) :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.ThroughputSettingsGetResults] + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.CassandraRoleDefinitionResource] :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace_async - async def begin_update_cassandra_view_throughput( + async def begin_create_update_cassandra_role_definition( # pylint: disable=name-too-long self, resource_group_name: str, account_name: str, - keyspace_name: str, - view_name: str, - update_throughput_parameters: Union[_models.ThroughputSettingsUpdateParameters, IO[bytes]], + role_definition_id: str, + create_update_cassandra_role_definition_parameters: Union[_models.CassandraRoleDefinitionResource, IO[bytes]], **kwargs: Any - ) -> AsyncLROPoller[_models.ThroughputSettingsGetResults]: - """Update RUs per second of an Azure Cosmos DB Cassandra view. + ) -> AsyncLROPoller[_models.CassandraRoleDefinitionResource]: + """Creates or updates an Azure Cosmos DB Cassandra Role Definition. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param keyspace_name: Cosmos DB keyspace name. Required. - :type keyspace_name: str - :param view_name: Cosmos DB view name. Required. - :type view_name: str - :param update_throughput_parameters: The RUs per second of the parameters to provide for the - current Cassandra view. Is either a ThroughputSettingsUpdateParameters type or a IO[bytes] - type. Required. - :type update_throughput_parameters: - ~azure.mgmt.cosmosdb.models.ThroughputSettingsUpdateParameters or IO[bytes] - :return: An instance of AsyncLROPoller that returns either ThroughputSettingsGetResults or the - result of cls(response) + :param role_definition_id: The GUID for the Role Definition. Required. + :type role_definition_id: str + :param create_update_cassandra_role_definition_parameters: The properties required to create or + update a Role Definition. Is either a CassandraRoleDefinitionResource type or a IO[bytes] type. + Required. + :type create_update_cassandra_role_definition_parameters: + ~azure.mgmt.cosmosdb.models.CassandraRoleDefinitionResource or IO[bytes] + :return: An instance of AsyncLROPoller that returns either CassandraRoleDefinitionResource or + the result of cls(response) :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.ThroughputSettingsGetResults] + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.CassandraRoleDefinitionResource] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -3900,17 +4154,16 @@ async def begin_update_cassandra_view_throughput( 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.ThroughputSettingsGetResults] = kwargs.pop("cls", None) + cls: ClsType[_models.CassandraRoleDefinitionResource] = 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_cassandra_view_throughput_initial( + raw_result = await self._create_update_cassandra_role_definition_initial( resource_group_name=resource_group_name, account_name=account_name, - keyspace_name=keyspace_name, - view_name=view_name, - update_throughput_parameters=update_throughput_parameters, + role_definition_id=role_definition_id, + create_update_cassandra_role_definition_parameters=create_update_cassandra_role_definition_parameters, api_version=api_version, content_type=content_type, cls=lambda x, y, z: x, @@ -3922,156 +4175,32 @@ async def begin_update_cassandra_view_throughput( kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ThroughputSettingsGetResults", pipeline_response.http_response) + deserialized = self._deserialize("CassandraRoleDefinitionResource", 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, **kwargs)) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[_models.ThroughputSettingsGetResults].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) ) - return AsyncLROPoller[_models.ThroughputSettingsGetResults]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _migrate_cassandra_view_to_autoscale_initial( # pylint: disable=name-too-long - self, resource_group_name: str, account_name: str, keyspace_name: str, view_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_migrate_cassandra_view_to_autoscale_request( - resource_group_name=resource_group_name, - account_name=account_name, - keyspace_name=keyspace_name, - view_name=view_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) - raise HttpResponseError(response=response, 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")) - - 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_migrate_cassandra_view_to_autoscale( # pylint: disable=name-too-long - self, resource_group_name: str, account_name: str, keyspace_name: str, view_name: str, **kwargs: Any - ) -> AsyncLROPoller[_models.ThroughputSettingsGetResults]: - """Migrate an Azure Cosmos DB Cassandra view from manual throughput to autoscale. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param account_name: Cosmos DB database account name. Required. - :type account_name: str - :param keyspace_name: Cosmos DB keyspace name. Required. - :type keyspace_name: str - :param view_name: Cosmos DB view name. Required. - :type view_name: str - :return: An instance of AsyncLROPoller that returns either ThroughputSettingsGetResults or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.ThroughputSettingsGetResults] - :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.ThroughputSettingsGetResults] = 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_cassandra_view_to_autoscale_initial( - resource_group_name=resource_group_name, - account_name=account_name, - keyspace_name=keyspace_name, - view_name=view_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("ThroughputSettingsGetResults", 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, **kwargs)) elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: - return AsyncLROPoller[_models.ThroughputSettingsGetResults].from_continuation_token( + return AsyncLROPoller[_models.CassandraRoleDefinitionResource].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller[_models.ThroughputSettingsGetResults]( + return AsyncLROPoller[_models.CassandraRoleDefinitionResource]( self._client, raw_result, get_long_running_output, polling_method # type: ignore ) - async def _migrate_cassandra_view_to_manual_throughput_initial( # pylint: disable=name-too-long - self, resource_group_name: str, account_name: str, keyspace_name: str, view_name: str, **kwargs: Any + async def _delete_cassandra_role_definition_initial( # pylint: disable=name-too-long + self, resource_group_name: str, account_name: str, role_definition_id: str, **kwargs: Any ) -> AsyncIterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -4087,11 +4216,10 @@ async def _migrate_cassandra_view_to_manual_throughput_initial( # pylint: disab 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_migrate_cassandra_view_to_manual_throughput_request( + _request = build_delete_cassandra_role_definition_request( resource_group_name=resource_group_name, account_name=account_name, - keyspace_name=keyspace_name, - view_name=view_name, + role_definition_id=role_definition_id, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, @@ -4107,20 +4235,24 @@ async def _migrate_cassandra_view_to_manual_throughput_initial( # pylint: disab response = pipeline_response.http_response - if response.status_code not in [200, 202]: + if response.status_code not in [200, 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + 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["azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("azure-AsyncOperation") + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") ) - response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) @@ -4130,40 +4262,35 @@ async def _migrate_cassandra_view_to_manual_throughput_initial( # pylint: disab return deserialized # type: ignore @distributed_trace_async - async def begin_migrate_cassandra_view_to_manual_throughput( # pylint: disable=name-too-long - self, resource_group_name: str, account_name: str, keyspace_name: str, view_name: str, **kwargs: Any - ) -> AsyncLROPoller[_models.ThroughputSettingsGetResults]: - """Migrate an Azure Cosmos DB Cassandra view from autoscale to manual throughput. + async def begin_delete_cassandra_role_definition( + self, resource_group_name: str, account_name: str, role_definition_id: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Deletes an existing Azure Cosmos DB Cassandra Role Definition. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param keyspace_name: Cosmos DB keyspace name. Required. - :type keyspace_name: str - :param view_name: Cosmos DB view name. Required. - :type view_name: str - :return: An instance of AsyncLROPoller that returns either ThroughputSettingsGetResults or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.ThroughputSettingsGetResults] + :param role_definition_id: The GUID for the Role Definition. Required. + :type role_definition_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[_models.ThroughputSettingsGetResults] = kwargs.pop("cls", 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._migrate_cassandra_view_to_manual_throughput_initial( + raw_result = await self._delete_cassandra_role_definition_initial( resource_group_name=resource_group_name, account_name=account_name, - keyspace_name=keyspace_name, - view_name=view_name, + role_definition_id=role_definition_id, api_version=api_version, cls=lambda x, y, z: x, headers=_headers, @@ -4173,25 +4300,23 @@ async def begin_migrate_cassandra_view_to_manual_throughput( # pylint: disable= await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ThroughputSettingsGetResults", pipeline_response.http_response) + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return cls(pipeline_response, None, {}) # type: ignore if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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.ThroughputSettingsGetResults].from_continuation_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[_models.ThroughputSettingsGetResults]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/aio/operations/_chaos_fault_operations.py b/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/aio/operations/_chaos_fault_operations.py index 5ab4fb71e3b..a4d54bc1811 100644 --- a/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/aio/operations/_chaos_fault_operations.py +++ b/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/aio/operations/_chaos_fault_operations.py @@ -147,6 +147,70 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) + @distributed_trace_async + async def get( + self, resource_group_name: str, account_name: str, chaos_fault: str, **kwargs: Any + ) -> _models.ChaosFaultResource: + """Get Chaos Fault for a CosmosdB account for a particular Chaos Fault. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param chaos_fault: The name of the ChaosFault. Required. + :type chaos_fault: str + :return: ChaosFaultResource or the result of cls(response) + :rtype: ~azure.mgmt.cosmosdb.models.ChaosFaultResource + :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.ChaosFaultResource] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + account_name=account_name, + chaos_fault=chaos_fault, + 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("ChaosFaultResource", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + async def _enable_disable_initial( self, resource_group_name: str, @@ -212,10 +276,15 @@ async def _enable_disable_initial( ) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + response_headers = {} + if response.status_code == 201: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @@ -356,67 +425,3 @@ def get_long_running_output(pipeline_response): return AsyncLROPoller[_models.ChaosFaultResource]( self._client, raw_result, get_long_running_output, polling_method # type: ignore ) - - @distributed_trace_async - async def get( - self, resource_group_name: str, account_name: str, chaos_fault: str, **kwargs: Any - ) -> _models.ChaosFaultResource: - """Get Chaos Fault for a CosmosdB account for a particular Chaos Fault. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param account_name: Cosmos DB database account name. Required. - :type account_name: str - :param chaos_fault: The name of the ChaosFault. Required. - :type chaos_fault: str - :return: ChaosFaultResource or the result of cls(response) - :rtype: ~azure.mgmt.cosmosdb.models.ChaosFaultResource - :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.ChaosFaultResource] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - account_name=account_name, - chaos_fault=chaos_fault, - 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("ChaosFaultResource", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/aio/operations/_collection_operations.py b/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/aio/operations/_collection_operations.py index 764abae0deb..3bf485bf883 100644 --- a/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/aio/operations/_collection_operations.py +++ b/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/aio/operations/_collection_operations.py @@ -59,17 +59,10 @@ def __init__(self, *args, **kwargs) -> None: self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def list_metrics( - self, - resource_group_name: str, - account_name: str, - database_rid: str, - collection_rid: str, - filter: str, - **kwargs: Any - ) -> AsyncItemPaged["_models.Metric"]: - """Retrieves the metrics determined by the given filter for the given database account and - collection. + def list_metric_definitions( + self, resource_group_name: str, account_name: str, database_rid: str, collection_rid: str, **kwargs: Any + ) -> AsyncItemPaged["_models.MetricDefinition"]: + """Retrieves metric definitions for the given collection. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -80,19 +73,15 @@ def list_metrics( :type database_rid: str :param collection_rid: Cosmos DB collection rid. Required. :type collection_rid: str - :param filter: An OData filter expression that describes a subset of metrics to return. The - parameters that can be filtered are name.value (name of the metric, can have an or of multiple - names), startTime, endTime, and timeGrain. The supported operator is eq. Required. - :type filter: str - :return: An iterator like instance of either Metric or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.Metric] + :return: An iterator like instance of either MetricDefinition or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.MetricDefinition] :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.MetricListResult] = kwargs.pop("cls", None) + cls: ClsType[_models.MetricDefinitionsListResult] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -105,13 +94,12 @@ def list_metrics( def prepare_request(next_link=None): if not next_link: - _request = build_list_metrics_request( + _request = build_list_metric_definitions_request( resource_group_name=resource_group_name, account_name=account_name, database_rid=database_rid, collection_rid=collection_rid, subscription_id=self._config.subscription_id, - filter=filter, api_version=api_version, headers=_headers, params=_params, @@ -136,11 +124,11 @@ def prepare_request(next_link=None): return _request async def extract_data(pipeline_response): - deserialized = self._deserialize("MetricListResult", pipeline_response) + deserialized = self._deserialize("MetricDefinitionsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore - return None, AsyncList(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): _request = prepare_request(next_link) @@ -153,23 +141,28 @@ 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + 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_usages( + def list_metrics( self, resource_group_name: str, account_name: str, database_rid: str, collection_rid: str, - filter: Optional[str] = None, + filter: str, **kwargs: Any - ) -> AsyncItemPaged["_models.Usage"]: - """Retrieves the usages (most recent storage data) for the given collection. + ) -> AsyncItemPaged["_models.Metric"]: + """Retrieves the metrics determined by the given filter for the given database account and + collection. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -180,19 +173,19 @@ def list_usages( :type database_rid: str :param collection_rid: Cosmos DB collection rid. Required. :type collection_rid: str - :param filter: An OData filter expression that describes a subset of usages to return. The - supported parameter is name.value (name of the metric, can have an or of multiple names). - Default value is None. + :param filter: An OData filter expression that describes a subset of metrics to return. The + parameters that can be filtered are name.value (name of the metric, can have an or of multiple + names), startTime, endTime, and timeGrain. The supported operator is eq. Required. :type filter: str - :return: An iterator like instance of either Usage or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.Usage] + :return: An iterator like instance of either Metric or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.Metric] :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.UsagesResult] = kwargs.pop("cls", None) + cls: ClsType[_models.MetricListResult] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -205,7 +198,7 @@ def list_usages( def prepare_request(next_link=None): if not next_link: - _request = build_list_usages_request( + _request = build_list_metrics_request( resource_group_name=resource_group_name, account_name=account_name, database_rid=database_rid, @@ -236,11 +229,11 @@ def prepare_request(next_link=None): return _request async def extract_data(pipeline_response): - deserialized = self._deserialize("UsagesResult", pipeline_response) + deserialized = self._deserialize("MetricListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore - return None, AsyncList(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): _request = prepare_request(next_link) @@ -253,17 +246,27 @@ 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + 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_metric_definitions( - self, resource_group_name: str, account_name: str, database_rid: str, collection_rid: str, **kwargs: Any - ) -> AsyncItemPaged["_models.MetricDefinition"]: - """Retrieves metric definitions for the given collection. + def list_usages( + self, + resource_group_name: str, + account_name: str, + database_rid: str, + collection_rid: str, + filter: Optional[str] = None, + **kwargs: Any + ) -> AsyncItemPaged["_models.Usage"]: + """Retrieves the usages (most recent storage data) for the given collection. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -274,15 +277,19 @@ def list_metric_definitions( :type database_rid: str :param collection_rid: Cosmos DB collection rid. Required. :type collection_rid: str - :return: An iterator like instance of either MetricDefinition or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.MetricDefinition] + :param filter: An OData filter expression that describes a subset of usages to return. The + supported parameter is name.value (name of the metric, can have an or of multiple names). + Default value is None. + :type filter: str + :return: An iterator like instance of either Usage or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.Usage] :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.MetricDefinitionsListResult] = kwargs.pop("cls", None) + cls: ClsType[_models.UsagesResult] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -295,12 +302,13 @@ def list_metric_definitions( def prepare_request(next_link=None): if not next_link: - _request = build_list_metric_definitions_request( + _request = build_list_usages_request( resource_group_name=resource_group_name, account_name=account_name, database_rid=database_rid, collection_rid=collection_rid, subscription_id=self._config.subscription_id, + filter=filter, api_version=api_version, headers=_headers, params=_params, @@ -325,11 +333,11 @@ def prepare_request(next_link=None): return _request async def extract_data(pipeline_response): - deserialized = self._deserialize("MetricDefinitionsListResult", pipeline_response) + deserialized = self._deserialize("UsagesResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore - return None, AsyncList(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): _request = prepare_request(next_link) @@ -342,7 +350,11 @@ 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response diff --git a/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/aio/operations/_collection_partition_operations.py b/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/aio/operations/_collection_partition_operations.py index 6c08dc32961..9e60e3503cb 100644 --- a/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/aio/operations/_collection_partition_operations.py +++ b/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/aio/operations/_collection_partition_operations.py @@ -136,7 +136,7 @@ async def extract_data(pipeline_response): list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore - return None, AsyncList(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): _request = prepare_request(next_link) @@ -149,7 +149,11 @@ 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response @@ -236,7 +240,7 @@ async def extract_data(pipeline_response): list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore - return None, AsyncList(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): _request = prepare_request(next_link) @@ -249,7 +253,11 @@ 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response diff --git a/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/aio/operations/_collection_partition_region_operations.py b/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/aio/operations/_collection_partition_region_operations.py index 8059feb32a2..ab20242b076 100644 --- a/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/aio/operations/_collection_partition_region_operations.py +++ b/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/aio/operations/_collection_partition_region_operations.py @@ -140,7 +140,7 @@ async def extract_data(pipeline_response): list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore - return None, AsyncList(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): _request = prepare_request(next_link) @@ -153,7 +153,11 @@ 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response diff --git a/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/aio/operations/_collection_region_operations.py b/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/aio/operations/_collection_region_operations.py index a9b71841c6a..ff0313d4638 100644 --- a/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/aio/operations/_collection_region_operations.py +++ b/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/aio/operations/_collection_region_operations.py @@ -140,7 +140,7 @@ async def extract_data(pipeline_response): list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore - return None, AsyncList(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): _request = prepare_request(next_link) @@ -153,7 +153,11 @@ 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response diff --git a/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/aio/operations/_copy_jobs_operations.py b/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/aio/operations/_copy_jobs_operations.py index c52461810f2..4691acd6785 100644 --- a/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/aio/operations/_copy_jobs_operations.py +++ b/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/aio/operations/_copy_jobs_operations.py @@ -64,6 +64,149 @@ def __init__(self, *args, **kwargs) -> None: 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_database_account( + self, resource_group_name: str, account_name: str, **kwargs: Any + ) -> AsyncItemPaged["_models.CopyJobGetResults"]: + """Get a list of Copy jobs. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :return: An iterator like instance of either CopyJobGetResults or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.CopyJobGetResults] + :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.CopyJobFeedResults] = 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_database_account_request( + resource_group_name=resource_group_name, + account_name=account_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("CopyJobFeedResults", 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace_async + async def get( + self, resource_group_name: str, account_name: str, job_name: str, **kwargs: Any + ) -> _models.CopyJobGetResults: + """Get a Copy Job. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param job_name: Name of the Copy Job. Required. + :type job_name: str + :return: CopyJobGetResults or the result of cls(response) + :rtype: ~azure.mgmt.cosmosdb.models.CopyJobGetResults + :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.CopyJobGetResults] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + account_name=account_name, + job_name=job_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("CopyJobGetResults", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + @overload async def create( self, @@ -204,70 +347,10 @@ async def create( return deserialized # type: ignore @distributed_trace_async - async def get( - self, resource_group_name: str, account_name: str, job_name: str, **kwargs: Any - ) -> _models.CopyJobGetResults: - """Get a Copy Job. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param account_name: Cosmos DB database account name. Required. - :type account_name: str - :param job_name: Name of the Copy Job. Required. - :type job_name: str - :return: CopyJobGetResults or the result of cls(response) - :rtype: ~azure.mgmt.cosmosdb.models.CopyJobGetResults - :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.CopyJobGetResults] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - account_name=account_name, - job_name=job_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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("CopyJobGetResults", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def pause( + async def cancel( self, resource_group_name: str, account_name: str, job_name: str, **kwargs: Any ) -> _models.CopyJobGetResults: - """Pause a Copy Job. + """Cancels a Copy Job. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -294,7 +377,7 @@ async def pause( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.CopyJobGetResults] = kwargs.pop("cls", None) - _request = build_pause_request( + _request = build_cancel_request( resource_group_name=resource_group_name, account_name=account_name, job_name=job_name, @@ -324,10 +407,10 @@ async def pause( return deserialized # type: ignore @distributed_trace_async - async def resume( + async def complete( self, resource_group_name: str, account_name: str, job_name: str, **kwargs: Any ) -> _models.CopyJobGetResults: - """Resumes a Copy Job. + """Completes an Online Copy Job. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -354,7 +437,7 @@ async def resume( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.CopyJobGetResults] = kwargs.pop("cls", None) - _request = build_resume_request( + _request = build_complete_request( resource_group_name=resource_group_name, account_name=account_name, job_name=job_name, @@ -384,10 +467,10 @@ async def resume( return deserialized # type: ignore @distributed_trace_async - async def cancel( + async def pause( self, resource_group_name: str, account_name: str, job_name: str, **kwargs: Any ) -> _models.CopyJobGetResults: - """Cancels a Copy Job. + """Pause a Copy Job. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -414,7 +497,7 @@ async def cancel( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.CopyJobGetResults] = kwargs.pop("cls", None) - _request = build_cancel_request( + _request = build_pause_request( resource_group_name=resource_group_name, account_name=account_name, job_name=job_name, @@ -444,10 +527,10 @@ async def cancel( return deserialized # type: ignore @distributed_trace_async - async def complete( + async def resume( self, resource_group_name: str, account_name: str, job_name: str, **kwargs: Any ) -> _models.CopyJobGetResults: - """Completes an Online Copy Job. + """Resumes a Copy Job. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -474,7 +557,7 @@ async def complete( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.CopyJobGetResults] = kwargs.pop("cls", None) - _request = build_complete_request( + _request = build_resume_request( resource_group_name=resource_group_name, account_name=account_name, job_name=job_name, @@ -502,86 +585,3 @@ async def complete( return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - - @distributed_trace - def list_by_database_account( - self, resource_group_name: str, account_name: str, **kwargs: Any - ) -> AsyncItemPaged["_models.CopyJobGetResults"]: - """Get a list of Copy jobs. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param account_name: Cosmos DB database account name. Required. - :type account_name: str - :return: An iterator like instance of either CopyJobGetResults or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.CopyJobGetResults] - :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.CopyJobFeedResults] = 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_database_account_request( - resource_group_name=resource_group_name, - account_name=account_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("CopyJobFeedResults", 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) diff --git a/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/aio/operations/_data_transfer_jobs_operations.py b/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/aio/operations/_data_transfer_jobs_operations.py index 6d861f08914..8ba5b338fd4 100644 --- a/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/aio/operations/_data_transfer_jobs_operations.py +++ b/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/aio/operations/_data_transfer_jobs_operations.py @@ -64,6 +64,151 @@ def __init__(self, *args, **kwargs) -> None: 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_database_account( + self, resource_group_name: str, account_name: str, **kwargs: Any + ) -> AsyncItemPaged["_models.DataTransferJobGetResults"]: + """Get a list of Data Transfer jobs. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :return: An iterator like instance of either DataTransferJobGetResults or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.DataTransferJobGetResults] + :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.DataTransferJobFeedResults] = 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_database_account_request( + resource_group_name=resource_group_name, + account_name=account_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("DataTransferJobFeedResults", 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace_async + async def get( + self, resource_group_name: str, account_name: str, job_name: str, **kwargs: Any + ) -> _models.DataTransferJobGetResults: + """Get a Data Transfer Job. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param job_name: Name of the Data Transfer Job. Required. + :type job_name: str + :return: DataTransferJobGetResults or the result of cls(response) + :rtype: ~azure.mgmt.cosmosdb.models.DataTransferJobGetResults + :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.DataTransferJobGetResults] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + account_name=account_name, + job_name=job_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("DataTransferJobGetResults", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + @overload async def create( self, @@ -204,70 +349,10 @@ async def create( return deserialized # type: ignore @distributed_trace_async - async def get( - self, resource_group_name: str, account_name: str, job_name: str, **kwargs: Any - ) -> _models.DataTransferJobGetResults: - """Get a Data Transfer Job. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param account_name: Cosmos DB database account name. Required. - :type account_name: str - :param job_name: Name of the Data Transfer Job. Required. - :type job_name: str - :return: DataTransferJobGetResults or the result of cls(response) - :rtype: ~azure.mgmt.cosmosdb.models.DataTransferJobGetResults - :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.DataTransferJobGetResults] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - account_name=account_name, - job_name=job_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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("DataTransferJobGetResults", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def pause( + async def cancel( self, resource_group_name: str, account_name: str, job_name: str, **kwargs: Any ) -> _models.DataTransferJobGetResults: - """Pause a Data Transfer Job. + """Cancels a Data Transfer Job. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -294,7 +379,7 @@ async def pause( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.DataTransferJobGetResults] = kwargs.pop("cls", None) - _request = build_pause_request( + _request = build_cancel_request( resource_group_name=resource_group_name, account_name=account_name, job_name=job_name, @@ -324,10 +409,10 @@ async def pause( return deserialized # type: ignore @distributed_trace_async - async def resume( + async def complete( self, resource_group_name: str, account_name: str, job_name: str, **kwargs: Any ) -> _models.DataTransferJobGetResults: - """Resumes a Data Transfer Job. + """Completes a Data Transfer Online Job. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -354,7 +439,7 @@ async def resume( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.DataTransferJobGetResults] = kwargs.pop("cls", None) - _request = build_resume_request( + _request = build_complete_request( resource_group_name=resource_group_name, account_name=account_name, job_name=job_name, @@ -384,10 +469,10 @@ async def resume( return deserialized # type: ignore @distributed_trace_async - async def cancel( + async def pause( self, resource_group_name: str, account_name: str, job_name: str, **kwargs: Any ) -> _models.DataTransferJobGetResults: - """Cancels a Data Transfer Job. + """Pause a Data Transfer Job. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -414,7 +499,7 @@ async def cancel( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.DataTransferJobGetResults] = kwargs.pop("cls", None) - _request = build_cancel_request( + _request = build_pause_request( resource_group_name=resource_group_name, account_name=account_name, job_name=job_name, @@ -444,10 +529,10 @@ async def cancel( return deserialized # type: ignore @distributed_trace_async - async def complete( + async def resume( self, resource_group_name: str, account_name: str, job_name: str, **kwargs: Any ) -> _models.DataTransferJobGetResults: - """Completes a Data Transfer Online Job. + """Resumes a Data Transfer Job. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -474,7 +559,7 @@ async def complete( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.DataTransferJobGetResults] = kwargs.pop("cls", None) - _request = build_complete_request( + _request = build_resume_request( resource_group_name=resource_group_name, account_name=account_name, job_name=job_name, @@ -502,88 +587,3 @@ async def complete( return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - - @distributed_trace - def list_by_database_account( - self, resource_group_name: str, account_name: str, **kwargs: Any - ) -> AsyncItemPaged["_models.DataTransferJobGetResults"]: - """Get a list of Data Transfer jobs. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param account_name: Cosmos DB database account name. Required. - :type account_name: str - :return: An iterator like instance of either DataTransferJobGetResults or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.DataTransferJobGetResults] - :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.DataTransferJobFeedResults] = 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_database_account_request( - resource_group_name=resource_group_name, - account_name=account_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("DataTransferJobFeedResults", 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) diff --git a/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/aio/operations/_database_account_region_operations.py b/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/aio/operations/_database_account_region_operations.py index 7aa17c673b4..ad8aa0a4228 100644 --- a/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/aio/operations/_database_account_region_operations.py +++ b/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/aio/operations/_database_account_region_operations.py @@ -126,7 +126,7 @@ async def extract_data(pipeline_response): list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore - return None, AsyncList(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): _request = prepare_request(next_link) @@ -139,7 +139,11 @@ 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response diff --git a/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/aio/operations/_database_accounts_operations.py b/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/aio/operations/_database_accounts_operations.py index b619668de95..73c7cb1d7cf 100644 --- a/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/aio/operations/_database_accounts_operations.py +++ b/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/aio/operations/_database_accounts_operations.py @@ -80,6 +80,225 @@ def __init__(self, *args, **kwargs) -> None: 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 check_name_exists(self, account_name: str, **kwargs: Any) -> bool: + """Checks that the Azure Cosmos DB account name already exists. A valid account name may contain + only lowercase letters, numbers, and the '-' character, and must be between 3 and 50 + characters. + + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :return: bool or the result of cls(response) + :rtype: bool + :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[None] = kwargs.pop("cls", None) + + _request = build_check_name_exists_request( + account_name=account_name, + 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, 404]: + 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) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + return 200 <= response.status_code <= 299 + + @distributed_trace + def list(self, **kwargs: Any) -> AsyncItemPaged["_models.DatabaseAccountGetResults"]: + """Lists all the Azure Cosmos DB database accounts available under the subscription. + + :return: An iterator like instance of either DatabaseAccountGetResults or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.DatabaseAccountGetResults] + :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.DatabaseAccountsListResult] = 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( + 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("DatabaseAccountsListResult", 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_resource_group( + self, resource_group_name: str, **kwargs: Any + ) -> AsyncItemPaged["_models.DatabaseAccountGetResults"]: + """Lists all the Azure Cosmos DB database accounts available under the given 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 DatabaseAccountGetResults or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.DatabaseAccountGetResults] + :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.DatabaseAccountsListResult] = 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("DatabaseAccountsListResult", 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, account_name: str, **kwargs: Any @@ -128,7 +347,11 @@ async def get( if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("DatabaseAccountGetResults", pipeline_response.http_response) @@ -137,11 +360,11 @@ async def get( return deserialized # type: ignore - async def _update_initial( + async def _create_or_update_initial( self, resource_group_name: str, account_name: str, - update_parameters: Union[_models.DatabaseAccountUpdateParameters, IO[bytes]], + create_update_parameters: Union[_models.DatabaseAccountCreateUpdateParameters, IO[bytes]], **kwargs: Any ) -> AsyncIterator[bytes]: error_map: MutableMapping = { @@ -162,12 +385,12 @@ async def _update_initial( content_type = content_type or "application/json" _json = None _content = None - if isinstance(update_parameters, (IOBase, bytes)): - _content = update_parameters + if isinstance(create_update_parameters, (IOBase, bytes)): + _content = create_update_parameters else: - _json = self._serialize.body(update_parameters, "DatabaseAccountUpdateParameters") + _json = self._serialize.body(create_update_parameters, "DatabaseAccountCreateUpdateParameters") - _request = build_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -194,34 +417,44 @@ async def _update_initial( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + 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")) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @overload - async def begin_update( + async def begin_create_or_update( self, resource_group_name: str, account_name: str, - update_parameters: _models.DatabaseAccountUpdateParameters, + create_update_parameters: _models.DatabaseAccountCreateUpdateParameters, *, content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[_models.DatabaseAccountGetResults]: - """Updates the properties of an existing Azure Cosmos DB database account. + """Creates or updates an Azure Cosmos DB database account. The "Update" method is preferred when + performing updates on an account. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param update_parameters: The parameters to provide for the current database account. Required. - :type update_parameters: ~azure.mgmt.cosmosdb.models.DatabaseAccountUpdateParameters + :param create_update_parameters: The parameters to provide for the current database account. + Required. + :type create_update_parameters: + ~azure.mgmt.cosmosdb.models.DatabaseAccountCreateUpdateParameters :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str @@ -233,26 +466,28 @@ async def begin_update( """ @overload - async def begin_update( + async def begin_create_or_update( self, resource_group_name: str, account_name: str, - update_parameters: IO[bytes], + create_update_parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[_models.DatabaseAccountGetResults]: - """Updates the properties of an existing Azure Cosmos DB database account. + """Creates or updates an Azure Cosmos DB database account. The "Update" method is preferred when + performing updates on an account. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param update_parameters: The parameters to provide for the current database account. Required. - :type update_parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". + :param create_update_parameters: The parameters to provide for the current database account. + Required. + :type create_update_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 DatabaseAccountGetResults or the result of cls(response) @@ -262,24 +497,25 @@ async def begin_update( """ @distributed_trace_async - async def begin_update( + async def begin_create_or_update( self, resource_group_name: str, account_name: str, - update_parameters: Union[_models.DatabaseAccountUpdateParameters, IO[bytes]], + create_update_parameters: Union[_models.DatabaseAccountCreateUpdateParameters, IO[bytes]], **kwargs: Any ) -> AsyncLROPoller[_models.DatabaseAccountGetResults]: - """Updates the properties of an existing Azure Cosmos DB database account. + """Creates or updates an Azure Cosmos DB database account. The "Update" method is preferred when + performing updates on an account. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param update_parameters: The parameters to provide for the current database account. Is either - a DatabaseAccountUpdateParameters type or a IO[bytes] type. Required. - :type update_parameters: ~azure.mgmt.cosmosdb.models.DatabaseAccountUpdateParameters or - IO[bytes] + :param create_update_parameters: The parameters to provide for the current database account. Is + either a DatabaseAccountCreateUpdateParameters type or a IO[bytes] type. Required. + :type create_update_parameters: + ~azure.mgmt.cosmosdb.models.DatabaseAccountCreateUpdateParameters or IO[bytes] :return: An instance of AsyncLROPoller that returns either DatabaseAccountGetResults or the result of cls(response) :rtype: @@ -296,10 +532,10 @@ async def begin_update( 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( + raw_result = await self._create_or_update_initial( resource_group_name=resource_group_name, account_name=account_name, - update_parameters=update_parameters, + create_update_parameters=create_update_parameters, api_version=api_version, content_type=content_type, cls=lambda x, y, z: x, @@ -311,13 +547,19 @@ async def begin_update( kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): + response_headers = {} + response = pipeline_response.http_response + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + deserialized = self._deserialize("DatabaseAccountGetResults", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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: @@ -333,11 +575,11 @@ def get_long_running_output(pipeline_response): self._client, raw_result, get_long_running_output, polling_method # type: ignore ) - async def _create_or_update_initial( + async def _update_initial( self, resource_group_name: str, account_name: str, - create_update_parameters: Union[_models.DatabaseAccountCreateUpdateParameters, IO[bytes]], + update_parameters: Union[_models.DatabaseAccountUpdateParameters, IO[bytes]], **kwargs: Any ) -> AsyncIterator[bytes]: error_map: MutableMapping = { @@ -358,12 +600,12 @@ async def _create_or_update_initial( content_type = content_type or "application/json" _json = None _content = None - if isinstance(create_update_parameters, (IOBase, bytes)): - _content = create_update_parameters + if isinstance(update_parameters, (IOBase, bytes)): + _content = update_parameters else: - _json = self._serialize.body(create_update_parameters, "DatabaseAccountCreateUpdateParameters") + _json = self._serialize.body(update_parameters, "DatabaseAccountUpdateParameters") - _request = build_create_or_update_request( + _request = build_update_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -390,37 +632,41 @@ async def _create_or_update_initial( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + 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")) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @overload - async def begin_create_or_update( + async def begin_update( self, resource_group_name: str, account_name: str, - create_update_parameters: _models.DatabaseAccountCreateUpdateParameters, + update_parameters: _models.DatabaseAccountUpdateParameters, *, content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[_models.DatabaseAccountGetResults]: - """Creates or updates an Azure Cosmos DB database account. The "Update" method is preferred when - performing updates on an account. + """Updates the properties of an existing Azure Cosmos DB database account. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param create_update_parameters: The parameters to provide for the current database account. - Required. - :type create_update_parameters: - ~azure.mgmt.cosmosdb.models.DatabaseAccountCreateUpdateParameters + :param update_parameters: The parameters to provide for the current database account. Required. + :type update_parameters: ~azure.mgmt.cosmosdb.models.DatabaseAccountUpdateParameters :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str @@ -432,26 +678,24 @@ async def begin_create_or_update( """ @overload - async def begin_create_or_update( + async def begin_update( self, resource_group_name: str, account_name: str, - create_update_parameters: IO[bytes], + update_parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[_models.DatabaseAccountGetResults]: - """Creates or updates an Azure Cosmos DB database account. The "Update" method is preferred when - performing updates on an account. + """Updates the properties of an existing Azure Cosmos DB database account. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param create_update_parameters: The parameters to provide for the current database account. - Required. - :type create_update_parameters: IO[bytes] + :param update_parameters: The parameters to provide for the current database account. Required. + :type update_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 @@ -463,25 +707,24 @@ async def begin_create_or_update( """ @distributed_trace_async - async def begin_create_or_update( + async def begin_update( self, resource_group_name: str, account_name: str, - create_update_parameters: Union[_models.DatabaseAccountCreateUpdateParameters, IO[bytes]], + update_parameters: Union[_models.DatabaseAccountUpdateParameters, IO[bytes]], **kwargs: Any ) -> AsyncLROPoller[_models.DatabaseAccountGetResults]: - """Creates or updates an Azure Cosmos DB database account. The "Update" method is preferred when - performing updates on an account. + """Updates the properties of an existing Azure Cosmos DB database account. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param create_update_parameters: The parameters to provide for the current database account. Is - either a DatabaseAccountCreateUpdateParameters type or a IO[bytes] type. Required. - :type create_update_parameters: - ~azure.mgmt.cosmosdb.models.DatabaseAccountCreateUpdateParameters or IO[bytes] + :param update_parameters: The parameters to provide for the current database account. Is either + a DatabaseAccountUpdateParameters type or a IO[bytes] type. Required. + :type update_parameters: ~azure.mgmt.cosmosdb.models.DatabaseAccountUpdateParameters or + IO[bytes] :return: An instance of AsyncLROPoller that returns either DatabaseAccountGetResults or the result of cls(response) :rtype: @@ -498,10 +741,10 @@ async def begin_create_or_update( 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( + raw_result = await self._update_initial( resource_group_name=resource_group_name, account_name=account_name, - create_update_parameters=create_update_parameters, + update_parameters=update_parameters, api_version=api_version, content_type=content_type, cls=lambda x, y, z: x, @@ -513,13 +756,19 @@ async def begin_create_or_update( kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): + response_headers = {} + response = pipeline_response.http_response + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + deserialized = self._deserialize("DatabaseAccountGetResults", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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: @@ -574,14 +823,18 @@ async def _delete_initial(self, resource_group_name: str, account_name: str, **k except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + 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["azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("azure-AsyncOperation") + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") ) - response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) @@ -629,7 +882,9 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- return cls(pipeline_response, None, {}) # type: ignore if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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: @@ -700,14 +955,19 @@ async def _failover_priority_change_initial( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + 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["azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("azure-AsyncOperation") + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") ) - response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) @@ -830,7 +1090,9 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- return cls(pipeline_response, None, {}) # type: ignore if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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: @@ -844,22 +1106,82 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- ) return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - @distributed_trace - def list(self, **kwargs: Any) -> AsyncItemPaged["_models.DatabaseAccountGetResults"]: - """Lists all the Azure Cosmos DB database accounts available under the subscription. + @distributed_trace_async + async def list_connection_strings( + self, resource_group_name: str, account_name: str, **kwargs: Any + ) -> _models.DatabaseAccountListConnectionStringsResult: + """Lists the connection strings for the specified Azure Cosmos DB database account. - :return: An iterator like instance of either DatabaseAccountGetResults or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.DatabaseAccountGetResults] + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :return: DatabaseAccountListConnectionStringsResult or the result of cls(response) + :rtype: ~azure.mgmt.cosmosdb.models.DatabaseAccountListConnectionStringsResult :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.DatabaseAccountsListResult] = kwargs.pop("cls", None) + cls: ClsType[_models.DatabaseAccountListConnectionStringsResult] = kwargs.pop("cls", None) + + _request = build_list_connection_strings_request( + resource_group_name=resource_group_name, + account_name=account_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("DatabaseAccountListConnectionStringsResult", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def list_keys( + self, resource_group_name: str, account_name: str, **kwargs: Any + ) -> _models.DatabaseAccountListKeysResult: + """Lists the access keys for the specified Azure Cosmos DB database account. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :return: DatabaseAccountListKeysResult or the result of cls(response) + :rtype: ~azure.mgmt.cosmosdb.models.DatabaseAccountListKeysResult + :raises ~azure.core.exceptions.HttpResponseError: + """ error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -868,78 +1190,64 @@ def list(self, **kwargs: Any) -> AsyncItemPaged["_models.DatabaseAccountGetResul } error_map.update(kwargs.pop("error_map", {}) or {}) - def prepare_request(next_link=None): - if not next_link: + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.DatabaseAccountListKeysResult] = kwargs.pop("cls", None) - 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 + _request = build_list_keys_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) - async def extract_data(pipeline_response): - deserialized = self._deserialize("DatabaseAccountsListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return None, AsyncList(list_of_elem) + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) - async def get_next(next_link=None): - _request = prepare_request(next_link) + response = pipeline_response.http_response - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs + 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, ) - response = pipeline_response.http_response + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + deserialized = self._deserialize("DatabaseAccountListKeysResult", pipeline_response.http_response) - return pipeline_response + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore - return AsyncItemPaged(get_next, extract_data) + return deserialized # type: ignore @distributed_trace - def list_by_resource_group( - self, resource_group_name: str, **kwargs: Any - ) -> AsyncItemPaged["_models.DatabaseAccountGetResults"]: - """Lists all the Azure Cosmos DB database accounts available under the given resource group. + def list_metric_definitions( + self, resource_group_name: str, account_name: str, **kwargs: Any + ) -> AsyncItemPaged["_models.MetricDefinition"]: + """Retrieves metric definitions for the given database account. :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 DatabaseAccountGetResults or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.DatabaseAccountGetResults] + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :return: An iterator like instance of either MetricDefinition or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.MetricDefinition] :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.DatabaseAccountsListResult] = kwargs.pop("cls", None) + cls: ClsType[_models.MetricDefinitionsListResult] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -952,8 +1260,9 @@ def list_by_resource_group( def prepare_request(next_link=None): if not next_link: - _request = build_list_by_resource_group_request( + _request = build_list_metric_definitions_request( resource_group_name=resource_group_name, + account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, @@ -979,11 +1288,11 @@ def prepare_request(next_link=None): return _request async def extract_data(pipeline_response): - deserialized = self._deserialize("DatabaseAccountsListResult", pipeline_response) + deserialized = self._deserialize("MetricDefinitionsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore - return None, AsyncList(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): _request = prepare_request(next_link) @@ -996,84 +1305,41 @@ 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + 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 list_keys( - self, resource_group_name: str, account_name: str, **kwargs: Any - ) -> _models.DatabaseAccountListKeysResult: - """Lists the access keys for the specified Azure Cosmos DB database account. + @distributed_trace + def list_metrics( + self, resource_group_name: str, account_name: str, filter: str, **kwargs: Any + ) -> AsyncItemPaged["_models.Metric"]: + """Retrieves the metrics determined by the given filter for the given database account. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param account_name: Cosmos DB database account name. Required. :type account_name: str - :return: DatabaseAccountListKeysResult or the result of cls(response) - :rtype: ~azure.mgmt.cosmosdb.models.DatabaseAccountListKeysResult + :param filter: An OData filter expression that describes a subset of metrics to return. The + parameters that can be filtered are name.value (name of the metric, can have an or of multiple + names), startTime, endTime, and timeGrain. The supported operator is eq. Required. + :type filter: str + :return: An iterator like instance of either Metric or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.Metric] :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.DatabaseAccountListKeysResult] = kwargs.pop("cls", None) - - _request = build_list_keys_request( - resource_group_name=resource_group_name, - account_name=account_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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("DatabaseAccountListKeysResult", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def list_connection_strings( - self, resource_group_name: str, account_name: str, **kwargs: Any - ) -> _models.DatabaseAccountListConnectionStringsResult: - """Lists the connection strings for the specified Azure Cosmos DB database account. + cls: ClsType[_models.MetricListResult] = kwargs.pop("cls", None) - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param account_name: Cosmos DB database account name. Required. - :type account_name: str - :return: DatabaseAccountListConnectionStringsResult or the result of cls(response) - :rtype: ~azure.mgmt.cosmosdb.models.DatabaseAccountListConnectionStringsResult - :raises ~azure.core.exceptions.HttpResponseError: - """ error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -1082,39 +1348,64 @@ async def list_connection_strings( } 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.DatabaseAccountListConnectionStringsResult] = kwargs.pop("cls", None) + def prepare_request(next_link=None): + if not next_link: - _request = build_list_connection_strings_request( - resource_group_name=resource_group_name, - account_name=account_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) + _request = build_list_metrics_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + filter=filter, + 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 - ) + 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 - response = pipeline_response.http_response + async def extract_data(pipeline_response): + deserialized = self._deserialize("MetricListResult", 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) - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + async def get_next(next_link=None): + _request = prepare_request(next_link) - deserialized = self._deserialize("DatabaseAccountListConnectionStringsResult", pipeline_response.http_response) + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + 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 deserialized # type: ignore + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) async def _offline_region_initial( self, @@ -1174,17 +1465,18 @@ async def _offline_region_initial( pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize( - _models.ErrorResponseAutoGenerated2, + _models.ErrorResponse, pipeline_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["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") ) - response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) @@ -1301,7 +1593,9 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- return cls(pipeline_response, None, {}) # type: ignore if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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: @@ -1373,17 +1667,18 @@ async def _online_region_initial( pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize( - _models.ErrorResponseAutoGenerated2, + _models.ErrorResponse, pipeline_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["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") ) - response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) @@ -1500,7 +1795,9 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- return cls(pipeline_response, None, {}) # type: ignore if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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: @@ -1562,7 +1859,11 @@ async def get_read_only_keys( if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("DatabaseAccountListReadOnlyKeysResult", pipeline_response.http_response) @@ -1619,7 +1920,11 @@ async def list_read_only_keys( if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("DatabaseAccountListReadOnlyKeysResult", pipeline_response.http_response) @@ -1685,14 +1990,19 @@ async def _regenerate_key_initial( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + 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["azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("azure-AsyncOperation") + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") ) - response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) @@ -1807,7 +2117,9 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- return cls(pipeline_response, None, {}) # type: ignore if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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: @@ -1821,143 +2133,6 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- ) return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - @distributed_trace_async - async def check_name_exists(self, account_name: str, **kwargs: Any) -> bool: - """Checks that the Azure Cosmos DB account name already exists. A valid account name may contain - only lowercase letters, numbers, and the '-' character, and must be between 3 and 50 - characters. - - :param account_name: Cosmos DB database account name. Required. - :type account_name: str - :return: bool or the result of cls(response) - :rtype: bool - :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[None] = kwargs.pop("cls", None) - - _request = build_check_name_exists_request( - account_name=account_name, - 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, 404]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) # type: ignore - return 200 <= response.status_code <= 299 - - @distributed_trace - def list_metrics( - self, resource_group_name: str, account_name: str, filter: str, **kwargs: Any - ) -> AsyncItemPaged["_models.Metric"]: - """Retrieves the metrics determined by the given filter for the given database account. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param account_name: Cosmos DB database account name. Required. - :type account_name: str - :param filter: An OData filter expression that describes a subset of metrics to return. The - parameters that can be filtered are name.value (name of the metric, can have an or of multiple - names), startTime, endTime, and timeGrain. The supported operator is eq. Required. - :type filter: str - :return: An iterator like instance of either Metric or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.Metric] - :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.MetricListResult] = 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_metrics_request( - resource_group_name=resource_group_name, - account_name=account_name, - subscription_id=self._config.subscription_id, - filter=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("MetricListResult", 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - @distributed_trace def list_usages( self, resource_group_name: str, account_name: str, filter: Optional[str] = None, **kwargs: Any @@ -2027,7 +2202,7 @@ async def extract_data(pipeline_response): list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore - return None, AsyncList(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): _request = prepare_request(next_link) @@ -2040,90 +2215,11 @@ 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace - def list_metric_definitions( - self, resource_group_name: str, account_name: str, **kwargs: Any - ) -> AsyncItemPaged["_models.MetricDefinition"]: - """Retrieves metric definitions for the given database account. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param account_name: Cosmos DB database account name. Required. - :type account_name: str - :return: An iterator like instance of either MetricDefinition or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.MetricDefinition] - :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.MetricDefinitionsListResult] = 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_metric_definitions_request( - resource_group_name=resource_group_name, - account_name=account_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 + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("MetricDefinitionsListResult", 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response diff --git a/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/aio/operations/_database_operations.py b/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/aio/operations/_database_operations.py index cf6ad88f8ae..99b3b2fbd97 100644 --- a/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/aio/operations/_database_operations.py +++ b/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/aio/operations/_database_operations.py @@ -59,11 +59,10 @@ def __init__(self, *args, **kwargs) -> None: self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def list_metrics( - self, resource_group_name: str, account_name: str, database_rid: str, filter: str, **kwargs: Any - ) -> AsyncItemPaged["_models.Metric"]: - """Retrieves the metrics determined by the given filter for the given database account and - database. + def list_metric_definitions( + self, resource_group_name: str, account_name: str, database_rid: str, **kwargs: Any + ) -> AsyncItemPaged["_models.MetricDefinition"]: + """Retrieves metric definitions for the given database. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -72,19 +71,15 @@ def list_metrics( :type account_name: str :param database_rid: Cosmos DB database rid. Required. :type database_rid: str - :param filter: An OData filter expression that describes a subset of metrics to return. The - parameters that can be filtered are name.value (name of the metric, can have an or of multiple - names), startTime, endTime, and timeGrain. The supported operator is eq. Required. - :type filter: str - :return: An iterator like instance of either Metric or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.Metric] + :return: An iterator like instance of either MetricDefinition or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.MetricDefinition] :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.MetricListResult] = kwargs.pop("cls", None) + cls: ClsType[_models.MetricDefinitionsListResult] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -97,12 +92,11 @@ def list_metrics( def prepare_request(next_link=None): if not next_link: - _request = build_list_metrics_request( + _request = build_list_metric_definitions_request( resource_group_name=resource_group_name, account_name=account_name, database_rid=database_rid, subscription_id=self._config.subscription_id, - filter=filter, api_version=api_version, headers=_headers, params=_params, @@ -127,11 +121,11 @@ def prepare_request(next_link=None): return _request async def extract_data(pipeline_response): - deserialized = self._deserialize("MetricListResult", pipeline_response) + deserialized = self._deserialize("MetricDefinitionsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore - return None, AsyncList(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): _request = prepare_request(next_link) @@ -144,22 +138,22 @@ 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + 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_usages( - self, - resource_group_name: str, - account_name: str, - database_rid: str, - filter: Optional[str] = None, - **kwargs: Any - ) -> AsyncItemPaged["_models.Usage"]: - """Retrieves the usages (most recent data) for the given database. + def list_metrics( + self, resource_group_name: str, account_name: str, database_rid: str, filter: str, **kwargs: Any + ) -> AsyncItemPaged["_models.Metric"]: + """Retrieves the metrics determined by the given filter for the given database account and + database. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -168,19 +162,19 @@ def list_usages( :type account_name: str :param database_rid: Cosmos DB database rid. Required. :type database_rid: str - :param filter: An OData filter expression that describes a subset of usages to return. The - supported parameter is name.value (name of the metric, can have an or of multiple names). - Default value is None. + :param filter: An OData filter expression that describes a subset of metrics to return. The + parameters that can be filtered are name.value (name of the metric, can have an or of multiple + names), startTime, endTime, and timeGrain. The supported operator is eq. Required. :type filter: str - :return: An iterator like instance of either Usage or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.Usage] + :return: An iterator like instance of either Metric or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.Metric] :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.UsagesResult] = kwargs.pop("cls", None) + cls: ClsType[_models.MetricListResult] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -193,7 +187,7 @@ def list_usages( def prepare_request(next_link=None): if not next_link: - _request = build_list_usages_request( + _request = build_list_metrics_request( resource_group_name=resource_group_name, account_name=account_name, database_rid=database_rid, @@ -223,11 +217,11 @@ def prepare_request(next_link=None): return _request async def extract_data(pipeline_response): - deserialized = self._deserialize("UsagesResult", pipeline_response) + deserialized = self._deserialize("MetricListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore - return None, AsyncList(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): _request = prepare_request(next_link) @@ -240,17 +234,26 @@ 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + 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_metric_definitions( - self, resource_group_name: str, account_name: str, database_rid: str, **kwargs: Any - ) -> AsyncItemPaged["_models.MetricDefinition"]: - """Retrieves metric definitions for the given database. + def list_usages( + self, + resource_group_name: str, + account_name: str, + database_rid: str, + filter: Optional[str] = None, + **kwargs: Any + ) -> AsyncItemPaged["_models.Usage"]: + """Retrieves the usages (most recent data) for the given database. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -259,15 +262,19 @@ def list_metric_definitions( :type account_name: str :param database_rid: Cosmos DB database rid. Required. :type database_rid: str - :return: An iterator like instance of either MetricDefinition or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.MetricDefinition] + :param filter: An OData filter expression that describes a subset of usages to return. The + supported parameter is name.value (name of the metric, can have an or of multiple names). + Default value is None. + :type filter: str + :return: An iterator like instance of either Usage or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.Usage] :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.MetricDefinitionsListResult] = kwargs.pop("cls", None) + cls: ClsType[_models.UsagesResult] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -280,11 +287,12 @@ def list_metric_definitions( def prepare_request(next_link=None): if not next_link: - _request = build_list_metric_definitions_request( + _request = build_list_usages_request( resource_group_name=resource_group_name, account_name=account_name, database_rid=database_rid, subscription_id=self._config.subscription_id, + filter=filter, api_version=api_version, headers=_headers, params=_params, @@ -309,11 +317,11 @@ def prepare_request(next_link=None): return _request async def extract_data(pipeline_response): - deserialized = self._deserialize("MetricDefinitionsListResult", pipeline_response) + deserialized = self._deserialize("UsagesResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore - return None, AsyncList(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): _request = prepare_request(next_link) @@ -326,7 +334,11 @@ 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response diff --git a/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/aio/operations/_fleet_analytics_operations.py b/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/aio/operations/_fleet_analytics_operations.py index 6976e89c015..e765ae7724b 100644 --- a/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/aio/operations/_fleet_analytics_operations.py +++ b/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/aio/operations/_fleet_analytics_operations.py @@ -145,7 +145,7 @@ 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( - _models.ErrorResponseAutoGenerated, + _models.ErrorResponse, pipeline_response, ) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -206,7 +206,7 @@ async def get( 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.ErrorResponseAutoGenerated, + _models.ErrorResponse, pipeline_response, ) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -350,7 +350,7 @@ async def create( 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.ErrorResponseAutoGenerated, + _models.ErrorResponse, pipeline_response, ) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -405,17 +405,18 @@ async def _delete_initial( pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize( - _models.ErrorResponseAutoGenerated, + _models.ErrorResponse, pipeline_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["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") ) - response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) diff --git a/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/aio/operations/_fleet_operations.py b/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/aio/operations/_fleet_operations.py index 26dab64f648..fdde0762d5c 100644 --- a/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/aio/operations/_fleet_operations.py +++ b/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/aio/operations/_fleet_operations.py @@ -136,7 +136,7 @@ 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( - _models.ErrorResponseAutoGenerated, + _models.ErrorResponse, pipeline_response, ) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -220,7 +220,7 @@ 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( - _models.ErrorResponseAutoGenerated, + _models.ErrorResponse, pipeline_response, ) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -276,7 +276,7 @@ async def get(self, resource_group_name: str, fleet_name: str, **kwargs: Any) -> 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.ErrorResponseAutoGenerated, + _models.ErrorResponse, pipeline_response, ) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -406,7 +406,7 @@ async def create( 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.ErrorResponseAutoGenerated, + _models.ErrorResponse, pipeline_response, ) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -544,7 +544,7 @@ async def update( 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.ErrorResponseAutoGenerated, + _models.ErrorResponse, pipeline_response, ) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -596,17 +596,18 @@ async def _delete_initial(self, resource_group_name: str, fleet_name: str, **kwa pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize( - _models.ErrorResponseAutoGenerated, + _models.ErrorResponse, pipeline_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["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") ) - response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) diff --git a/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/aio/operations/_fleetspace_account_operations.py b/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/aio/operations/_fleetspace_account_operations.py index 2ce2e94580b..daa3f4f6e5c 100644 --- a/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/aio/operations/_fleetspace_account_operations.py +++ b/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/aio/operations/_fleetspace_account_operations.py @@ -148,7 +148,7 @@ 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( - _models.ErrorResponseAutoGenerated, + _models.ErrorResponse, pipeline_response, ) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -217,7 +217,7 @@ async def get( 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.ErrorResponseAutoGenerated, + _models.ErrorResponse, pipeline_response, ) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -291,15 +291,22 @@ async def _create_initial( pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize( - _models.ErrorResponseAutoGenerated, + _models.ErrorResponse, pipeline_response, ) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + response_headers = {} + if response.status_code == 201: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @@ -504,17 +511,18 @@ async def _delete_initial( pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize( - _models.ErrorResponseAutoGenerated, + _models.ErrorResponse, pipeline_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["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") ) - response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) diff --git a/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/aio/operations/_fleetspace_operations.py b/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/aio/operations/_fleetspace_operations.py index 5e78841a44a..468aa5f7f3c 100644 --- a/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/aio/operations/_fleetspace_operations.py +++ b/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/aio/operations/_fleetspace_operations.py @@ -144,7 +144,7 @@ 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( - _models.ErrorResponseAutoGenerated, + _models.ErrorResponse, pipeline_response, ) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -205,7 +205,7 @@ async def get( 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.ErrorResponseAutoGenerated, + _models.ErrorResponse, pipeline_response, ) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -277,15 +277,22 @@ async def _create_initial( pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize( - _models.ErrorResponseAutoGenerated, + _models.ErrorResponse, pipeline_response, ) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + response_headers = {} + if response.status_code == 201: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @@ -492,17 +499,18 @@ async def _update_initial( pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize( - _models.ErrorResponseAutoGenerated, + _models.ErrorResponse, pipeline_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["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") ) - response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) @@ -694,17 +702,18 @@ async def _delete_initial( pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize( - _models.ErrorResponseAutoGenerated, + _models.ErrorResponse, pipeline_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["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") ) - response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) diff --git a/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/aio/operations/_garnet_clusters_operations.py b/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/aio/operations/_garnet_clusters_operations.py index 7cc20c45f55..1c37f98bd11 100644 --- a/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/aio/operations/_garnet_clusters_operations.py +++ b/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/aio/operations/_garnet_clusters_operations.py @@ -124,7 +124,7 @@ async def extract_data(pipeline_response): list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore - return None, AsyncList(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): _request = prepare_request(next_link) @@ -138,7 +138,7 @@ 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( - _models.ErrorResponseAutoGenerated, + _models.ErrorResponse, pipeline_response, ) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -210,7 +210,7 @@ async def extract_data(pipeline_response): list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore - return None, AsyncList(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): _request = prepare_request(next_link) @@ -224,7 +224,7 @@ 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( - _models.ErrorResponseAutoGenerated, + _models.ErrorResponse, pipeline_response, ) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -240,7 +240,7 @@ async def get(self, resource_group_name: str, cluster_name: str, **kwargs: Any) :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str - :param cluster_name: Garnet cache cluster name. Required. + :param cluster_name: The name of the GarnetClusterResource. Required. :type cluster_name: str :return: GarnetClusterResource or the result of cls(response) :rtype: ~azure.mgmt.cosmosdb.models.GarnetClusterResource @@ -280,7 +280,7 @@ async def get(self, resource_group_name: str, cluster_name: str, **kwargs: Any) 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.ErrorResponseAutoGenerated, + _models.ErrorResponse, pipeline_response, ) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -292,118 +292,6 @@ async def get(self, resource_group_name: str, cluster_name: str, **kwargs: Any) return deserialized # type: ignore - async def _delete_initial(self, resource_group_name: str, cluster_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, - cluster_name=cluster_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.ErrorResponseAutoGenerated, - pipeline_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")) - - 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, cluster_name: str, **kwargs: Any) -> AsyncLROPoller[None]: - """Deletes a Garnet cluster. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param cluster_name: Garnet cache cluster name. Required. - :type cluster_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, - cluster_name=cluster_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, **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 _create_update_initial( self, resource_group_name: str, @@ -462,15 +350,20 @@ async def _create_update_initial( pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize( - _models.ErrorResponseAutoGenerated, + _models.ErrorResponse, pipeline_response, ) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + response_headers = {} + if response.status_code == 201: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @@ -490,9 +383,9 @@ async def begin_create_update( :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str - :param cluster_name: Garnet cache cluster name. Required. + :param cluster_name: The name of the GarnetClusterResource. Required. :type cluster_name: str - :param body: The properties specifying the desired state of the Garnet cache cluster. Required. + :param body: Resource create parameters. Required. :type body: ~azure.mgmt.cosmosdb.models.GarnetClusterResource :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". @@ -519,9 +412,9 @@ async def begin_create_update( :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str - :param cluster_name: Garnet cache cluster name. Required. + :param cluster_name: The name of the GarnetClusterResource. Required. :type cluster_name: str - :param body: The properties specifying the desired state of the Garnet cache cluster. Required. + :param body: Resource create parameters. Required. :type body: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". @@ -546,10 +439,10 @@ async def begin_create_update( :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str - :param cluster_name: Garnet cache cluster name. Required. + :param cluster_name: The name of the GarnetClusterResource. Required. :type cluster_name: str - :param body: The properties specifying the desired state of the Garnet cache cluster. Is either - a GarnetClusterResource type or a IO[bytes] type. Required. + :param body: Resource create parameters. Is either a GarnetClusterResource type or a IO[bytes] + type. Required. :type body: ~azure.mgmt.cosmosdb.models.GarnetClusterResource or IO[bytes] :return: An instance of AsyncLROPoller that returns either GarnetClusterResource or the result of cls(response) @@ -587,7 +480,9 @@ def get_long_running_output(pipeline_response): return deserialized if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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: @@ -661,17 +556,18 @@ async def _update_initial( pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize( - _models.ErrorResponseAutoGenerated, + _models.ErrorResponse, pipeline_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["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") ) - response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) @@ -695,9 +591,9 @@ async def begin_update( :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str - :param cluster_name: Garnet cache cluster name. Required. + :param cluster_name: The name of the GarnetClusterResource. Required. :type cluster_name: str - :param body: Parameters to provide for updating the Garnet cluster. Required. + :param body: The resource properties to be updated. Required. :type body: ~azure.mgmt.cosmosdb.models.GarnetClusterResourcePatch :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". @@ -723,9 +619,9 @@ async def begin_update( :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str - :param cluster_name: Garnet cache cluster name. Required. + :param cluster_name: The name of the GarnetClusterResource. Required. :type cluster_name: str - :param body: Parameters to provide for updating the Garnet cluster. Required. + :param body: The resource properties to be updated. Required. :type body: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". @@ -749,10 +645,10 @@ async def begin_update( :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str - :param cluster_name: Garnet cache cluster name. Required. + :param cluster_name: The name of the GarnetClusterResource. Required. :type cluster_name: str - :param body: Parameters to provide for updating the Garnet cluster. Is either a - GarnetClusterResourcePatch type or a IO[bytes] type. Required. + :param body: The resource properties to be updated. Is either a GarnetClusterResourcePatch type + or a IO[bytes] type. Required. :type body: ~azure.mgmt.cosmosdb.models.GarnetClusterResourcePatch or IO[bytes] :return: An instance of AsyncLROPoller that returns either GarnetClusterResource or the result of cls(response) @@ -790,7 +686,9 @@ def get_long_running_output(pipeline_response): return deserialized if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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: @@ -805,3 +703,118 @@ def get_long_running_output(pipeline_response): return AsyncLROPoller[_models.GarnetClusterResource]( self._client, raw_result, get_long_running_output, polling_method # type: ignore ) + + async def _delete_initial(self, resource_group_name: str, cluster_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, + cluster_name=cluster_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["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.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, cluster_name: str, **kwargs: Any) -> AsyncLROPoller[None]: + """Deletes a Garnet cluster. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_name: The name of the GarnetClusterResource. Required. + :type cluster_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, + cluster_name=cluster_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/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/aio/operations/_graph_resources_operations.py b/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/aio/operations/_graph_resources_operations.py index 811ed1ae43f..157fe8df5eb 100644 --- a/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/aio/operations/_graph_resources_operations.py +++ b/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/aio/operations/_graph_resources_operations.py @@ -131,7 +131,7 @@ async def extract_data(pipeline_response): list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore - return None, AsyncList(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): _request = prepare_request(next_link) @@ -144,7 +144,11 @@ 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response @@ -202,7 +206,11 @@ async def get_graph( if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("GraphResourceGetResults", pipeline_response.http_response) @@ -270,14 +278,19 @@ async def _create_update_graph_initial( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + 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["azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("azure-AsyncOperation") + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") ) - response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) @@ -410,7 +423,9 @@ def get_long_running_output(pipeline_response): return deserialized if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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: @@ -468,14 +483,18 @@ async def _delete_graph_resource_initial( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + 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["azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("azure-AsyncOperation") + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") ) - response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) @@ -528,7 +547,9 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- return cls(pipeline_response, None, {}) # type: ignore if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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: diff --git a/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/aio/operations/_gremlin_resources_operations.py b/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/aio/operations/_gremlin_resources_operations.py index 66ae051c1f0..e0daafadf62 100644 --- a/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/aio/operations/_gremlin_resources_operations.py +++ b/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/aio/operations/_gremlin_resources_operations.py @@ -153,7 +153,7 @@ async def extract_data(pipeline_response): list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore - return None, AsyncList(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): _request = prepare_request(next_link) @@ -166,7 +166,11 @@ 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response @@ -224,7 +228,11 @@ async def get_gremlin_database( if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("GremlinDatabaseGetResults", pipeline_response.http_response) @@ -294,14 +302,19 @@ async def _create_update_gremlin_database_initial( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + 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["azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("azure-AsyncOperation") + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") ) - response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) @@ -438,7 +451,9 @@ def get_long_running_output(pipeline_response): return deserialized if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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: @@ -496,14 +511,18 @@ async def _delete_gremlin_database_initial( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + 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["azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("azure-AsyncOperation") + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") ) - response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) @@ -556,7 +575,9 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- return cls(pipeline_response, None, {}) # type: ignore if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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: @@ -570,12 +591,11 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- ) return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - @distributed_trace_async - async def get_gremlin_database_throughput( + @distributed_trace + def list_gremlin_graphs( self, resource_group_name: str, account_name: str, database_name: str, **kwargs: Any - ) -> _models.ThroughputSettingsGetResults: - """Gets the RUs per second of the Gremlin database under an existing Azure Cosmos DB database - account with the provided name. + ) -> AsyncItemPaged["_models.GremlinGraphGetResults"]: + """Lists the Gremlin graph under an existing Azure Cosmos DB database account. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -584,8 +604,102 @@ async def get_gremlin_database_throughput( :type account_name: str :param database_name: Cosmos DB database name. Required. :type database_name: str - :return: ThroughputSettingsGetResults or the result of cls(response) - :rtype: ~azure.mgmt.cosmosdb.models.ThroughputSettingsGetResults + :return: An iterator like instance of either GremlinGraphGetResults or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.GremlinGraphGetResults] + :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.GremlinGraphListResult] = 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_gremlin_graphs_request( + resource_group_name=resource_group_name, + account_name=account_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) + + 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("GremlinGraphListResult", 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_gremlin_graph( + self, resource_group_name: str, account_name: str, database_name: str, graph_name: str, **kwargs: Any + ) -> _models.GremlinGraphGetResults: + """Gets the Gremlin graph under an existing Azure Cosmos DB database account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param database_name: Cosmos DB database name. Required. + :type database_name: str + :param graph_name: Cosmos DB graph name. Required. + :type graph_name: str + :return: GremlinGraphGetResults or the result of cls(response) + :rtype: ~azure.mgmt.cosmosdb.models.GremlinGraphGetResults :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -600,12 +714,13 @@ async def get_gremlin_database_throughput( _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.ThroughputSettingsGetResults] = kwargs.pop("cls", None) + cls: ClsType[_models.GremlinGraphGetResults] = kwargs.pop("cls", None) - _request = build_get_gremlin_database_throughput_request( + _request = build_get_gremlin_graph_request( resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, + graph_name=graph_name, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, @@ -622,21 +737,26 @@ async def get_gremlin_database_throughput( if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("ThroughputSettingsGetResults", pipeline_response.http_response) + deserialized = self._deserialize("GremlinGraphGetResults", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - async def _update_gremlin_database_throughput_initial( # pylint: disable=name-too-long + async def _create_update_gremlin_graph_initial( self, resource_group_name: str, account_name: str, database_name: str, - update_throughput_parameters: Union[_models.ThroughputSettingsUpdateParameters, IO[bytes]], + graph_name: str, + create_update_gremlin_graph_parameters: Union[_models.GremlinGraphCreateUpdateParameters, IO[bytes]], **kwargs: Any ) -> AsyncIterator[bytes]: error_map: MutableMapping = { @@ -657,15 +777,16 @@ async def _update_gremlin_database_throughput_initial( # pylint: disable=name-t content_type = content_type or "application/json" _json = None _content = None - if isinstance(update_throughput_parameters, (IOBase, bytes)): - _content = update_throughput_parameters + if isinstance(create_update_gremlin_graph_parameters, (IOBase, bytes)): + _content = create_update_gremlin_graph_parameters else: - _json = self._serialize.body(update_throughput_parameters, "ThroughputSettingsUpdateParameters") + _json = self._serialize.body(create_update_gremlin_graph_parameters, "GremlinGraphCreateUpdateParameters") - _request = build_update_gremlin_database_throughput_request( + _request = build_create_update_gremlin_graph_request( resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, + graph_name=graph_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, @@ -690,14 +811,19 @@ async def _update_gremlin_database_throughput_initial( # pylint: disable=name-t except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + 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["azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("azure-AsyncOperation") + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") ) - response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) @@ -707,17 +833,18 @@ async def _update_gremlin_database_throughput_initial( # pylint: disable=name-t return deserialized # type: ignore @overload - async def begin_update_gremlin_database_throughput( + async def begin_create_update_gremlin_graph( self, resource_group_name: str, account_name: str, database_name: str, - update_throughput_parameters: _models.ThroughputSettingsUpdateParameters, + graph_name: str, + create_update_gremlin_graph_parameters: _models.GremlinGraphCreateUpdateParameters, *, content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller[_models.ThroughputSettingsGetResults]: - """Update RUs per second of an Azure Cosmos DB Gremlin database. + ) -> AsyncLROPoller[_models.GremlinGraphGetResults]: + """Create or update an Azure Cosmos DB Gremlin graph. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -726,32 +853,34 @@ async def begin_update_gremlin_database_throughput( :type account_name: str :param database_name: Cosmos DB database name. Required. :type database_name: str - :param update_throughput_parameters: The RUs per second of the parameters to provide for the - current Gremlin database. Required. - :type update_throughput_parameters: - ~azure.mgmt.cosmosdb.models.ThroughputSettingsUpdateParameters + :param graph_name: Cosmos DB graph name. Required. + :type graph_name: str + :param create_update_gremlin_graph_parameters: The parameters to provide for the current + Gremlin graph. Required. + :type create_update_gremlin_graph_parameters: + ~azure.mgmt.cosmosdb.models.GremlinGraphCreateUpdateParameters :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 ThroughputSettingsGetResults or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.ThroughputSettingsGetResults] + :return: An instance of AsyncLROPoller that returns either GremlinGraphGetResults or the result + of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.GremlinGraphGetResults] :raises ~azure.core.exceptions.HttpResponseError: """ @overload - async def begin_update_gremlin_database_throughput( + async def begin_create_update_gremlin_graph( self, resource_group_name: str, account_name: str, database_name: str, - update_throughput_parameters: IO[bytes], + graph_name: str, + create_update_gremlin_graph_parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller[_models.ThroughputSettingsGetResults]: - """Update RUs per second of an Azure Cosmos DB Gremlin database. + ) -> AsyncLROPoller[_models.GremlinGraphGetResults]: + """Create or update an Azure Cosmos DB Gremlin graph. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -760,29 +889,31 @@ async def begin_update_gremlin_database_throughput( :type account_name: str :param database_name: Cosmos DB database name. Required. :type database_name: str - :param update_throughput_parameters: The RUs per second of the parameters to provide for the - current Gremlin database. Required. - :type update_throughput_parameters: IO[bytes] + :param graph_name: Cosmos DB graph name. Required. + :type graph_name: str + :param create_update_gremlin_graph_parameters: The parameters to provide for the current + Gremlin graph. Required. + :type create_update_gremlin_graph_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 ThroughputSettingsGetResults or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.ThroughputSettingsGetResults] + :return: An instance of AsyncLROPoller that returns either GremlinGraphGetResults or the result + of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.GremlinGraphGetResults] :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace_async - async def begin_update_gremlin_database_throughput( + async def begin_create_update_gremlin_graph( self, resource_group_name: str, account_name: str, database_name: str, - update_throughput_parameters: Union[_models.ThroughputSettingsUpdateParameters, IO[bytes]], + graph_name: str, + create_update_gremlin_graph_parameters: Union[_models.GremlinGraphCreateUpdateParameters, IO[bytes]], **kwargs: Any - ) -> AsyncLROPoller[_models.ThroughputSettingsGetResults]: - """Update RUs per second of an Azure Cosmos DB Gremlin database. + ) -> AsyncLROPoller[_models.GremlinGraphGetResults]: + """Create or update an Azure Cosmos DB Gremlin graph. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -791,15 +922,16 @@ async def begin_update_gremlin_database_throughput( :type account_name: str :param database_name: Cosmos DB database name. Required. :type database_name: str - :param update_throughput_parameters: The RUs per second of the parameters to provide for the - current Gremlin database. Is either a ThroughputSettingsUpdateParameters type or a IO[bytes] - type. Required. - :type update_throughput_parameters: - ~azure.mgmt.cosmosdb.models.ThroughputSettingsUpdateParameters or IO[bytes] - :return: An instance of AsyncLROPoller that returns either ThroughputSettingsGetResults or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.ThroughputSettingsGetResults] + :param graph_name: Cosmos DB graph name. Required. + :type graph_name: str + :param create_update_gremlin_graph_parameters: The parameters to provide for the current + Gremlin graph. Is either a GremlinGraphCreateUpdateParameters type or a IO[bytes] type. + Required. + :type create_update_gremlin_graph_parameters: + ~azure.mgmt.cosmosdb.models.GremlinGraphCreateUpdateParameters or IO[bytes] + :return: An instance of AsyncLROPoller that returns either GremlinGraphGetResults or the result + of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.GremlinGraphGetResults] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -807,16 +939,17 @@ async def begin_update_gremlin_database_throughput( 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.ThroughputSettingsGetResults] = kwargs.pop("cls", None) + cls: ClsType[_models.GremlinGraphGetResults] = 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_gremlin_database_throughput_initial( + raw_result = await self._create_update_gremlin_graph_initial( resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, - update_throughput_parameters=update_throughput_parameters, + graph_name=graph_name, + create_update_gremlin_graph_parameters=create_update_gremlin_graph_parameters, api_version=api_version, content_type=content_type, cls=lambda x, y, z: x, @@ -828,30 +961,32 @@ async def begin_update_gremlin_database_throughput( kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ThroughputSettingsGetResults", pipeline_response.http_response) + deserialized = self._deserialize("GremlinGraphGetResults", 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, **kwargs)) - elif polling is False: + 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.ThroughputSettingsGetResults].from_continuation_token( + return AsyncLROPoller[_models.GremlinGraphGetResults].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller[_models.ThroughputSettingsGetResults]( + return AsyncLROPoller[_models.GremlinGraphGetResults]( self._client, raw_result, get_long_running_output, polling_method # type: ignore ) - async def _migrate_gremlin_database_to_autoscale_initial( # pylint: disable=name-too-long - self, resource_group_name: str, account_name: str, database_name: str, **kwargs: Any + async def _delete_gremlin_graph_initial( + self, resource_group_name: str, account_name: str, database_name: str, graph_name: str, **kwargs: Any ) -> AsyncIterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -867,10 +1002,11 @@ async def _migrate_gremlin_database_to_autoscale_initial( # pylint: disable=nam 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_migrate_gremlin_database_to_autoscale_request( + _request = build_delete_gremlin_graph_request( resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, + graph_name=graph_name, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, @@ -886,20 +1022,24 @@ async def _migrate_gremlin_database_to_autoscale_initial( # pylint: disable=nam response = pipeline_response.http_response - if response.status_code not in [200, 202]: + 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + 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["azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("azure-AsyncOperation") + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") ) - response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) @@ -909,10 +1049,10 @@ async def _migrate_gremlin_database_to_autoscale_initial( # pylint: disable=nam return deserialized # type: ignore @distributed_trace_async - async def begin_migrate_gremlin_database_to_autoscale( # pylint: disable=name-too-long - self, resource_group_name: str, account_name: str, database_name: str, **kwargs: Any - ) -> AsyncLROPoller[_models.ThroughputSettingsGetResults]: - """Migrate an Azure Cosmos DB Gremlin database from manual throughput to autoscale. + async def begin_delete_gremlin_graph( + self, resource_group_name: str, account_name: str, database_name: str, graph_name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Deletes an existing Azure Cosmos DB Gremlin graph. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -921,25 +1061,26 @@ async def begin_migrate_gremlin_database_to_autoscale( # pylint: disable=name-t :type account_name: str :param database_name: Cosmos DB database name. Required. :type database_name: str - :return: An instance of AsyncLROPoller that returns either ThroughputSettingsGetResults or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.ThroughputSettingsGetResults] + :param graph_name: Cosmos DB graph name. Required. + :type graph_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[_models.ThroughputSettingsGetResults] = kwargs.pop("cls", 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._migrate_gremlin_database_to_autoscale_initial( + raw_result = await self._delete_gremlin_graph_initial( resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, + graph_name=graph_name, api_version=api_version, cls=lambda x, y, z: x, headers=_headers, @@ -949,31 +1090,35 @@ async def begin_migrate_gremlin_database_to_autoscale( # pylint: disable=name-t await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ThroughputSettingsGetResults", pipeline_response.http_response) + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return cls(pipeline_response, None, {}) # type: ignore if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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.ThroughputSettingsGetResults].from_continuation_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[_models.ThroughputSettingsGetResults]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - async def _migrate_gremlin_database_to_manual_throughput_initial( # pylint: disable=name-too-long - self, resource_group_name: str, account_name: str, database_name: str, **kwargs: Any + async def _retrieve_continuous_backup_information_initial( # pylint: disable=name-too-long + self, + resource_group_name: str, + account_name: str, + database_name: str, + graph_name: str, + location: Union[_models.ContinuousBackupRestoreLocation, IO[bytes]], + **kwargs: Any ) -> AsyncIterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -983,18 +1128,31 @@ async def _migrate_gremlin_database_to_manual_throughput_initial( # pylint: dis } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) 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) - _request = build_migrate_gremlin_database_to_manual_throughput_request( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(location, (IOBase, bytes)): + _content = location + else: + _json = self._serialize.body(location, "ContinuousBackupRestoreLocation") + + _request = build_retrieve_continuous_backup_information_request( resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, + graph_name=graph_name, subscription_id=self._config.subscription_id, api_version=api_version, + content_type=content_type, + json=_json, + content=_content, headers=_headers, params=_params, ) @@ -1018,10 +1176,8 @@ async def _migrate_gremlin_database_to_manual_throughput_initial( # pylint: dis 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["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) @@ -1030,11 +1186,85 @@ async def _migrate_gremlin_database_to_manual_throughput_initial( # pylint: dis return deserialized # type: ignore + @overload + async def begin_retrieve_continuous_backup_information( # pylint: disable=name-too-long + self, + resource_group_name: str, + account_name: str, + database_name: str, + graph_name: str, + location: _models.ContinuousBackupRestoreLocation, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.BackupInformation]: + """Retrieves continuous backup information for a gremlin graph. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param database_name: Cosmos DB database name. Required. + :type database_name: str + :param graph_name: Cosmos DB graph name. Required. + :type graph_name: str + :param location: The name of the continuous backup restore location. Required. + :type location: ~azure.mgmt.cosmosdb.models.ContinuousBackupRestoreLocation + :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 BackupInformation or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.BackupInformation] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_retrieve_continuous_backup_information( # pylint: disable=name-too-long + self, + resource_group_name: str, + account_name: str, + database_name: str, + graph_name: str, + location: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.BackupInformation]: + """Retrieves continuous backup information for a gremlin graph. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param database_name: Cosmos DB database name. Required. + :type database_name: str + :param graph_name: Cosmos DB graph name. Required. + :type graph_name: str + :param location: The name of the continuous backup restore location. Required. + :type location: 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 BackupInformation or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.BackupInformation] + :raises ~azure.core.exceptions.HttpResponseError: + """ + @distributed_trace_async - async def begin_migrate_gremlin_database_to_manual_throughput( # pylint: disable=name-too-long - self, resource_group_name: str, account_name: str, database_name: str, **kwargs: Any - ) -> AsyncLROPoller[_models.ThroughputSettingsGetResults]: - """Migrate an Azure Cosmos DB Gremlin database from autoscale to manual throughput. + async def begin_retrieve_continuous_backup_information( # pylint: disable=name-too-long + self, + resource_group_name: str, + account_name: str, + database_name: str, + graph_name: str, + location: Union[_models.ContinuousBackupRestoreLocation, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.BackupInformation]: + """Retrieves continuous backup information for a gremlin graph. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -1043,26 +1273,34 @@ async def begin_migrate_gremlin_database_to_manual_throughput( # pylint: disabl :type account_name: str :param database_name: Cosmos DB database name. Required. :type database_name: str - :return: An instance of AsyncLROPoller that returns either ThroughputSettingsGetResults or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.ThroughputSettingsGetResults] + :param graph_name: Cosmos DB graph name. Required. + :type graph_name: str + :param location: The name of the continuous backup restore location. Is either a + ContinuousBackupRestoreLocation type or a IO[bytes] type. Required. + :type location: ~azure.mgmt.cosmosdb.models.ContinuousBackupRestoreLocation or IO[bytes] + :return: An instance of AsyncLROPoller that returns either BackupInformation or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.BackupInformation] :raises ~azure.core.exceptions.HttpResponseError: """ - _headers = kwargs.pop("headers", {}) 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)) - cls: ClsType[_models.ThroughputSettingsGetResults] = kwargs.pop("cls", None) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.BackupInformation] = 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_gremlin_database_to_manual_throughput_initial( + raw_result = await self._retrieve_continuous_backup_information_initial( resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, + graph_name=graph_name, + location=location, api_version=api_version, + content_type=content_type, cls=lambda x, y, z: x, headers=_headers, params=_params, @@ -1072,33 +1310,36 @@ async def begin_migrate_gremlin_database_to_manual_throughput( # pylint: disabl kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ThroughputSettingsGetResults", pipeline_response.http_response) + deserialized = self._deserialize("BackupInformation", 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, **kwargs)) + 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.ThroughputSettingsGetResults].from_continuation_token( + return AsyncLROPoller[_models.BackupInformation].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller[_models.ThroughputSettingsGetResults]( + return AsyncLROPoller[_models.BackupInformation]( self._client, raw_result, get_long_running_output, polling_method # type: ignore ) - @distributed_trace - def list_gremlin_graphs( - self, resource_group_name: str, account_name: str, database_name: str, **kwargs: Any - ) -> AsyncItemPaged["_models.GremlinGraphGetResults"]: - """Lists the Gremlin graph under an existing Azure Cosmos DB database account. + @distributed_trace_async + async def get_gremlin_graph_throughput( + self, resource_group_name: str, account_name: str, database_name: str, graph_name: str, **kwargs: Any + ) -> _models.ThroughputSettingsGetResults: + """Gets the Gremlin graph throughput under an existing Azure Cosmos DB database account with the + provided name. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -1107,18 +1348,12 @@ def list_gremlin_graphs( :type account_name: str :param database_name: Cosmos DB database name. Required. :type database_name: str - :return: An iterator like instance of either GremlinGraphGetResults or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.GremlinGraphGetResults] + :param graph_name: Cosmos DB graph name. Required. + :type graph_name: str + :return: ThroughputSettingsGetResults or the result of cls(response) + :rtype: ~azure.mgmt.cosmosdb.models.ThroughputSettingsGetResults :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.GremlinGraphListResult] = kwargs.pop("cls", None) - error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -1127,95 +1362,13 @@ def list_gremlin_graphs( } error_map.update(kwargs.pop("error_map", {}) or {}) - def prepare_request(next_link=None): - if not next_link: + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _request = build_list_gremlin_graphs_request( - resource_group_name=resource_group_name, - account_name=account_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) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.ThroughputSettingsGetResults] = kwargs.pop("cls", None) - 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("GremlinGraphListResult", 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace_async - async def get_gremlin_graph( - self, resource_group_name: str, account_name: str, database_name: str, graph_name: str, **kwargs: Any - ) -> _models.GremlinGraphGetResults: - """Gets the Gremlin graph under an existing Azure Cosmos DB database account. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param account_name: Cosmos DB database account name. Required. - :type account_name: str - :param database_name: Cosmos DB database name. Required. - :type database_name: str - :param graph_name: Cosmos DB graph name. Required. - :type graph_name: str - :return: GremlinGraphGetResults or the result of cls(response) - :rtype: ~azure.mgmt.cosmosdb.models.GremlinGraphGetResults - :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.GremlinGraphGetResults] = kwargs.pop("cls", None) - - _request = build_get_gremlin_graph_request( + _request = build_get_gremlin_graph_throughput_request( resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, @@ -1236,22 +1389,26 @@ async def get_gremlin_graph( if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("GremlinGraphGetResults", pipeline_response.http_response) + deserialized = self._deserialize("ThroughputSettingsGetResults", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - async def _create_update_gremlin_graph_initial( + async def _update_gremlin_graph_throughput_initial( self, resource_group_name: str, account_name: str, database_name: str, graph_name: str, - create_update_gremlin_graph_parameters: Union[_models.GremlinGraphCreateUpdateParameters, IO[bytes]], + update_throughput_parameters: Union[_models.ThroughputSettingsUpdateParameters, IO[bytes]], **kwargs: Any ) -> AsyncIterator[bytes]: error_map: MutableMapping = { @@ -1272,12 +1429,12 @@ async def _create_update_gremlin_graph_initial( content_type = content_type or "application/json" _json = None _content = None - if isinstance(create_update_gremlin_graph_parameters, (IOBase, bytes)): - _content = create_update_gremlin_graph_parameters + if isinstance(update_throughput_parameters, (IOBase, bytes)): + _content = update_throughput_parameters else: - _json = self._serialize.body(create_update_gremlin_graph_parameters, "GremlinGraphCreateUpdateParameters") + _json = self._serialize.body(update_throughput_parameters, "ThroughputSettingsUpdateParameters") - _request = build_create_update_gremlin_graph_request( + _request = build_update_gremlin_graph_throughput_request( resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, @@ -1306,14 +1463,19 @@ async def _create_update_gremlin_graph_initial( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + 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["azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("azure-AsyncOperation") + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") ) - response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) @@ -1323,18 +1485,18 @@ async def _create_update_gremlin_graph_initial( return deserialized # type: ignore @overload - async def begin_create_update_gremlin_graph( + async def begin_update_gremlin_graph_throughput( self, resource_group_name: str, account_name: str, database_name: str, graph_name: str, - create_update_gremlin_graph_parameters: _models.GremlinGraphCreateUpdateParameters, + update_throughput_parameters: _models.ThroughputSettingsUpdateParameters, *, content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller[_models.GremlinGraphGetResults]: - """Create or update an Azure Cosmos DB Gremlin graph. + ) -> AsyncLROPoller[_models.ThroughputSettingsGetResults]: + """Update RUs per second of an Azure Cosmos DB Gremlin graph. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -1345,32 +1507,33 @@ async def begin_create_update_gremlin_graph( :type database_name: str :param graph_name: Cosmos DB graph name. Required. :type graph_name: str - :param create_update_gremlin_graph_parameters: The parameters to provide for the current - Gremlin graph. Required. - :type create_update_gremlin_graph_parameters: - ~azure.mgmt.cosmosdb.models.GremlinGraphCreateUpdateParameters + :param update_throughput_parameters: The RUs per second of the parameters to provide for the + current Gremlin graph. Required. + :type update_throughput_parameters: + ~azure.mgmt.cosmosdb.models.ThroughputSettingsUpdateParameters :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 GremlinGraphGetResults or the result - of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.GremlinGraphGetResults] + :return: An instance of AsyncLROPoller that returns either ThroughputSettingsGetResults or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.ThroughputSettingsGetResults] :raises ~azure.core.exceptions.HttpResponseError: """ @overload - async def begin_create_update_gremlin_graph( + async def begin_update_gremlin_graph_throughput( self, resource_group_name: str, account_name: str, database_name: str, graph_name: str, - create_update_gremlin_graph_parameters: IO[bytes], + update_throughput_parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller[_models.GremlinGraphGetResults]: - """Create or update an Azure Cosmos DB Gremlin graph. + ) -> AsyncLROPoller[_models.ThroughputSettingsGetResults]: + """Update RUs per second of an Azure Cosmos DB Gremlin graph. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -1381,29 +1544,30 @@ async def begin_create_update_gremlin_graph( :type database_name: str :param graph_name: Cosmos DB graph name. Required. :type graph_name: str - :param create_update_gremlin_graph_parameters: The parameters to provide for the current - Gremlin graph. Required. - :type create_update_gremlin_graph_parameters: IO[bytes] + :param update_throughput_parameters: The RUs per second of the parameters to provide for the + current Gremlin graph. Required. + :type update_throughput_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 GremlinGraphGetResults or the result - of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.GremlinGraphGetResults] + :return: An instance of AsyncLROPoller that returns either ThroughputSettingsGetResults or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.ThroughputSettingsGetResults] :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace_async - async def begin_create_update_gremlin_graph( + async def begin_update_gremlin_graph_throughput( self, resource_group_name: str, account_name: str, database_name: str, graph_name: str, - create_update_gremlin_graph_parameters: Union[_models.GremlinGraphCreateUpdateParameters, IO[bytes]], + update_throughput_parameters: Union[_models.ThroughputSettingsUpdateParameters, IO[bytes]], **kwargs: Any - ) -> AsyncLROPoller[_models.GremlinGraphGetResults]: - """Create or update an Azure Cosmos DB Gremlin graph. + ) -> AsyncLROPoller[_models.ThroughputSettingsGetResults]: + """Update RUs per second of an Azure Cosmos DB Gremlin graph. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -1414,14 +1578,15 @@ async def begin_create_update_gremlin_graph( :type database_name: str :param graph_name: Cosmos DB graph name. Required. :type graph_name: str - :param create_update_gremlin_graph_parameters: The parameters to provide for the current - Gremlin graph. Is either a GremlinGraphCreateUpdateParameters type or a IO[bytes] type. + :param update_throughput_parameters: The RUs per second of the parameters to provide for the + current Gremlin graph. Is either a ThroughputSettingsUpdateParameters type or a IO[bytes] type. Required. - :type create_update_gremlin_graph_parameters: - ~azure.mgmt.cosmosdb.models.GremlinGraphCreateUpdateParameters or IO[bytes] - :return: An instance of AsyncLROPoller that returns either GremlinGraphGetResults or the result - of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.GremlinGraphGetResults] + :type update_throughput_parameters: + ~azure.mgmt.cosmosdb.models.ThroughputSettingsUpdateParameters or IO[bytes] + :return: An instance of AsyncLROPoller that returns either ThroughputSettingsGetResults or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.ThroughputSettingsGetResults] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -1429,17 +1594,17 @@ async def begin_create_update_gremlin_graph( 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.GremlinGraphGetResults] = kwargs.pop("cls", None) + cls: ClsType[_models.ThroughputSettingsGetResults] = 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_update_gremlin_graph_initial( + raw_result = await self._update_gremlin_graph_throughput_initial( resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, graph_name=graph_name, - create_update_gremlin_graph_parameters=create_update_gremlin_graph_parameters, + update_throughput_parameters=update_throughput_parameters, api_version=api_version, content_type=content_type, cls=lambda x, y, z: x, @@ -1451,29 +1616,31 @@ async def begin_create_update_gremlin_graph( kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("GremlinGraphGetResults", pipeline_response.http_response) + deserialized = self._deserialize("ThroughputSettingsGetResults", 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, **kwargs)) + 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.GremlinGraphGetResults].from_continuation_token( + return AsyncLROPoller[_models.ThroughputSettingsGetResults].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller[_models.GremlinGraphGetResults]( + return AsyncLROPoller[_models.ThroughputSettingsGetResults]( self._client, raw_result, get_long_running_output, polling_method # type: ignore ) - async def _delete_gremlin_graph_initial( + async def _migrate_gremlin_graph_to_autoscale_initial( # pylint: disable=name-too-long self, resource_group_name: str, account_name: str, database_name: str, graph_name: str, **kwargs: Any ) -> AsyncIterator[bytes]: error_map: MutableMapping = { @@ -1490,7 +1657,7 @@ async def _delete_gremlin_graph_initial( 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_gremlin_graph_request( + _request = build_migrate_gremlin_graph_to_autoscale_request( resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, @@ -1510,7 +1677,7 @@ async def _delete_gremlin_graph_initial( response = pipeline_response.http_response - if response.status_code not in [202, 204]: + if response.status_code not in [200, 202]: try: await response.read() # Load the body in memory and close the socket except (StreamConsumedError, StreamClosedError): @@ -1520,10 +1687,11 @@ async def _delete_gremlin_graph_initial( response_headers = {} if response.status_code == 202: - response_headers["azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("azure-AsyncOperation") + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") ) - response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) @@ -1533,10 +1701,10 @@ async def _delete_gremlin_graph_initial( return deserialized # type: ignore @distributed_trace_async - async def begin_delete_gremlin_graph( + async def begin_migrate_gremlin_graph_to_autoscale( self, resource_group_name: str, account_name: str, database_name: str, graph_name: str, **kwargs: Any - ) -> AsyncLROPoller[None]: - """Deletes an existing Azure Cosmos DB Gremlin graph. + ) -> AsyncLROPoller[_models.ThroughputSettingsGetResults]: + """Migrate an Azure Cosmos DB Gremlin graph from manual throughput to autoscale. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -1547,20 +1715,22 @@ async def begin_delete_gremlin_graph( :type database_name: str :param graph_name: Cosmos DB graph name. Required. :type graph_name: str - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] + :return: An instance of AsyncLROPoller that returns either ThroughputSettingsGetResults or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.ThroughputSettingsGetResults] :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) + cls: ClsType[_models.ThroughputSettingsGetResults] = 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_gremlin_graph_initial( + raw_result = await self._migrate_gremlin_graph_to_autoscale_initial( resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, @@ -1574,45 +1744,34 @@ async def begin_delete_gremlin_graph( 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 + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("ThroughputSettingsGetResults", pipeline_response.http_response) if cls: - return cls(pipeline_response, None, {}) # type: ignore + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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( + return AsyncLROPoller[_models.ThroughputSettingsGetResults].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 + return AsyncLROPoller[_models.ThroughputSettingsGetResults]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) - @distributed_trace_async - async def get_gremlin_graph_throughput( + async def _migrate_gremlin_graph_to_manual_throughput_initial( # pylint: disable=name-too-long self, resource_group_name: str, account_name: str, database_name: str, graph_name: str, **kwargs: Any - ) -> _models.ThroughputSettingsGetResults: - """Gets the Gremlin graph throughput under an existing Azure Cosmos DB database account with the - provided name. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param account_name: Cosmos DB database account name. Required. - :type account_name: str - :param database_name: Cosmos DB database name. Required. - :type database_name: str - :param graph_name: Cosmos DB graph name. Required. - :type graph_name: str - :return: ThroughputSettingsGetResults or the result of cls(response) - :rtype: ~azure.mgmt.cosmosdb.models.ThroughputSettingsGetResults - :raises ~azure.core.exceptions.HttpResponseError: - """ + ) -> AsyncIterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -1625,9 +1784,9 @@ async def get_gremlin_graph_throughput( _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.ThroughputSettingsGetResults] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - _request = build_get_gremlin_graph_throughput_request( + _request = build_migrate_gremlin_graph_to_manual_throughput_request( resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, @@ -1639,34 +1798,180 @@ async def get_gremlin_graph_throughput( ) _request.url = self._client.format_url(_request.url) - _stream = False + _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]: + 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) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("ThroughputSettingsGetResults", pipeline_response.http_response) + 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.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore - async def _update_gremlin_graph_throughput_initial( - self, - resource_group_name: str, - account_name: str, - database_name: str, - graph_name: str, - update_throughput_parameters: Union[_models.ThroughputSettingsUpdateParameters, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { + @distributed_trace_async + async def begin_migrate_gremlin_graph_to_manual_throughput( # pylint: disable=name-too-long + self, resource_group_name: str, account_name: str, database_name: str, graph_name: str, **kwargs: Any + ) -> AsyncLROPoller[_models.ThroughputSettingsGetResults]: + """Migrate an Azure Cosmos DB Gremlin graph from autoscale to manual throughput. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param database_name: Cosmos DB database name. Required. + :type database_name: str + :param graph_name: Cosmos DB graph name. Required. + :type graph_name: str + :return: An instance of AsyncLROPoller that returns either ThroughputSettingsGetResults or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.ThroughputSettingsGetResults] + :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.ThroughputSettingsGetResults] = 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_gremlin_graph_to_manual_throughput_initial( + resource_group_name=resource_group_name, + account_name=account_name, + database_name=database_name, + graph_name=graph_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("ThroughputSettingsGetResults", 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": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.ThroughputSettingsGetResults].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.ThroughputSettingsGetResults]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + @distributed_trace_async + async def get_gremlin_database_throughput( + self, resource_group_name: str, account_name: str, database_name: str, **kwargs: Any + ) -> _models.ThroughputSettingsGetResults: + """Gets the RUs per second of the Gremlin database under an existing Azure Cosmos DB database + account with the provided name. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param database_name: Cosmos DB database name. Required. + :type database_name: str + :return: ThroughputSettingsGetResults or the result of cls(response) + :rtype: ~azure.mgmt.cosmosdb.models.ThroughputSettingsGetResults + :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.ThroughputSettingsGetResults] = kwargs.pop("cls", None) + + _request = build_get_gremlin_database_throughput_request( + resource_group_name=resource_group_name, + account_name=account_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("ThroughputSettingsGetResults", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + async def _update_gremlin_database_throughput_initial( # pylint: disable=name-too-long + self, + resource_group_name: str, + account_name: str, + database_name: str, + update_throughput_parameters: Union[_models.ThroughputSettingsUpdateParameters, IO[bytes]], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1689,11 +1994,10 @@ async def _update_gremlin_graph_throughput_initial( else: _json = self._serialize.body(update_throughput_parameters, "ThroughputSettingsUpdateParameters") - _request = build_update_gremlin_graph_throughput_request( + _request = build_update_gremlin_database_throughput_request( resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, - graph_name=graph_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, @@ -1718,14 +2022,19 @@ async def _update_gremlin_graph_throughput_initial( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + 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["azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("azure-AsyncOperation") + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") ) - response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) @@ -1735,18 +2044,17 @@ async def _update_gremlin_graph_throughput_initial( return deserialized # type: ignore @overload - async def begin_update_gremlin_graph_throughput( + async def begin_update_gremlin_database_throughput( self, resource_group_name: str, account_name: str, database_name: str, - graph_name: str, update_throughput_parameters: _models.ThroughputSettingsUpdateParameters, *, content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[_models.ThroughputSettingsGetResults]: - """Update RUs per second of an Azure Cosmos DB Gremlin graph. + """Update RUs per second of an Azure Cosmos DB Gremlin database. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -1755,10 +2063,8 @@ async def begin_update_gremlin_graph_throughput( :type account_name: str :param database_name: Cosmos DB database name. Required. :type database_name: str - :param graph_name: Cosmos DB graph name. Required. - :type graph_name: str :param update_throughput_parameters: The RUs per second of the parameters to provide for the - current Gremlin graph. Required. + current Gremlin database. Required. :type update_throughput_parameters: ~azure.mgmt.cosmosdb.models.ThroughputSettingsUpdateParameters :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. @@ -1772,18 +2078,17 @@ async def begin_update_gremlin_graph_throughput( """ @overload - async def begin_update_gremlin_graph_throughput( + async def begin_update_gremlin_database_throughput( self, resource_group_name: str, account_name: str, database_name: str, - graph_name: str, update_throughput_parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[_models.ThroughputSettingsGetResults]: - """Update RUs per second of an Azure Cosmos DB Gremlin graph. + """Update RUs per second of an Azure Cosmos DB Gremlin database. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -1792,10 +2097,8 @@ async def begin_update_gremlin_graph_throughput( :type account_name: str :param database_name: Cosmos DB database name. Required. :type database_name: str - :param graph_name: Cosmos DB graph name. Required. - :type graph_name: str :param update_throughput_parameters: The RUs per second of the parameters to provide for the - current Gremlin graph. Required. + current Gremlin database. Required. :type update_throughput_parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". @@ -1808,16 +2111,15 @@ async def begin_update_gremlin_graph_throughput( """ @distributed_trace_async - async def begin_update_gremlin_graph_throughput( + async def begin_update_gremlin_database_throughput( self, resource_group_name: str, account_name: str, database_name: str, - graph_name: str, update_throughput_parameters: Union[_models.ThroughputSettingsUpdateParameters, IO[bytes]], **kwargs: Any ) -> AsyncLROPoller[_models.ThroughputSettingsGetResults]: - """Update RUs per second of an Azure Cosmos DB Gremlin graph. + """Update RUs per second of an Azure Cosmos DB Gremlin database. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -1826,11 +2128,9 @@ async def begin_update_gremlin_graph_throughput( :type account_name: str :param database_name: Cosmos DB database name. Required. :type database_name: str - :param graph_name: Cosmos DB graph name. Required. - :type graph_name: str :param update_throughput_parameters: The RUs per second of the parameters to provide for the - current Gremlin graph. Is either a ThroughputSettingsUpdateParameters type or a IO[bytes] type. - Required. + current Gremlin database. Is either a ThroughputSettingsUpdateParameters type or a IO[bytes] + type. Required. :type update_throughput_parameters: ~azure.mgmt.cosmosdb.models.ThroughputSettingsUpdateParameters or IO[bytes] :return: An instance of AsyncLROPoller that returns either ThroughputSettingsGetResults or the @@ -1849,11 +2149,10 @@ async def begin_update_gremlin_graph_throughput( 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_gremlin_graph_throughput_initial( + raw_result = await self._update_gremlin_database_throughput_initial( resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, - graph_name=graph_name, update_throughput_parameters=update_throughput_parameters, api_version=api_version, content_type=content_type, @@ -1872,7 +2171,9 @@ def get_long_running_output(pipeline_response): return deserialized if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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: @@ -1888,8 +2189,8 @@ def get_long_running_output(pipeline_response): self._client, raw_result, get_long_running_output, polling_method # type: ignore ) - async def _migrate_gremlin_graph_to_autoscale_initial( # pylint: disable=name-too-long - self, resource_group_name: str, account_name: str, database_name: str, graph_name: str, **kwargs: Any + async def _migrate_gremlin_database_to_autoscale_initial( # pylint: disable=name-too-long + self, resource_group_name: str, account_name: str, database_name: str, **kwargs: Any ) -> AsyncIterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -1905,11 +2206,10 @@ async def _migrate_gremlin_graph_to_autoscale_initial( # pylint: disable=name-t 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_migrate_gremlin_graph_to_autoscale_request( + _request = build_migrate_gremlin_database_to_autoscale_request( resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, - graph_name=graph_name, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, @@ -1935,10 +2235,11 @@ async def _migrate_gremlin_graph_to_autoscale_initial( # pylint: disable=name-t response_headers = {} if response.status_code == 202: - response_headers["azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("azure-AsyncOperation") + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") ) - response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) @@ -1948,10 +2249,10 @@ async def _migrate_gremlin_graph_to_autoscale_initial( # pylint: disable=name-t return deserialized # type: ignore @distributed_trace_async - async def begin_migrate_gremlin_graph_to_autoscale( - self, resource_group_name: str, account_name: str, database_name: str, graph_name: str, **kwargs: Any + async def begin_migrate_gremlin_database_to_autoscale( # pylint: disable=name-too-long + self, resource_group_name: str, account_name: str, database_name: str, **kwargs: Any ) -> AsyncLROPoller[_models.ThroughputSettingsGetResults]: - """Migrate an Azure Cosmos DB Gremlin graph from manual throughput to autoscale. + """Migrate an Azure Cosmos DB Gremlin database from manual throughput to autoscale. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -1960,8 +2261,6 @@ async def begin_migrate_gremlin_graph_to_autoscale( :type account_name: str :param database_name: Cosmos DB database name. Required. :type database_name: str - :param graph_name: Cosmos DB graph name. Required. - :type graph_name: str :return: An instance of AsyncLROPoller that returns either ThroughputSettingsGetResults or the result of cls(response) :rtype: @@ -1977,11 +2276,10 @@ async def begin_migrate_gremlin_graph_to_autoscale( 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_gremlin_graph_to_autoscale_initial( + raw_result = await self._migrate_gremlin_database_to_autoscale_initial( resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, - graph_name=graph_name, api_version=api_version, cls=lambda x, y, z: x, headers=_headers, @@ -1998,7 +2296,9 @@ def get_long_running_output(pipeline_response): return deserialized if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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: @@ -2014,8 +2314,8 @@ def get_long_running_output(pipeline_response): self._client, raw_result, get_long_running_output, polling_method # type: ignore ) - async def _migrate_gremlin_graph_to_manual_throughput_initial( # pylint: disable=name-too-long - self, resource_group_name: str, account_name: str, database_name: str, graph_name: str, **kwargs: Any + async def _migrate_gremlin_database_to_manual_throughput_initial( # pylint: disable=name-too-long + self, resource_group_name: str, account_name: str, database_name: str, **kwargs: Any ) -> AsyncIterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -2031,11 +2331,10 @@ async def _migrate_gremlin_graph_to_manual_throughput_initial( # pylint: disabl 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_migrate_gremlin_graph_to_manual_throughput_request( + _request = build_migrate_gremlin_database_to_manual_throughput_request( resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, - graph_name=graph_name, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, @@ -2061,10 +2360,11 @@ async def _migrate_gremlin_graph_to_manual_throughput_initial( # pylint: disabl response_headers = {} if response.status_code == 202: - response_headers["azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("azure-AsyncOperation") + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") ) - response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) @@ -2074,10 +2374,10 @@ async def _migrate_gremlin_graph_to_manual_throughput_initial( # pylint: disabl return deserialized # type: ignore @distributed_trace_async - async def begin_migrate_gremlin_graph_to_manual_throughput( # pylint: disable=name-too-long - self, resource_group_name: str, account_name: str, database_name: str, graph_name: str, **kwargs: Any + async def begin_migrate_gremlin_database_to_manual_throughput( # pylint: disable=name-too-long + self, resource_group_name: str, account_name: str, database_name: str, **kwargs: Any ) -> AsyncLROPoller[_models.ThroughputSettingsGetResults]: - """Migrate an Azure Cosmos DB Gremlin graph from autoscale to manual throughput. + """Migrate an Azure Cosmos DB Gremlin database from autoscale to manual throughput. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -2086,8 +2386,6 @@ async def begin_migrate_gremlin_graph_to_manual_throughput( # pylint: disable=n :type account_name: str :param database_name: Cosmos DB database name. Required. :type database_name: str - :param graph_name: Cosmos DB graph name. Required. - :type graph_name: str :return: An instance of AsyncLROPoller that returns either ThroughputSettingsGetResults or the result of cls(response) :rtype: @@ -2103,11 +2401,10 @@ async def begin_migrate_gremlin_graph_to_manual_throughput( # pylint: disable=n 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_gremlin_graph_to_manual_throughput_initial( + raw_result = await self._migrate_gremlin_database_to_manual_throughput_initial( resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, - graph_name=graph_name, api_version=api_version, cls=lambda x, y, z: x, headers=_headers, @@ -2124,7 +2421,9 @@ def get_long_running_output(pipeline_response): return deserialized if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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: @@ -2140,24 +2439,29 @@ def get_long_running_output(pipeline_response): self._client, raw_result, get_long_running_output, polling_method # type: ignore ) - @distributed_trace_async - async def get_gremlin_role_definition( - self, resource_group_name: str, account_name: str, role_definition_id: str, **kwargs: Any - ) -> _models.GremlinRoleDefinitionResource: - """Retrieves the properties of an existing Azure Cosmos DB Gremlin Role Definition with the given - Id. + @distributed_trace + def list_gremlin_role_assignments( + self, resource_group_name: str, account_name: str, **kwargs: Any + ) -> AsyncItemPaged["_models.GremlinRoleAssignmentResource"]: + """Retrieves the list of all Azure Cosmos DB Gremlin Role Assignments. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param role_definition_id: The GUID for the Role Definition. Required. - :type role_definition_id: str - :return: GremlinRoleDefinitionResource or the result of cls(response) - :rtype: ~azure.mgmt.cosmosdb.models.GremlinRoleDefinitionResource + :return: An iterator like instance of either GremlinRoleAssignmentResource or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.GremlinRoleAssignmentResource] :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.GremlinRoleAssignmentListResult] = kwargs.pop("cls", None) + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -2166,16 +2470,100 @@ async def get_gremlin_role_definition( } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_gremlin_role_assignments_request( + resource_group_name=resource_group_name, + account_name=account_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("GremlinRoleAssignmentListResult", 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_gremlin_role_assignment( + self, resource_group_name: str, account_name: str, role_assignment_id: str, **kwargs: Any + ) -> _models.GremlinRoleAssignmentResource: + """Retrieves the properties of an existing Azure Cosmos DB Gremlin Role Assignment with the given + Id. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param role_assignment_id: The GUID for the Role Assignment. Required. + :type role_assignment_id: str + :return: GremlinRoleAssignmentResource or the result of cls(response) + :rtype: ~azure.mgmt.cosmosdb.models.GremlinRoleAssignmentResource + :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.GremlinRoleDefinitionResource] = kwargs.pop("cls", None) + cls: ClsType[_models.GremlinRoleAssignmentResource] = kwargs.pop("cls", None) - _request = build_get_gremlin_role_definition_request( + _request = build_get_gremlin_role_assignment_request( resource_group_name=resource_group_name, account_name=account_name, - role_definition_id=role_definition_id, + role_assignment_id=role_assignment_id, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, @@ -2198,19 +2586,19 @@ async def get_gremlin_role_definition( ) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("GremlinRoleDefinitionResource", pipeline_response.http_response) + deserialized = self._deserialize("GremlinRoleAssignmentResource", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - async def _create_update_gremlin_role_definition_initial( # pylint: disable=name-too-long + async def _create_update_gremlin_role_assignment_initial( # pylint: disable=name-too-long self, resource_group_name: str, account_name: str, - role_definition_id: str, - create_update_gremlin_role_definition_parameters: Union[_models.GremlinRoleDefinitionResource, IO[bytes]], + role_assignment_id: str, + create_update_gremlin_role_assignment_parameters: Union[_models.GremlinRoleAssignmentResource, IO[bytes]], **kwargs: Any ) -> AsyncIterator[bytes]: error_map: MutableMapping = { @@ -2231,17 +2619,17 @@ async def _create_update_gremlin_role_definition_initial( # pylint: disable=nam content_type = content_type or "application/json" _json = None _content = None - if isinstance(create_update_gremlin_role_definition_parameters, (IOBase, bytes)): - _content = create_update_gremlin_role_definition_parameters + if isinstance(create_update_gremlin_role_assignment_parameters, (IOBase, bytes)): + _content = create_update_gremlin_role_assignment_parameters else: _json = self._serialize.body( - create_update_gremlin_role_definition_parameters, "GremlinRoleDefinitionResource" + create_update_gremlin_role_assignment_parameters, "GremlinRoleAssignmentResource" ) - _request = build_create_update_gremlin_role_definition_request( + _request = build_create_update_gremlin_role_assignment_request( resource_group_name=resource_group_name, account_name=account_name, - role_definition_id=role_definition_id, + role_assignment_id=role_assignment_id, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, @@ -2274,10 +2662,11 @@ async def _create_update_gremlin_role_definition_initial( # pylint: disable=nam response_headers = {} if response.status_code == 202: - response_headers["azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("azure-AsyncOperation") + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") ) - response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) @@ -2287,99 +2676,99 @@ async def _create_update_gremlin_role_definition_initial( # pylint: disable=nam return deserialized # type: ignore @overload - async def begin_create_update_gremlin_role_definition( # pylint: disable=name-too-long + async def begin_create_update_gremlin_role_assignment( # pylint: disable=name-too-long self, resource_group_name: str, account_name: str, - role_definition_id: str, - create_update_gremlin_role_definition_parameters: _models.GremlinRoleDefinitionResource, + role_assignment_id: str, + create_update_gremlin_role_assignment_parameters: _models.GremlinRoleAssignmentResource, *, content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller[_models.GremlinRoleDefinitionResource]: - """Creates or updates an Azure Cosmos DB Gremlin Role Definition. + ) -> AsyncLROPoller[_models.GremlinRoleAssignmentResource]: + """Creates or updates an Azure Cosmos DB Gremlin Role Assignment. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param role_definition_id: The GUID for the Role Definition. Required. - :type role_definition_id: str - :param create_update_gremlin_role_definition_parameters: The properties required to create or - update a Role Definition. Required. - :type create_update_gremlin_role_definition_parameters: - ~azure.mgmt.cosmosdb.models.GremlinRoleDefinitionResource + :param role_assignment_id: The GUID for the Role Assignment. Required. + :type role_assignment_id: str + :param create_update_gremlin_role_assignment_parameters: The properties required to create or + update a Role Assignment. Required. + :type create_update_gremlin_role_assignment_parameters: + ~azure.mgmt.cosmosdb.models.GremlinRoleAssignmentResource :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 GremlinRoleDefinitionResource or the + :return: An instance of AsyncLROPoller that returns either GremlinRoleAssignmentResource or the result of cls(response) :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.GremlinRoleDefinitionResource] + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.GremlinRoleAssignmentResource] :raises ~azure.core.exceptions.HttpResponseError: """ @overload - async def begin_create_update_gremlin_role_definition( # pylint: disable=name-too-long + async def begin_create_update_gremlin_role_assignment( # pylint: disable=name-too-long self, resource_group_name: str, account_name: str, - role_definition_id: str, - create_update_gremlin_role_definition_parameters: IO[bytes], + role_assignment_id: str, + create_update_gremlin_role_assignment_parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller[_models.GremlinRoleDefinitionResource]: - """Creates or updates an Azure Cosmos DB Gremlin Role Definition. + ) -> AsyncLROPoller[_models.GremlinRoleAssignmentResource]: + """Creates or updates an Azure Cosmos DB Gremlin Role Assignment. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param role_definition_id: The GUID for the Role Definition. Required. - :type role_definition_id: str - :param create_update_gremlin_role_definition_parameters: The properties required to create or - update a Role Definition. Required. - :type create_update_gremlin_role_definition_parameters: IO[bytes] + :param role_assignment_id: The GUID for the Role Assignment. Required. + :type role_assignment_id: str + :param create_update_gremlin_role_assignment_parameters: The properties required to create or + update a Role Assignment. Required. + :type create_update_gremlin_role_assignment_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 GremlinRoleDefinitionResource or the + :return: An instance of AsyncLROPoller that returns either GremlinRoleAssignmentResource or the result of cls(response) :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.GremlinRoleDefinitionResource] + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.GremlinRoleAssignmentResource] :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace_async - async def begin_create_update_gremlin_role_definition( # pylint: disable=name-too-long + async def begin_create_update_gremlin_role_assignment( # pylint: disable=name-too-long self, resource_group_name: str, account_name: str, - role_definition_id: str, - create_update_gremlin_role_definition_parameters: Union[_models.GremlinRoleDefinitionResource, IO[bytes]], + role_assignment_id: str, + create_update_gremlin_role_assignment_parameters: Union[_models.GremlinRoleAssignmentResource, IO[bytes]], **kwargs: Any - ) -> AsyncLROPoller[_models.GremlinRoleDefinitionResource]: - """Creates or updates an Azure Cosmos DB Gremlin Role Definition. + ) -> AsyncLROPoller[_models.GremlinRoleAssignmentResource]: + """Creates or updates an Azure Cosmos DB Gremlin Role Assignment. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param role_definition_id: The GUID for the Role Definition. Required. - :type role_definition_id: str - :param create_update_gremlin_role_definition_parameters: The properties required to create or - update a Role Definition. Is either a GremlinRoleDefinitionResource type or a IO[bytes] type. + :param role_assignment_id: The GUID for the Role Assignment. Required. + :type role_assignment_id: str + :param create_update_gremlin_role_assignment_parameters: The properties required to create or + update a Role Assignment. Is either a GremlinRoleAssignmentResource type or a IO[bytes] type. Required. - :type create_update_gremlin_role_definition_parameters: - ~azure.mgmt.cosmosdb.models.GremlinRoleDefinitionResource or IO[bytes] - :return: An instance of AsyncLROPoller that returns either GremlinRoleDefinitionResource or the + :type create_update_gremlin_role_assignment_parameters: + ~azure.mgmt.cosmosdb.models.GremlinRoleAssignmentResource or IO[bytes] + :return: An instance of AsyncLROPoller that returns either GremlinRoleAssignmentResource or the result of cls(response) :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.GremlinRoleDefinitionResource] + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.GremlinRoleAssignmentResource] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -2387,16 +2776,16 @@ async def begin_create_update_gremlin_role_definition( # pylint: disable=name-t 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.GremlinRoleDefinitionResource] = kwargs.pop("cls", None) + cls: ClsType[_models.GremlinRoleAssignmentResource] = 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_update_gremlin_role_definition_initial( + raw_result = await self._create_update_gremlin_role_assignment_initial( resource_group_name=resource_group_name, account_name=account_name, - role_definition_id=role_definition_id, - create_update_gremlin_role_definition_parameters=create_update_gremlin_role_definition_parameters, + role_assignment_id=role_assignment_id, + create_update_gremlin_role_assignment_parameters=create_update_gremlin_role_assignment_parameters, api_version=api_version, content_type=content_type, cls=lambda x, y, z: x, @@ -2408,30 +2797,32 @@ async def begin_create_update_gremlin_role_definition( # pylint: disable=name-t kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("GremlinRoleDefinitionResource", pipeline_response.http_response) + deserialized = self._deserialize("GremlinRoleAssignmentResource", 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, **kwargs)) + 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.GremlinRoleDefinitionResource].from_continuation_token( + return AsyncLROPoller[_models.GremlinRoleAssignmentResource].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller[_models.GremlinRoleDefinitionResource]( + return AsyncLROPoller[_models.GremlinRoleAssignmentResource]( self._client, raw_result, get_long_running_output, polling_method # type: ignore ) - async def _delete_gremlin_role_definition_initial( - self, resource_group_name: str, account_name: str, role_definition_id: str, **kwargs: Any + async def _delete_gremlin_role_assignment_initial( + self, resource_group_name: str, account_name: str, role_assignment_id: str, **kwargs: Any ) -> AsyncIterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -2447,10 +2838,10 @@ async def _delete_gremlin_role_definition_initial( 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_gremlin_role_definition_request( + _request = build_delete_gremlin_role_assignment_request( resource_group_name=resource_group_name, account_name=account_name, - role_definition_id=role_definition_id, + role_assignment_id=role_assignment_id, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, @@ -2480,10 +2871,10 @@ async def _delete_gremlin_role_definition_initial( response_headers = {} if response.status_code == 202: - response_headers["azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("azure-AsyncOperation") + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") ) - response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) @@ -2493,18 +2884,18 @@ async def _delete_gremlin_role_definition_initial( return deserialized # type: ignore @distributed_trace_async - async def begin_delete_gremlin_role_definition( - self, resource_group_name: str, account_name: str, role_definition_id: str, **kwargs: Any + async def begin_delete_gremlin_role_assignment( + self, resource_group_name: str, account_name: str, role_assignment_id: str, **kwargs: Any ) -> AsyncLROPoller[None]: - """Deletes an existing Azure Cosmos DB Gremlin Role Definition. + """Deletes an existing Azure Cosmos DB Gremlin Role Assignment. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param role_definition_id: The GUID for the Role Definition. Required. - :type role_definition_id: str + :param role_assignment_id: The GUID for the Role Assignment. Required. + :type role_assignment_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: @@ -2518,10 +2909,10 @@ async def begin_delete_gremlin_role_definition( 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_gremlin_role_definition_initial( + raw_result = await self._delete_gremlin_role_assignment_initial( resource_group_name=resource_group_name, account_name=account_name, - role_definition_id=role_definition_id, + role_assignment_id=role_assignment_id, api_version=api_version, cls=lambda x, y, z: x, headers=_headers, @@ -2536,7 +2927,9 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- return cls(pipeline_response, None, {}) # type: ignore if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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: @@ -2616,7 +3009,7 @@ async def extract_data(pipeline_response): list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore - return None, AsyncList(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): _request = prepare_request(next_link) @@ -2640,10 +3033,10 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) @distributed_trace_async - async def get_gremlin_role_assignment( - self, resource_group_name: str, account_name: str, role_assignment_id: str, **kwargs: Any - ) -> _models.GremlinRoleAssignmentResource: - """Retrieves the properties of an existing Azure Cosmos DB Gremlin Role Assignment with the given + async def get_gremlin_role_definition( + self, resource_group_name: str, account_name: str, role_definition_id: str, **kwargs: Any + ) -> _models.GremlinRoleDefinitionResource: + """Retrieves the properties of an existing Azure Cosmos DB Gremlin Role Definition with the given Id. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -2651,10 +3044,10 @@ async def get_gremlin_role_assignment( :type resource_group_name: str :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param role_assignment_id: The GUID for the Role Assignment. Required. - :type role_assignment_id: str - :return: GremlinRoleAssignmentResource or the result of cls(response) - :rtype: ~azure.mgmt.cosmosdb.models.GremlinRoleAssignmentResource + :param role_definition_id: The GUID for the Role Definition. Required. + :type role_definition_id: str + :return: GremlinRoleDefinitionResource or the result of cls(response) + :rtype: ~azure.mgmt.cosmosdb.models.GremlinRoleDefinitionResource :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -2669,12 +3062,12 @@ async def get_gremlin_role_assignment( _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.GremlinRoleAssignmentResource] = kwargs.pop("cls", None) + cls: ClsType[_models.GremlinRoleDefinitionResource] = kwargs.pop("cls", None) - _request = build_get_gremlin_role_assignment_request( + _request = build_get_gremlin_role_definition_request( resource_group_name=resource_group_name, account_name=account_name, - role_assignment_id=role_assignment_id, + role_definition_id=role_definition_id, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, @@ -2697,20 +3090,20 @@ async def get_gremlin_role_assignment( ) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("GremlinRoleAssignmentResource", pipeline_response.http_response) + deserialized = self._deserialize("GremlinRoleDefinitionResource", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - async def _create_update_gremlin_role_assignment_initial( # pylint: disable=name-too-long + async def _create_update_gremlin_role_definition_initial( # pylint: disable=name-too-long self, resource_group_name: str, account_name: str, - role_assignment_id: str, - create_update_gremlin_role_assignment_parameters: Union[_models.GremlinRoleAssignmentResource, IO[bytes]], - **kwargs: Any + role_definition_id: str, + create_update_gremlin_role_definition_parameters: Union[_models.GremlinRoleDefinitionResource, IO[bytes]], + **kwargs: Any ) -> AsyncIterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -2730,17 +3123,17 @@ async def _create_update_gremlin_role_assignment_initial( # pylint: disable=nam content_type = content_type or "application/json" _json = None _content = None - if isinstance(create_update_gremlin_role_assignment_parameters, (IOBase, bytes)): - _content = create_update_gremlin_role_assignment_parameters + if isinstance(create_update_gremlin_role_definition_parameters, (IOBase, bytes)): + _content = create_update_gremlin_role_definition_parameters else: _json = self._serialize.body( - create_update_gremlin_role_assignment_parameters, "GremlinRoleAssignmentResource" + create_update_gremlin_role_definition_parameters, "GremlinRoleDefinitionResource" ) - _request = build_create_update_gremlin_role_assignment_request( + _request = build_create_update_gremlin_role_definition_request( resource_group_name=resource_group_name, account_name=account_name, - role_assignment_id=role_assignment_id, + role_definition_id=role_definition_id, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, @@ -2773,10 +3166,11 @@ async def _create_update_gremlin_role_assignment_initial( # pylint: disable=nam response_headers = {} if response.status_code == 202: - response_headers["azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("azure-AsyncOperation") + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") ) - response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) @@ -2786,99 +3180,99 @@ async def _create_update_gremlin_role_assignment_initial( # pylint: disable=nam return deserialized # type: ignore @overload - async def begin_create_update_gremlin_role_assignment( # pylint: disable=name-too-long + async def begin_create_update_gremlin_role_definition( # pylint: disable=name-too-long self, resource_group_name: str, account_name: str, - role_assignment_id: str, - create_update_gremlin_role_assignment_parameters: _models.GremlinRoleAssignmentResource, + role_definition_id: str, + create_update_gremlin_role_definition_parameters: _models.GremlinRoleDefinitionResource, *, content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller[_models.GremlinRoleAssignmentResource]: - """Creates or updates an Azure Cosmos DB Gremlin Role Assignment. + ) -> AsyncLROPoller[_models.GremlinRoleDefinitionResource]: + """Creates or updates an Azure Cosmos DB Gremlin Role Definition. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param role_assignment_id: The GUID for the Role Assignment. Required. - :type role_assignment_id: str - :param create_update_gremlin_role_assignment_parameters: The properties required to create or - update a Role Assignment. Required. - :type create_update_gremlin_role_assignment_parameters: - ~azure.mgmt.cosmosdb.models.GremlinRoleAssignmentResource + :param role_definition_id: The GUID for the Role Definition. Required. + :type role_definition_id: str + :param create_update_gremlin_role_definition_parameters: The properties required to create or + update a Role Definition. Required. + :type create_update_gremlin_role_definition_parameters: + ~azure.mgmt.cosmosdb.models.GremlinRoleDefinitionResource :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 GremlinRoleAssignmentResource or the + :return: An instance of AsyncLROPoller that returns either GremlinRoleDefinitionResource or the result of cls(response) :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.GremlinRoleAssignmentResource] + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.GremlinRoleDefinitionResource] :raises ~azure.core.exceptions.HttpResponseError: """ @overload - async def begin_create_update_gremlin_role_assignment( # pylint: disable=name-too-long + async def begin_create_update_gremlin_role_definition( # pylint: disable=name-too-long self, resource_group_name: str, account_name: str, - role_assignment_id: str, - create_update_gremlin_role_assignment_parameters: IO[bytes], + role_definition_id: str, + create_update_gremlin_role_definition_parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller[_models.GremlinRoleAssignmentResource]: - """Creates or updates an Azure Cosmos DB Gremlin Role Assignment. + ) -> AsyncLROPoller[_models.GremlinRoleDefinitionResource]: + """Creates or updates an Azure Cosmos DB Gremlin Role Definition. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param role_assignment_id: The GUID for the Role Assignment. Required. - :type role_assignment_id: str - :param create_update_gremlin_role_assignment_parameters: The properties required to create or - update a Role Assignment. Required. - :type create_update_gremlin_role_assignment_parameters: IO[bytes] + :param role_definition_id: The GUID for the Role Definition. Required. + :type role_definition_id: str + :param create_update_gremlin_role_definition_parameters: The properties required to create or + update a Role Definition. Required. + :type create_update_gremlin_role_definition_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 GremlinRoleAssignmentResource or the + :return: An instance of AsyncLROPoller that returns either GremlinRoleDefinitionResource or the result of cls(response) :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.GremlinRoleAssignmentResource] + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.GremlinRoleDefinitionResource] :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace_async - async def begin_create_update_gremlin_role_assignment( # pylint: disable=name-too-long + async def begin_create_update_gremlin_role_definition( # pylint: disable=name-too-long self, resource_group_name: str, account_name: str, - role_assignment_id: str, - create_update_gremlin_role_assignment_parameters: Union[_models.GremlinRoleAssignmentResource, IO[bytes]], + role_definition_id: str, + create_update_gremlin_role_definition_parameters: Union[_models.GremlinRoleDefinitionResource, IO[bytes]], **kwargs: Any - ) -> AsyncLROPoller[_models.GremlinRoleAssignmentResource]: - """Creates or updates an Azure Cosmos DB Gremlin Role Assignment. + ) -> AsyncLROPoller[_models.GremlinRoleDefinitionResource]: + """Creates or updates an Azure Cosmos DB Gremlin Role Definition. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param role_assignment_id: The GUID for the Role Assignment. Required. - :type role_assignment_id: str - :param create_update_gremlin_role_assignment_parameters: The properties required to create or - update a Role Assignment. Is either a GremlinRoleAssignmentResource type or a IO[bytes] type. + :param role_definition_id: The GUID for the Role Definition. Required. + :type role_definition_id: str + :param create_update_gremlin_role_definition_parameters: The properties required to create or + update a Role Definition. Is either a GremlinRoleDefinitionResource type or a IO[bytes] type. Required. - :type create_update_gremlin_role_assignment_parameters: - ~azure.mgmt.cosmosdb.models.GremlinRoleAssignmentResource or IO[bytes] - :return: An instance of AsyncLROPoller that returns either GremlinRoleAssignmentResource or the + :type create_update_gremlin_role_definition_parameters: + ~azure.mgmt.cosmosdb.models.GremlinRoleDefinitionResource or IO[bytes] + :return: An instance of AsyncLROPoller that returns either GremlinRoleDefinitionResource or the result of cls(response) :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.GremlinRoleAssignmentResource] + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.GremlinRoleDefinitionResource] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -2886,16 +3280,16 @@ async def begin_create_update_gremlin_role_assignment( # pylint: disable=name-t 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.GremlinRoleAssignmentResource] = kwargs.pop("cls", None) + cls: ClsType[_models.GremlinRoleDefinitionResource] = 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_update_gremlin_role_assignment_initial( + raw_result = await self._create_update_gremlin_role_definition_initial( resource_group_name=resource_group_name, account_name=account_name, - role_assignment_id=role_assignment_id, - create_update_gremlin_role_assignment_parameters=create_update_gremlin_role_assignment_parameters, + role_definition_id=role_definition_id, + create_update_gremlin_role_definition_parameters=create_update_gremlin_role_definition_parameters, api_version=api_version, content_type=content_type, cls=lambda x, y, z: x, @@ -2907,30 +3301,32 @@ async def begin_create_update_gremlin_role_assignment( # pylint: disable=name-t kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("GremlinRoleAssignmentResource", pipeline_response.http_response) + deserialized = self._deserialize("GremlinRoleDefinitionResource", 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, **kwargs)) + 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.GremlinRoleAssignmentResource].from_continuation_token( + return AsyncLROPoller[_models.GremlinRoleDefinitionResource].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller[_models.GremlinRoleAssignmentResource]( + return AsyncLROPoller[_models.GremlinRoleDefinitionResource]( self._client, raw_result, get_long_running_output, polling_method # type: ignore ) - async def _delete_gremlin_role_assignment_initial( - self, resource_group_name: str, account_name: str, role_assignment_id: str, **kwargs: Any + async def _delete_gremlin_role_definition_initial( + self, resource_group_name: str, account_name: str, role_definition_id: str, **kwargs: Any ) -> AsyncIterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -2946,10 +3342,10 @@ async def _delete_gremlin_role_assignment_initial( 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_gremlin_role_assignment_request( + _request = build_delete_gremlin_role_definition_request( resource_group_name=resource_group_name, account_name=account_name, - role_assignment_id=role_assignment_id, + role_definition_id=role_definition_id, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, @@ -2979,10 +3375,10 @@ async def _delete_gremlin_role_assignment_initial( response_headers = {} if response.status_code == 202: - response_headers["azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("azure-AsyncOperation") + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") ) - response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) @@ -2992,18 +3388,18 @@ async def _delete_gremlin_role_assignment_initial( return deserialized # type: ignore @distributed_trace_async - async def begin_delete_gremlin_role_assignment( - self, resource_group_name: str, account_name: str, role_assignment_id: str, **kwargs: Any + async def begin_delete_gremlin_role_definition( + self, resource_group_name: str, account_name: str, role_definition_id: str, **kwargs: Any ) -> AsyncLROPoller[None]: - """Deletes an existing Azure Cosmos DB Gremlin Role Assignment. + """Deletes an existing Azure Cosmos DB Gremlin Role Definition. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param role_assignment_id: The GUID for the Role Assignment. Required. - :type role_assignment_id: str + :param role_definition_id: The GUID for the Role Definition. Required. + :type role_definition_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: @@ -3017,10 +3413,10 @@ async def begin_delete_gremlin_role_assignment( 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_gremlin_role_assignment_initial( + raw_result = await self._delete_gremlin_role_definition_initial( resource_group_name=resource_group_name, account_name=account_name, - role_assignment_id=role_assignment_id, + role_definition_id=role_definition_id, api_version=api_version, cls=lambda x, y, z: x, headers=_headers, @@ -3034,309 +3430,6 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- if cls: return cls(pipeline_response, None, {}) # type: ignore - if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **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_gremlin_role_assignments( - self, resource_group_name: str, account_name: str, **kwargs: Any - ) -> AsyncItemPaged["_models.GremlinRoleAssignmentResource"]: - """Retrieves the list of all Azure Cosmos DB Gremlin Role Assignments. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param account_name: Cosmos DB database account name. Required. - :type account_name: str - :return: An iterator like instance of either GremlinRoleAssignmentResource or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.GremlinRoleAssignmentResource] - :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.GremlinRoleAssignmentListResult] = 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_gremlin_role_assignments_request( - resource_group_name=resource_group_name, - account_name=account_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("GremlinRoleAssignmentListResult", 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) - - async def _retrieve_continuous_backup_information_initial( # pylint: disable=name-too-long - self, - resource_group_name: str, - account_name: str, - database_name: str, - graph_name: str, - location: Union[_models.ContinuousBackupRestoreLocation, 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(location, (IOBase, bytes)): - _content = location - else: - _json = self._serialize.body(location, "ContinuousBackupRestoreLocation") - - _request = build_retrieve_continuous_backup_information_request( - resource_group_name=resource_group_name, - account_name=account_name, - database_name=database_name, - graph_name=graph_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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def begin_retrieve_continuous_backup_information( # pylint: disable=name-too-long - self, - resource_group_name: str, - account_name: str, - database_name: str, - graph_name: str, - location: _models.ContinuousBackupRestoreLocation, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.BackupInformation]: - """Retrieves continuous backup information for a gremlin graph. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param account_name: Cosmos DB database account name. Required. - :type account_name: str - :param database_name: Cosmos DB database name. Required. - :type database_name: str - :param graph_name: Cosmos DB graph name. Required. - :type graph_name: str - :param location: The name of the continuous backup restore location. Required. - :type location: ~azure.mgmt.cosmosdb.models.ContinuousBackupRestoreLocation - :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 BackupInformation or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.BackupInformation] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_retrieve_continuous_backup_information( # pylint: disable=name-too-long - self, - resource_group_name: str, - account_name: str, - database_name: str, - graph_name: str, - location: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.BackupInformation]: - """Retrieves continuous backup information for a gremlin graph. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param account_name: Cosmos DB database account name. Required. - :type account_name: str - :param database_name: Cosmos DB database name. Required. - :type database_name: str - :param graph_name: Cosmos DB graph name. Required. - :type graph_name: str - :param location: The name of the continuous backup restore location. Required. - :type location: 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 BackupInformation or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.BackupInformation] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_retrieve_continuous_backup_information( # pylint: disable=name-too-long - self, - resource_group_name: str, - account_name: str, - database_name: str, - graph_name: str, - location: Union[_models.ContinuousBackupRestoreLocation, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.BackupInformation]: - """Retrieves continuous backup information for a gremlin graph. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param account_name: Cosmos DB database account name. Required. - :type account_name: str - :param database_name: Cosmos DB database name. Required. - :type database_name: str - :param graph_name: Cosmos DB graph name. Required. - :type graph_name: str - :param location: The name of the continuous backup restore location. Is either a - ContinuousBackupRestoreLocation type or a IO[bytes] type. Required. - :type location: ~azure.mgmt.cosmosdb.models.ContinuousBackupRestoreLocation or IO[bytes] - :return: An instance of AsyncLROPoller that returns either BackupInformation or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.BackupInformation] - :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.BackupInformation] = 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._retrieve_continuous_backup_information_initial( - resource_group_name=resource_group_name, - account_name=account_name, - database_name=database_name, - graph_name=graph_name, - location=location, - 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("BackupInformation", 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": "location"}, **kwargs) @@ -3346,12 +3439,10 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller[_models.BackupInformation].from_continuation_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[_models.BackupInformation]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/aio/operations/_locations_operations.py b/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/aio/operations/_locations_operations.py index 51e7fdc95b9..46c009d82b0 100644 --- a/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/aio/operations/_locations_operations.py +++ b/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/aio/operations/_locations_operations.py @@ -110,7 +110,7 @@ async def extract_data(pipeline_response): list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore - return None, AsyncList(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): _request = prepare_request(next_link) diff --git a/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/aio/operations/_mongo_db_resources_operations.py b/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/aio/operations/_mongo_db_resources_operations.py index a9dc8f26901..383c3b4e244 100644 --- a/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/aio/operations/_mongo_db_resources_operations.py +++ b/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/aio/operations/_mongo_db_resources_operations.py @@ -159,7 +159,7 @@ async def extract_data(pipeline_response): list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore - return None, AsyncList(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): _request = prepare_request(next_link) @@ -172,7 +172,11 @@ 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response @@ -230,7 +234,11 @@ async def get_mongo_db_database( if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("MongoDBDatabaseGetResults", pipeline_response.http_response) @@ -300,14 +308,19 @@ async def _create_update_mongo_db_database_initial( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + 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["azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("azure-AsyncOperation") + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") ) - response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) @@ -444,7 +457,9 @@ def get_long_running_output(pipeline_response): return deserialized if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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: @@ -502,14 +517,18 @@ async def _delete_mongo_db_database_initial( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + 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["azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("azure-AsyncOperation") + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") ) - response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) @@ -562,7 +581,9 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- return cls(pipeline_response, None, {}) # type: ignore if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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: @@ -576,12 +597,11 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- ) return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - @distributed_trace_async - async def get_mongo_db_database_throughput( + @distributed_trace + def list_mongo_db_collections( self, resource_group_name: str, account_name: str, database_name: str, **kwargs: Any - ) -> _models.ThroughputSettingsGetResults: - """Gets the RUs per second of the MongoDB database under an existing Azure Cosmos DB database - account with the provided name. + ) -> AsyncItemPaged["_models.MongoDBCollectionGetResults"]: + """Lists the MongoDB collection under an existing Azure Cosmos DB database account. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -590,8 +610,102 @@ async def get_mongo_db_database_throughput( :type account_name: str :param database_name: Cosmos DB database name. Required. :type database_name: str - :return: ThroughputSettingsGetResults or the result of cls(response) - :rtype: ~azure.mgmt.cosmosdb.models.ThroughputSettingsGetResults + :return: An iterator like instance of either MongoDBCollectionGetResults or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.MongoDBCollectionGetResults] + :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.MongoDBCollectionListResult] = 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_mongo_db_collections_request( + resource_group_name=resource_group_name, + account_name=account_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) + + 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("MongoDBCollectionListResult", 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_mongo_db_collection( + self, resource_group_name: str, account_name: str, database_name: str, collection_name: str, **kwargs: Any + ) -> _models.MongoDBCollectionGetResults: + """Gets the MongoDB collection under an existing Azure Cosmos DB database account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param database_name: Cosmos DB database name. Required. + :type database_name: str + :param collection_name: Cosmos DB collection name. Required. + :type collection_name: str + :return: MongoDBCollectionGetResults or the result of cls(response) + :rtype: ~azure.mgmt.cosmosdb.models.MongoDBCollectionGetResults :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -606,12 +720,13 @@ async def get_mongo_db_database_throughput( _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.ThroughputSettingsGetResults] = kwargs.pop("cls", None) + cls: ClsType[_models.MongoDBCollectionGetResults] = kwargs.pop("cls", None) - _request = build_get_mongo_db_database_throughput_request( + _request = build_get_mongo_db_collection_request( resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, + collection_name=collection_name, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, @@ -628,21 +743,26 @@ async def get_mongo_db_database_throughput( if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("ThroughputSettingsGetResults", pipeline_response.http_response) + deserialized = self._deserialize("MongoDBCollectionGetResults", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - async def _update_mongo_db_database_throughput_initial( # pylint: disable=name-too-long + async def _create_update_mongo_db_collection_initial( # pylint: disable=name-too-long self, resource_group_name: str, account_name: str, database_name: str, - update_throughput_parameters: Union[_models.ThroughputSettingsUpdateParameters, IO[bytes]], + collection_name: str, + create_update_mongo_db_collection_parameters: Union[_models.MongoDBCollectionCreateUpdateParameters, IO[bytes]], **kwargs: Any ) -> AsyncIterator[bytes]: error_map: MutableMapping = { @@ -663,15 +783,18 @@ async def _update_mongo_db_database_throughput_initial( # pylint: disable=name- content_type = content_type or "application/json" _json = None _content = None - if isinstance(update_throughput_parameters, (IOBase, bytes)): - _content = update_throughput_parameters + if isinstance(create_update_mongo_db_collection_parameters, (IOBase, bytes)): + _content = create_update_mongo_db_collection_parameters else: - _json = self._serialize.body(update_throughput_parameters, "ThroughputSettingsUpdateParameters") + _json = self._serialize.body( + create_update_mongo_db_collection_parameters, "MongoDBCollectionCreateUpdateParameters" + ) - _request = build_update_mongo_db_database_throughput_request( + _request = build_create_update_mongo_db_collection_request( resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, + collection_name=collection_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, @@ -696,14 +819,19 @@ async def _update_mongo_db_database_throughput_initial( # pylint: disable=name- except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + 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["azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("azure-AsyncOperation") + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") ) - response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) @@ -713,17 +841,18 @@ async def _update_mongo_db_database_throughput_initial( # pylint: disable=name- return deserialized # type: ignore @overload - async def begin_update_mongo_db_database_throughput( # pylint: disable=name-too-long + async def begin_create_update_mongo_db_collection( self, resource_group_name: str, account_name: str, database_name: str, - update_throughput_parameters: _models.ThroughputSettingsUpdateParameters, + collection_name: str, + create_update_mongo_db_collection_parameters: _models.MongoDBCollectionCreateUpdateParameters, *, content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller[_models.ThroughputSettingsGetResults]: - """Update RUs per second of the an Azure Cosmos DB MongoDB database. + ) -> AsyncLROPoller[_models.MongoDBCollectionGetResults]: + """Create or update an Azure Cosmos DB MongoDB Collection. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -732,32 +861,35 @@ async def begin_update_mongo_db_database_throughput( # pylint: disable=name-too :type account_name: str :param database_name: Cosmos DB database name. Required. :type database_name: str - :param update_throughput_parameters: The RUs per second of the parameters to provide for the - current MongoDB database. Required. - :type update_throughput_parameters: - ~azure.mgmt.cosmosdb.models.ThroughputSettingsUpdateParameters + :param collection_name: Cosmos DB collection name. Required. + :type collection_name: str + :param create_update_mongo_db_collection_parameters: The parameters to provide for the current + MongoDB Collection. Required. + :type create_update_mongo_db_collection_parameters: + ~azure.mgmt.cosmosdb.models.MongoDBCollectionCreateUpdateParameters :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 ThroughputSettingsGetResults or the + :return: An instance of AsyncLROPoller that returns either MongoDBCollectionGetResults or the result of cls(response) :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.ThroughputSettingsGetResults] + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.MongoDBCollectionGetResults] :raises ~azure.core.exceptions.HttpResponseError: """ @overload - async def begin_update_mongo_db_database_throughput( # pylint: disable=name-too-long + async def begin_create_update_mongo_db_collection( self, resource_group_name: str, account_name: str, database_name: str, - update_throughput_parameters: IO[bytes], + collection_name: str, + create_update_mongo_db_collection_parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller[_models.ThroughputSettingsGetResults]: - """Update RUs per second of the an Azure Cosmos DB MongoDB database. + ) -> AsyncLROPoller[_models.MongoDBCollectionGetResults]: + """Create or update an Azure Cosmos DB MongoDB Collection. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -766,29 +898,32 @@ async def begin_update_mongo_db_database_throughput( # pylint: disable=name-too :type account_name: str :param database_name: Cosmos DB database name. Required. :type database_name: str - :param update_throughput_parameters: The RUs per second of the parameters to provide for the - current MongoDB database. Required. - :type update_throughput_parameters: IO[bytes] + :param collection_name: Cosmos DB collection name. Required. + :type collection_name: str + :param create_update_mongo_db_collection_parameters: The parameters to provide for the current + MongoDB Collection. Required. + :type create_update_mongo_db_collection_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 ThroughputSettingsGetResults or the + :return: An instance of AsyncLROPoller that returns either MongoDBCollectionGetResults or the result of cls(response) :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.ThroughputSettingsGetResults] + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.MongoDBCollectionGetResults] :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace_async - async def begin_update_mongo_db_database_throughput( # pylint: disable=name-too-long + async def begin_create_update_mongo_db_collection( self, resource_group_name: str, account_name: str, database_name: str, - update_throughput_parameters: Union[_models.ThroughputSettingsUpdateParameters, IO[bytes]], + collection_name: str, + create_update_mongo_db_collection_parameters: Union[_models.MongoDBCollectionCreateUpdateParameters, IO[bytes]], **kwargs: Any - ) -> AsyncLROPoller[_models.ThroughputSettingsGetResults]: - """Update RUs per second of the an Azure Cosmos DB MongoDB database. + ) -> AsyncLROPoller[_models.MongoDBCollectionGetResults]: + """Create or update an Azure Cosmos DB MongoDB Collection. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -797,15 +932,17 @@ async def begin_update_mongo_db_database_throughput( # pylint: disable=name-too :type account_name: str :param database_name: Cosmos DB database name. Required. :type database_name: str - :param update_throughput_parameters: The RUs per second of the parameters to provide for the - current MongoDB database. Is either a ThroughputSettingsUpdateParameters type or a IO[bytes] + :param collection_name: Cosmos DB collection name. Required. + :type collection_name: str + :param create_update_mongo_db_collection_parameters: The parameters to provide for the current + MongoDB Collection. Is either a MongoDBCollectionCreateUpdateParameters type or a IO[bytes] type. Required. - :type update_throughput_parameters: - ~azure.mgmt.cosmosdb.models.ThroughputSettingsUpdateParameters or IO[bytes] - :return: An instance of AsyncLROPoller that returns either ThroughputSettingsGetResults or the + :type create_update_mongo_db_collection_parameters: + ~azure.mgmt.cosmosdb.models.MongoDBCollectionCreateUpdateParameters or IO[bytes] + :return: An instance of AsyncLROPoller that returns either MongoDBCollectionGetResults or the result of cls(response) :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.ThroughputSettingsGetResults] + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.MongoDBCollectionGetResults] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -813,16 +950,17 @@ async def begin_update_mongo_db_database_throughput( # pylint: disable=name-too 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.ThroughputSettingsGetResults] = kwargs.pop("cls", None) + cls: ClsType[_models.MongoDBCollectionGetResults] = 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_mongo_db_database_throughput_initial( + raw_result = await self._create_update_mongo_db_collection_initial( resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, - update_throughput_parameters=update_throughput_parameters, + collection_name=collection_name, + create_update_mongo_db_collection_parameters=create_update_mongo_db_collection_parameters, api_version=api_version, content_type=content_type, cls=lambda x, y, z: x, @@ -834,30 +972,32 @@ async def begin_update_mongo_db_database_throughput( # pylint: disable=name-too kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ThroughputSettingsGetResults", pipeline_response.http_response) + deserialized = self._deserialize("MongoDBCollectionGetResults", 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, **kwargs)) + 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.ThroughputSettingsGetResults].from_continuation_token( + return AsyncLROPoller[_models.MongoDBCollectionGetResults].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller[_models.ThroughputSettingsGetResults]( + return AsyncLROPoller[_models.MongoDBCollectionGetResults]( self._client, raw_result, get_long_running_output, polling_method # type: ignore ) - async def _migrate_mongo_db_database_to_autoscale_initial( # pylint: disable=name-too-long - self, resource_group_name: str, account_name: str, database_name: str, **kwargs: Any + async def _delete_mongo_db_collection_initial( + self, resource_group_name: str, account_name: str, database_name: str, collection_name: str, **kwargs: Any ) -> AsyncIterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -873,10 +1013,11 @@ async def _migrate_mongo_db_database_to_autoscale_initial( # pylint: disable=na 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_migrate_mongo_db_database_to_autoscale_request( + _request = build_delete_mongo_db_collection_request( resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, + collection_name=collection_name, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, @@ -892,20 +1033,24 @@ async def _migrate_mongo_db_database_to_autoscale_initial( # pylint: disable=na response = pipeline_response.http_response - if response.status_code not in [200, 202]: + 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + 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["azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("azure-AsyncOperation") + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") ) - response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) @@ -915,10 +1060,10 @@ async def _migrate_mongo_db_database_to_autoscale_initial( # pylint: disable=na return deserialized # type: ignore @distributed_trace_async - async def begin_migrate_mongo_db_database_to_autoscale( # pylint: disable=name-too-long - self, resource_group_name: str, account_name: str, database_name: str, **kwargs: Any - ) -> AsyncLROPoller[_models.ThroughputSettingsGetResults]: - """Migrate an Azure Cosmos DB MongoDB database from manual throughput to autoscale. + async def begin_delete_mongo_db_collection( + self, resource_group_name: str, account_name: str, database_name: str, collection_name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Deletes an existing Azure Cosmos DB MongoDB Collection. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -927,25 +1072,26 @@ async def begin_migrate_mongo_db_database_to_autoscale( # pylint: disable=name- :type account_name: str :param database_name: Cosmos DB database name. Required. :type database_name: str - :return: An instance of AsyncLROPoller that returns either ThroughputSettingsGetResults or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.ThroughputSettingsGetResults] + :param collection_name: Cosmos DB collection name. Required. + :type collection_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[_models.ThroughputSettingsGetResults] = kwargs.pop("cls", 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._migrate_mongo_db_database_to_autoscale_initial( + raw_result = await self._delete_mongo_db_collection_initial( resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, + collection_name=collection_name, api_version=api_version, cls=lambda x, y, z: x, headers=_headers, @@ -955,31 +1101,35 @@ async def begin_migrate_mongo_db_database_to_autoscale( # pylint: disable=name- await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ThroughputSettingsGetResults", pipeline_response.http_response) + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return cls(pipeline_response, None, {}) # type: ignore if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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.ThroughputSettingsGetResults].from_continuation_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[_models.ThroughputSettingsGetResults]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - async def _migrate_mongo_db_database_to_manual_throughput_initial( # pylint: disable=name-too-long - self, resource_group_name: str, account_name: str, database_name: str, **kwargs: Any + async def _list_mongo_db_collection_partition_merge_initial( # pylint: disable=name-too-long + self, + resource_group_name: str, + account_name: str, + database_name: str, + collection_name: str, + merge_parameters: Union[_models.MergeParameters, IO[bytes]], + **kwargs: Any ) -> AsyncIterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -989,18 +1139,31 @@ async def _migrate_mongo_db_database_to_manual_throughput_initial( # pylint: di } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) 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) - _request = build_migrate_mongo_db_database_to_manual_throughput_request( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(merge_parameters, (IOBase, bytes)): + _content = merge_parameters + else: + _json = self._serialize.body(merge_parameters, "MergeParameters") + + _request = build_list_mongo_db_collection_partition_merge_request( resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, + collection_name=collection_name, subscription_id=self._config.subscription_id, api_version=api_version, + content_type=content_type, + json=_json, + content=_content, headers=_headers, params=_params, ) @@ -1024,10 +1187,11 @@ async def _migrate_mongo_db_database_to_manual_throughput_initial( # pylint: di response_headers = {} if response.status_code == 202: - response_headers["azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("azure-AsyncOperation") + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") ) - response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) @@ -1036,11 +1200,87 @@ async def _migrate_mongo_db_database_to_manual_throughput_initial( # pylint: di return deserialized # type: ignore + @overload + async def begin_list_mongo_db_collection_partition_merge( # pylint: disable=name-too-long + self, + resource_group_name: str, + account_name: str, + database_name: str, + collection_name: str, + merge_parameters: _models.MergeParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.PhysicalPartitionStorageInfoCollection]: + """Merges the partitions of a MongoDB Collection. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param database_name: Cosmos DB database name. Required. + :type database_name: str + :param collection_name: Cosmos DB collection name. Required. + :type collection_name: str + :param merge_parameters: The parameters for the merge operation. Required. + :type merge_parameters: ~azure.mgmt.cosmosdb.models.MergeParameters + :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 + PhysicalPartitionStorageInfoCollection or the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.PhysicalPartitionStorageInfoCollection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_list_mongo_db_collection_partition_merge( # pylint: disable=name-too-long + self, + resource_group_name: str, + account_name: str, + database_name: str, + collection_name: str, + merge_parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.PhysicalPartitionStorageInfoCollection]: + """Merges the partitions of a MongoDB Collection. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param database_name: Cosmos DB database name. Required. + :type database_name: str + :param collection_name: Cosmos DB collection name. Required. + :type collection_name: str + :param merge_parameters: The parameters for the merge operation. Required. + :type merge_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 + PhysicalPartitionStorageInfoCollection or the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.PhysicalPartitionStorageInfoCollection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + @distributed_trace_async - async def begin_migrate_mongo_db_database_to_manual_throughput( # pylint: disable=name-too-long - self, resource_group_name: str, account_name: str, database_name: str, **kwargs: Any - ) -> AsyncLROPoller[_models.ThroughputSettingsGetResults]: - """Migrate an Azure Cosmos DB MongoDB database from autoscale to manual throughput. + async def begin_list_mongo_db_collection_partition_merge( # pylint: disable=name-too-long + self, + resource_group_name: str, + account_name: str, + database_name: str, + collection_name: str, + merge_parameters: Union[_models.MergeParameters, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.PhysicalPartitionStorageInfoCollection]: + """Merges the partitions of a MongoDB Collection. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -1049,26 +1289,35 @@ async def begin_migrate_mongo_db_database_to_manual_throughput( # pylint: disab :type account_name: str :param database_name: Cosmos DB database name. Required. :type database_name: str - :return: An instance of AsyncLROPoller that returns either ThroughputSettingsGetResults or the - result of cls(response) + :param collection_name: Cosmos DB collection name. Required. + :type collection_name: str + :param merge_parameters: The parameters for the merge operation. Is either a MergeParameters + type or a IO[bytes] type. Required. + :type merge_parameters: ~azure.mgmt.cosmosdb.models.MergeParameters or IO[bytes] + :return: An instance of AsyncLROPoller that returns either + PhysicalPartitionStorageInfoCollection or the result of cls(response) :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.ThroughputSettingsGetResults] + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.PhysicalPartitionStorageInfoCollection] :raises ~azure.core.exceptions.HttpResponseError: """ - _headers = kwargs.pop("headers", {}) 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)) - cls: ClsType[_models.ThroughputSettingsGetResults] = kwargs.pop("cls", None) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.PhysicalPartitionStorageInfoCollection] = 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_mongo_db_database_to_manual_throughput_initial( + raw_result = await self._list_mongo_db_collection_partition_merge_initial( resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, + collection_name=collection_name, + merge_parameters=merge_parameters, api_version=api_version, + content_type=content_type, cls=lambda x, y, z: x, headers=_headers, params=_params, @@ -1078,34 +1327,37 @@ async def begin_migrate_mongo_db_database_to_manual_throughput( # pylint: disab kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ThroughputSettingsGetResults", pipeline_response.http_response) + deserialized = self._deserialize("PhysicalPartitionStorageInfoCollection", 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, **kwargs)) + 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.ThroughputSettingsGetResults].from_continuation_token( + return AsyncLROPoller[_models.PhysicalPartitionStorageInfoCollection].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller[_models.ThroughputSettingsGetResults]( + return AsyncLROPoller[_models.PhysicalPartitionStorageInfoCollection]( self._client, raw_result, get_long_running_output, polling_method # type: ignore ) - async def _mongo_db_database_retrieve_throughput_distribution_initial( # pylint: disable=name-too-long + async def _retrieve_continuous_backup_information_initial( # pylint: disable=name-too-long self, resource_group_name: str, account_name: str, database_name: str, - retrieve_throughput_parameters: Union[_models.RetrieveThroughputParameters, IO[bytes]], + collection_name: str, + location: Union[_models.ContinuousBackupRestoreLocation, IO[bytes]], **kwargs: Any ) -> AsyncIterator[bytes]: error_map: MutableMapping = { @@ -1126,15 +1378,16 @@ async def _mongo_db_database_retrieve_throughput_distribution_initial( # pylint content_type = content_type or "application/json" _json = None _content = None - if isinstance(retrieve_throughput_parameters, (IOBase, bytes)): - _content = retrieve_throughput_parameters + if isinstance(location, (IOBase, bytes)): + _content = location else: - _json = self._serialize.body(retrieve_throughput_parameters, "RetrieveThroughputParameters") + _json = self._serialize.body(location, "ContinuousBackupRestoreLocation") - _request = build_mongo_db_database_retrieve_throughput_distribution_request( + _request = build_retrieve_continuous_backup_information_request( resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, + collection_name=collection_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, @@ -1163,10 +1416,8 @@ async def _mongo_db_database_retrieve_throughput_distribution_initial( # pylint 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["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) @@ -1176,17 +1427,18 @@ async def _mongo_db_database_retrieve_throughput_distribution_initial( # pylint return deserialized # type: ignore @overload - async def begin_mongo_db_database_retrieve_throughput_distribution( # pylint: disable=name-too-long + async def begin_retrieve_continuous_backup_information( # pylint: disable=name-too-long self, resource_group_name: str, account_name: str, database_name: str, - retrieve_throughput_parameters: _models.RetrieveThroughputParameters, + collection_name: str, + location: _models.ContinuousBackupRestoreLocation, *, content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller[_models.PhysicalPartitionThroughputInfoResult]: - """Retrieve throughput distribution for an Azure Cosmos DB MongoDB database. + ) -> AsyncLROPoller[_models.BackupInformation]: + """Retrieves continuous backup information for a Mongodb collection. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -1195,31 +1447,32 @@ async def begin_mongo_db_database_retrieve_throughput_distribution( # pylint: d :type account_name: str :param database_name: Cosmos DB database name. Required. :type database_name: str - :param retrieve_throughput_parameters: The parameters to provide for retrieving throughput - distribution for the current MongoDB database. Required. - :type retrieve_throughput_parameters: ~azure.mgmt.cosmosdb.models.RetrieveThroughputParameters + :param collection_name: Cosmos DB collection name. Required. + :type collection_name: str + :param location: The name of the continuous backup restore location. Required. + :type location: ~azure.mgmt.cosmosdb.models.ContinuousBackupRestoreLocation :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 - PhysicalPartitionThroughputInfoResult or the result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.PhysicalPartitionThroughputInfoResult] + :return: An instance of AsyncLROPoller that returns either BackupInformation or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.BackupInformation] :raises ~azure.core.exceptions.HttpResponseError: """ @overload - async def begin_mongo_db_database_retrieve_throughput_distribution( # pylint: disable=name-too-long + async def begin_retrieve_continuous_backup_information( # pylint: disable=name-too-long self, resource_group_name: str, account_name: str, database_name: str, - retrieve_throughput_parameters: IO[bytes], + collection_name: str, + location: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller[_models.PhysicalPartitionThroughputInfoResult]: - """Retrieve throughput distribution for an Azure Cosmos DB MongoDB database. + ) -> AsyncLROPoller[_models.BackupInformation]: + """Retrieves continuous backup information for a Mongodb collection. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -1228,29 +1481,30 @@ async def begin_mongo_db_database_retrieve_throughput_distribution( # pylint: d :type account_name: str :param database_name: Cosmos DB database name. Required. :type database_name: str - :param retrieve_throughput_parameters: The parameters to provide for retrieving throughput - distribution for the current MongoDB database. Required. - :type retrieve_throughput_parameters: IO[bytes] + :param collection_name: Cosmos DB collection name. Required. + :type collection_name: str + :param location: The name of the continuous backup restore location. Required. + :type location: 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 - PhysicalPartitionThroughputInfoResult or the result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.PhysicalPartitionThroughputInfoResult] + :return: An instance of AsyncLROPoller that returns either BackupInformation or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.BackupInformation] :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace_async - async def begin_mongo_db_database_retrieve_throughput_distribution( # pylint: disable=name-too-long + async def begin_retrieve_continuous_backup_information( # pylint: disable=name-too-long self, resource_group_name: str, account_name: str, database_name: str, - retrieve_throughput_parameters: Union[_models.RetrieveThroughputParameters, IO[bytes]], + collection_name: str, + location: Union[_models.ContinuousBackupRestoreLocation, IO[bytes]], **kwargs: Any - ) -> AsyncLROPoller[_models.PhysicalPartitionThroughputInfoResult]: - """Retrieve throughput distribution for an Azure Cosmos DB MongoDB database. + ) -> AsyncLROPoller[_models.BackupInformation]: + """Retrieves continuous backup information for a Mongodb collection. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -1259,15 +1513,14 @@ async def begin_mongo_db_database_retrieve_throughput_distribution( # pylint: d :type account_name: str :param database_name: Cosmos DB database name. Required. :type database_name: str - :param retrieve_throughput_parameters: The parameters to provide for retrieving throughput - distribution for the current MongoDB database. Is either a RetrieveThroughputParameters type or - a IO[bytes] type. Required. - :type retrieve_throughput_parameters: ~azure.mgmt.cosmosdb.models.RetrieveThroughputParameters - or IO[bytes] - :return: An instance of AsyncLROPoller that returns either - PhysicalPartitionThroughputInfoResult or the result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.PhysicalPartitionThroughputInfoResult] + :param collection_name: Cosmos DB collection name. Required. + :type collection_name: str + :param location: The name of the continuous backup restore location. Is either a + ContinuousBackupRestoreLocation type or a IO[bytes] type. Required. + :type location: ~azure.mgmt.cosmosdb.models.ContinuousBackupRestoreLocation or IO[bytes] + :return: An instance of AsyncLROPoller that returns either BackupInformation or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.BackupInformation] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -1275,16 +1528,17 @@ async def begin_mongo_db_database_retrieve_throughput_distribution( # pylint: d 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.PhysicalPartitionThroughputInfoResult] = kwargs.pop("cls", None) + cls: ClsType[_models.BackupInformation] = 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._mongo_db_database_retrieve_throughput_distribution_initial( + raw_result = await self._retrieve_continuous_backup_information_initial( resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, - retrieve_throughput_parameters=retrieve_throughput_parameters, + collection_name=collection_name, + location=location, api_version=api_version, content_type=content_type, cls=lambda x, y, z: x, @@ -1296,7 +1550,7 @@ async def begin_mongo_db_database_retrieve_throughput_distribution( # pylint: d kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("PhysicalPartitionThroughputInfoResult", pipeline_response.http_response) + deserialized = self._deserialize("BackupInformation", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized @@ -1310,22 +1564,91 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller[_models.PhysicalPartitionThroughputInfoResult].from_continuation_token( + return AsyncLROPoller[_models.BackupInformation].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller[_models.PhysicalPartitionThroughputInfoResult]( + return AsyncLROPoller[_models.BackupInformation]( self._client, raw_result, get_long_running_output, polling_method # type: ignore ) - async def _mongo_db_database_redistribute_throughput_initial( # pylint: disable=name-too-long + @distributed_trace_async + async def get_mongo_db_collection_throughput( + self, resource_group_name: str, account_name: str, database_name: str, collection_name: str, **kwargs: Any + ) -> _models.ThroughputSettingsGetResults: + """Gets the RUs per second of the MongoDB collection under an existing Azure Cosmos DB database + account with the provided name. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param database_name: Cosmos DB database name. Required. + :type database_name: str + :param collection_name: Cosmos DB collection name. Required. + :type collection_name: str + :return: ThroughputSettingsGetResults or the result of cls(response) + :rtype: ~azure.mgmt.cosmosdb.models.ThroughputSettingsGetResults + :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.ThroughputSettingsGetResults] = kwargs.pop("cls", None) + + _request = build_get_mongo_db_collection_throughput_request( + resource_group_name=resource_group_name, + account_name=account_name, + database_name=database_name, + collection_name=collection_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("ThroughputSettingsGetResults", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + async def _update_mongo_db_collection_throughput_initial( # pylint: disable=name-too-long self, resource_group_name: str, account_name: str, database_name: str, - redistribute_throughput_parameters: Union[_models.RedistributeThroughputParameters, IO[bytes]], + collection_name: str, + update_throughput_parameters: Union[_models.ThroughputSettingsUpdateParameters, IO[bytes]], **kwargs: Any ) -> AsyncIterator[bytes]: error_map: MutableMapping = { @@ -1346,15 +1669,16 @@ async def _mongo_db_database_redistribute_throughput_initial( # pylint: disable content_type = content_type or "application/json" _json = None _content = None - if isinstance(redistribute_throughput_parameters, (IOBase, bytes)): - _content = redistribute_throughput_parameters + if isinstance(update_throughput_parameters, (IOBase, bytes)): + _content = update_throughput_parameters else: - _json = self._serialize.body(redistribute_throughput_parameters, "RedistributeThroughputParameters") + _json = self._serialize.body(update_throughput_parameters, "ThroughputSettingsUpdateParameters") - _request = build_mongo_db_database_redistribute_throughput_request( + _request = build_update_mongo_db_collection_throughput_request( resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, + collection_name=collection_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, @@ -1379,14 +1703,19 @@ async def _mongo_db_database_redistribute_throughput_initial( # pylint: disable except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + 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["azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("azure-AsyncOperation") + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") ) - response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) @@ -1396,17 +1725,18 @@ async def _mongo_db_database_redistribute_throughput_initial( # pylint: disable return deserialized # type: ignore @overload - async def begin_mongo_db_database_redistribute_throughput( # pylint: disable=name-too-long + async def begin_update_mongo_db_collection_throughput( # pylint: disable=name-too-long self, resource_group_name: str, account_name: str, database_name: str, - redistribute_throughput_parameters: _models.RedistributeThroughputParameters, + collection_name: str, + update_throughput_parameters: _models.ThroughputSettingsUpdateParameters, *, content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller[_models.PhysicalPartitionThroughputInfoResult]: - """Redistribute throughput for an Azure Cosmos DB MongoDB database. + ) -> AsyncLROPoller[_models.ThroughputSettingsGetResults]: + """Update the RUs per second of an Azure Cosmos DB MongoDB collection. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -1415,32 +1745,35 @@ async def begin_mongo_db_database_redistribute_throughput( # pylint: disable=na :type account_name: str :param database_name: Cosmos DB database name. Required. :type database_name: str - :param redistribute_throughput_parameters: The parameters to provide for redistributing - throughput for the current MongoDB database. Required. - :type redistribute_throughput_parameters: - ~azure.mgmt.cosmosdb.models.RedistributeThroughputParameters + :param collection_name: Cosmos DB collection name. Required. + :type collection_name: str + :param update_throughput_parameters: The RUs per second of the parameters to provide for the + current MongoDB collection. Required. + :type update_throughput_parameters: + ~azure.mgmt.cosmosdb.models.ThroughputSettingsUpdateParameters :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 - PhysicalPartitionThroughputInfoResult or the result of cls(response) + :return: An instance of AsyncLROPoller that returns either ThroughputSettingsGetResults or the + result of cls(response) :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.PhysicalPartitionThroughputInfoResult] + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.ThroughputSettingsGetResults] :raises ~azure.core.exceptions.HttpResponseError: """ @overload - async def begin_mongo_db_database_redistribute_throughput( # pylint: disable=name-too-long + async def begin_update_mongo_db_collection_throughput( # pylint: disable=name-too-long self, resource_group_name: str, account_name: str, database_name: str, - redistribute_throughput_parameters: IO[bytes], + collection_name: str, + update_throughput_parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller[_models.PhysicalPartitionThroughputInfoResult]: - """Redistribute throughput for an Azure Cosmos DB MongoDB database. + ) -> AsyncLROPoller[_models.ThroughputSettingsGetResults]: + """Update the RUs per second of an Azure Cosmos DB MongoDB collection. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -1449,29 +1782,32 @@ async def begin_mongo_db_database_redistribute_throughput( # pylint: disable=na :type account_name: str :param database_name: Cosmos DB database name. Required. :type database_name: str - :param redistribute_throughput_parameters: The parameters to provide for redistributing - throughput for the current MongoDB database. Required. - :type redistribute_throughput_parameters: IO[bytes] + :param collection_name: Cosmos DB collection name. Required. + :type collection_name: str + :param update_throughput_parameters: The RUs per second of the parameters to provide for the + current MongoDB collection. Required. + :type update_throughput_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 - PhysicalPartitionThroughputInfoResult or the result of cls(response) + :return: An instance of AsyncLROPoller that returns either ThroughputSettingsGetResults or the + result of cls(response) :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.PhysicalPartitionThroughputInfoResult] + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.ThroughputSettingsGetResults] :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace_async - async def begin_mongo_db_database_redistribute_throughput( # pylint: disable=name-too-long + async def begin_update_mongo_db_collection_throughput( # pylint: disable=name-too-long self, resource_group_name: str, account_name: str, database_name: str, - redistribute_throughput_parameters: Union[_models.RedistributeThroughputParameters, IO[bytes]], + collection_name: str, + update_throughput_parameters: Union[_models.ThroughputSettingsUpdateParameters, IO[bytes]], **kwargs: Any - ) -> AsyncLROPoller[_models.PhysicalPartitionThroughputInfoResult]: - """Redistribute throughput for an Azure Cosmos DB MongoDB database. + ) -> AsyncLROPoller[_models.ThroughputSettingsGetResults]: + """Update the RUs per second of an Azure Cosmos DB MongoDB collection. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -1480,15 +1816,17 @@ async def begin_mongo_db_database_redistribute_throughput( # pylint: disable=na :type account_name: str :param database_name: Cosmos DB database name. Required. :type database_name: str - :param redistribute_throughput_parameters: The parameters to provide for redistributing - throughput for the current MongoDB database. Is either a RedistributeThroughputParameters type - or a IO[bytes] type. Required. - :type redistribute_throughput_parameters: - ~azure.mgmt.cosmosdb.models.RedistributeThroughputParameters or IO[bytes] - :return: An instance of AsyncLROPoller that returns either - PhysicalPartitionThroughputInfoResult or the result of cls(response) + :param collection_name: Cosmos DB collection name. Required. + :type collection_name: str + :param update_throughput_parameters: The RUs per second of the parameters to provide for the + current MongoDB collection. Is either a ThroughputSettingsUpdateParameters type or a IO[bytes] + type. Required. + :type update_throughput_parameters: + ~azure.mgmt.cosmosdb.models.ThroughputSettingsUpdateParameters or IO[bytes] + :return: An instance of AsyncLROPoller that returns either ThroughputSettingsGetResults or the + result of cls(response) :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.PhysicalPartitionThroughputInfoResult] + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.ThroughputSettingsGetResults] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -1496,16 +1834,17 @@ async def begin_mongo_db_database_redistribute_throughput( # pylint: disable=na 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.PhysicalPartitionThroughputInfoResult] = kwargs.pop("cls", None) + cls: ClsType[_models.ThroughputSettingsGetResults] = 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._mongo_db_database_redistribute_throughput_initial( + raw_result = await self._update_mongo_db_collection_throughput_initial( resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, - redistribute_throughput_parameters=redistribute_throughput_parameters, + collection_name=collection_name, + update_throughput_parameters=update_throughput_parameters, api_version=api_version, content_type=content_type, cls=lambda x, y, z: x, @@ -1517,7 +1856,7 @@ async def begin_mongo_db_database_redistribute_throughput( # pylint: disable=na kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("PhysicalPartitionThroughputInfoResult", pipeline_response.http_response) + deserialized = self._deserialize("ThroughputSettingsGetResults", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized @@ -1531,24 +1870,18 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller[_models.PhysicalPartitionThroughputInfoResult].from_continuation_token( + return AsyncLROPoller[_models.ThroughputSettingsGetResults].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller[_models.PhysicalPartitionThroughputInfoResult]( + return AsyncLROPoller[_models.ThroughputSettingsGetResults]( self._client, raw_result, get_long_running_output, polling_method # type: ignore ) - async def _mongo_db_container_retrieve_throughput_distribution_initial( # pylint: disable=name-too-long - self, - resource_group_name: str, - account_name: str, - database_name: str, - collection_name: str, - retrieve_throughput_parameters: Union[_models.RetrieveThroughputParameters, IO[bytes]], - **kwargs: Any + async def _migrate_mongo_db_collection_to_autoscale_initial( # pylint: disable=name-too-long + self, resource_group_name: str, account_name: str, database_name: str, collection_name: str, **kwargs: Any ) -> AsyncIterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -1558,31 +1891,19 @@ async def _mongo_db_container_retrieve_throughput_distribution_initial( # pylin } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = case_insensitive_dict(kwargs.pop("headers", {}) 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)) - 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(retrieve_throughput_parameters, (IOBase, bytes)): - _content = retrieve_throughput_parameters - else: - _json = self._serialize.body(retrieve_throughput_parameters, "RetrieveThroughputParameters") - - _request = build_mongo_db_container_retrieve_throughput_distribution_request( + _request = build_migrate_mongo_db_collection_to_autoscale_request( resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, collection_name=collection_name, subscription_id=self._config.subscription_id, api_version=api_version, - content_type=content_type, - json=_json, - content=_content, headers=_headers, params=_params, ) @@ -1606,10 +1927,11 @@ async def _mongo_db_container_retrieve_throughput_distribution_initial( # pylin response_headers = {} if response.status_code == 202: - response_headers["azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("azure-AsyncOperation") + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") ) - response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) @@ -1618,19 +1940,11 @@ async def _mongo_db_container_retrieve_throughput_distribution_initial( # pylin return deserialized # type: ignore - @overload - async def begin_mongo_db_container_retrieve_throughput_distribution( # pylint: disable=name-too-long - self, - resource_group_name: str, - account_name: str, - database_name: str, - collection_name: str, - retrieve_throughput_parameters: _models.RetrieveThroughputParameters, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.PhysicalPartitionThroughputInfoResult]: - """Retrieve throughput distribution for an Azure Cosmos DB MongoDB container. + @distributed_trace_async + async def begin_migrate_mongo_db_collection_to_autoscale( # pylint: disable=name-too-long + self, resource_group_name: str, account_name: str, database_name: str, collection_name: str, **kwargs: Any + ) -> AsyncLROPoller[_models.ThroughputSettingsGetResults]: + """Migrate an Azure Cosmos DB MongoDB collection from manual throughput to autoscale. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -1641,66 +1955,125 @@ async def begin_mongo_db_container_retrieve_throughput_distribution( # pylint: :type database_name: str :param collection_name: Cosmos DB collection name. Required. :type collection_name: str - :param retrieve_throughput_parameters: The parameters to provide for retrieving throughput - distribution for the current MongoDB container. Required. - :type retrieve_throughput_parameters: ~azure.mgmt.cosmosdb.models.RetrieveThroughputParameters - :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 - PhysicalPartitionThroughputInfoResult or the result of cls(response) + :return: An instance of AsyncLROPoller that returns either ThroughputSettingsGetResults or the + result of cls(response) :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.PhysicalPartitionThroughputInfoResult] + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.ThroughputSettingsGetResults] :raises ~azure.core.exceptions.HttpResponseError: """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - @overload - async def begin_mongo_db_container_retrieve_throughput_distribution( # pylint: disable=name-too-long - self, - resource_group_name: str, - account_name: str, - database_name: str, - collection_name: str, - retrieve_throughput_parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.PhysicalPartitionThroughputInfoResult]: - """Retrieve throughput distribution for an Azure Cosmos DB MongoDB container. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param account_name: Cosmos DB database account name. Required. - :type account_name: str - :param database_name: Cosmos DB database name. Required. - :type database_name: str - :param collection_name: Cosmos DB collection name. Required. - :type collection_name: str - :param retrieve_throughput_parameters: The parameters to provide for retrieving throughput - distribution for the current MongoDB container. Required. - :type retrieve_throughput_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 - PhysicalPartitionThroughputInfoResult or the result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.PhysicalPartitionThroughputInfoResult] - :raises ~azure.core.exceptions.HttpResponseError: - """ + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.ThroughputSettingsGetResults] = 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_mongo_db_collection_to_autoscale_initial( + resource_group_name=resource_group_name, + account_name=account_name, + database_name=database_name, + collection_name=collection_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("ThroughputSettingsGetResults", 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": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.ThroughputSettingsGetResults].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.ThroughputSettingsGetResults]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + async def _migrate_mongo_db_collection_to_manual_throughput_initial( # pylint: disable=name-too-long + self, resource_group_name: str, account_name: str, database_name: str, collection_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_migrate_mongo_db_collection_to_manual_throughput_request( + resource_group_name=resource_group_name, + account_name=account_name, + database_name=database_name, + collection_name=collection_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) + raise HttpResponseError(response=response, 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.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_mongo_db_container_retrieve_throughput_distribution( # pylint: disable=name-too-long - self, - resource_group_name: str, - account_name: str, - database_name: str, - collection_name: str, - retrieve_throughput_parameters: Union[_models.RetrieveThroughputParameters, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.PhysicalPartitionThroughputInfoResult]: - """Retrieve throughput distribution for an Azure Cosmos DB MongoDB container. + async def begin_migrate_mongo_db_collection_to_manual_throughput( # pylint: disable=name-too-long + self, resource_group_name: str, account_name: str, database_name: str, collection_name: str, **kwargs: Any + ) -> AsyncLROPoller[_models.ThroughputSettingsGetResults]: + """Migrate an Azure Cosmos DB MongoDB collection from autoscale to manual throughput. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -1711,35 +2084,27 @@ async def begin_mongo_db_container_retrieve_throughput_distribution( # pylint: :type database_name: str :param collection_name: Cosmos DB collection name. Required. :type collection_name: str - :param retrieve_throughput_parameters: The parameters to provide for retrieving throughput - distribution for the current MongoDB container. Is either a RetrieveThroughputParameters type - or a IO[bytes] type. Required. - :type retrieve_throughput_parameters: ~azure.mgmt.cosmosdb.models.RetrieveThroughputParameters - or IO[bytes] - :return: An instance of AsyncLROPoller that returns either - PhysicalPartitionThroughputInfoResult or the result of cls(response) + :return: An instance of AsyncLROPoller that returns either ThroughputSettingsGetResults or the + result of cls(response) :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.PhysicalPartitionThroughputInfoResult] + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.ThroughputSettingsGetResults] :raises ~azure.core.exceptions.HttpResponseError: """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) 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)) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.PhysicalPartitionThroughputInfoResult] = kwargs.pop("cls", None) + cls: ClsType[_models.ThroughputSettingsGetResults] = 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._mongo_db_container_retrieve_throughput_distribution_initial( + raw_result = await self._migrate_mongo_db_collection_to_manual_throughput_initial( resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, collection_name=collection_name, - retrieve_throughput_parameters=retrieve_throughput_parameters, api_version=api_version, - content_type=content_type, cls=lambda x, y, z: x, headers=_headers, params=_params, @@ -1749,7 +2114,7 @@ async def begin_mongo_db_container_retrieve_throughput_distribution( # pylint: kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("PhysicalPartitionThroughputInfoResult", pipeline_response.http_response) + deserialized = self._deserialize("ThroughputSettingsGetResults", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized @@ -1763,13 +2128,13 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller[_models.PhysicalPartitionThroughputInfoResult].from_continuation_token( + return AsyncLROPoller[_models.ThroughputSettingsGetResults].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller[_models.PhysicalPartitionThroughputInfoResult]( + return AsyncLROPoller[_models.ThroughputSettingsGetResults]( self._client, raw_result, get_long_running_output, polling_method # type: ignore ) @@ -1838,10 +2203,11 @@ async def _mongo_db_container_redistribute_throughput_initial( # pylint: disabl response_headers = {} if response.status_code == 202: - response_headers["azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("azure-AsyncOperation") + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") ) - response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) @@ -2006,31 +2372,15 @@ def get_long_running_output(pipeline_response): self._client, raw_result, get_long_running_output, polling_method # type: ignore ) - @distributed_trace - def list_mongo_db_collections( - self, resource_group_name: str, account_name: str, database_name: str, **kwargs: Any - ) -> AsyncItemPaged["_models.MongoDBCollectionGetResults"]: - """Lists the MongoDB collection under an existing Azure Cosmos DB database account. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param account_name: Cosmos DB database account name. Required. - :type account_name: str - :param database_name: Cosmos DB database name. Required. - :type database_name: str - :return: An iterator like instance of either MongoDBCollectionGetResults or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.MongoDBCollectionGetResults] - :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.MongoDBCollectionListResult] = kwargs.pop("cls", None) - + async def _mongo_db_container_retrieve_throughput_distribution_initial( # pylint: disable=name-too-long + self, + resource_group_name: str, + account_name: str, + database_name: str, + collection_name: str, + retrieve_throughput_parameters: Union[_models.RetrieveThroughputParameters, IO[bytes]], + **kwargs: Any + ) -> AsyncIterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -2039,180 +2389,43 @@ def list_mongo_db_collections( } error_map.update(kwargs.pop("error_map", {}) or {}) - def prepare_request(next_link=None): - if not next_link: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _request = build_list_mongo_db_collections_request( - resource_group_name=resource_group_name, - account_name=account_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) + 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) - 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 + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(retrieve_throughput_parameters, (IOBase, bytes)): + _content = retrieve_throughput_parameters + else: + _json = self._serialize.body(retrieve_throughput_parameters, "RetrieveThroughputParameters") - async def extract_data(pipeline_response): - deserialized = self._deserialize("MongoDBCollectionListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return None, AsyncList(list_of_elem) + _request = build_mongo_db_container_retrieve_throughput_distribution_request( + resource_group_name=resource_group_name, + account_name=account_name, + database_name=database_name, + collection_name=collection_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) - async def get_next(next_link=None): - _request = prepare_request(next_link) + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) - _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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace_async - async def get_mongo_db_collection( - self, resource_group_name: str, account_name: str, database_name: str, collection_name: str, **kwargs: Any - ) -> _models.MongoDBCollectionGetResults: - """Gets the MongoDB collection under an existing Azure Cosmos DB database account. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param account_name: Cosmos DB database account name. Required. - :type account_name: str - :param database_name: Cosmos DB database name. Required. - :type database_name: str - :param collection_name: Cosmos DB collection name. Required. - :type collection_name: str - :return: MongoDBCollectionGetResults or the result of cls(response) - :rtype: ~azure.mgmt.cosmosdb.models.MongoDBCollectionGetResults - :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.MongoDBCollectionGetResults] = kwargs.pop("cls", None) - - _request = build_get_mongo_db_collection_request( - resource_group_name=resource_group_name, - account_name=account_name, - database_name=database_name, - collection_name=collection_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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("MongoDBCollectionGetResults", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - async def _create_update_mongo_db_collection_initial( # pylint: disable=name-too-long - self, - resource_group_name: str, - account_name: str, - database_name: str, - collection_name: str, - create_update_mongo_db_collection_parameters: Union[_models.MongoDBCollectionCreateUpdateParameters, 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(create_update_mongo_db_collection_parameters, (IOBase, bytes)): - _content = create_update_mongo_db_collection_parameters - else: - _json = self._serialize.body( - create_update_mongo_db_collection_parameters, "MongoDBCollectionCreateUpdateParameters" - ) - - _request = build_create_update_mongo_db_collection_request( - resource_group_name=resource_group_name, - account_name=account_name, - database_name=database_name, - collection_name=collection_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 + response = pipeline_response.http_response if response.status_code not in [200, 202]: try: @@ -2224,10 +2437,11 @@ async def _create_update_mongo_db_collection_initial( # pylint: disable=name-to response_headers = {} if response.status_code == 202: - response_headers["azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("azure-AsyncOperation") + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") ) - response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) @@ -2237,18 +2451,18 @@ async def _create_update_mongo_db_collection_initial( # pylint: disable=name-to return deserialized # type: ignore @overload - async def begin_create_update_mongo_db_collection( + async def begin_mongo_db_container_retrieve_throughput_distribution( # pylint: disable=name-too-long self, resource_group_name: str, account_name: str, database_name: str, collection_name: str, - create_update_mongo_db_collection_parameters: _models.MongoDBCollectionCreateUpdateParameters, + retrieve_throughput_parameters: _models.RetrieveThroughputParameters, *, content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller[_models.MongoDBCollectionGetResults]: - """Create or update an Azure Cosmos DB MongoDB Collection. + ) -> AsyncLROPoller[_models.PhysicalPartitionThroughputInfoResult]: + """Retrieve throughput distribution for an Azure Cosmos DB MongoDB container. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -2259,33 +2473,32 @@ async def begin_create_update_mongo_db_collection( :type database_name: str :param collection_name: Cosmos DB collection name. Required. :type collection_name: str - :param create_update_mongo_db_collection_parameters: The parameters to provide for the current - MongoDB Collection. Required. - :type create_update_mongo_db_collection_parameters: - ~azure.mgmt.cosmosdb.models.MongoDBCollectionCreateUpdateParameters + :param retrieve_throughput_parameters: The parameters to provide for retrieving throughput + distribution for the current MongoDB container. Required. + :type retrieve_throughput_parameters: ~azure.mgmt.cosmosdb.models.RetrieveThroughputParameters :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 MongoDBCollectionGetResults or the - result of cls(response) + :return: An instance of AsyncLROPoller that returns either + PhysicalPartitionThroughputInfoResult or the result of cls(response) :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.MongoDBCollectionGetResults] + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.PhysicalPartitionThroughputInfoResult] :raises ~azure.core.exceptions.HttpResponseError: """ @overload - async def begin_create_update_mongo_db_collection( + async def begin_mongo_db_container_retrieve_throughput_distribution( # pylint: disable=name-too-long self, resource_group_name: str, account_name: str, database_name: str, collection_name: str, - create_update_mongo_db_collection_parameters: IO[bytes], + retrieve_throughput_parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller[_models.MongoDBCollectionGetResults]: - """Create or update an Azure Cosmos DB MongoDB Collection. + ) -> AsyncLROPoller[_models.PhysicalPartitionThroughputInfoResult]: + """Retrieve throughput distribution for an Azure Cosmos DB MongoDB container. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -2296,30 +2509,30 @@ async def begin_create_update_mongo_db_collection( :type database_name: str :param collection_name: Cosmos DB collection name. Required. :type collection_name: str - :param create_update_mongo_db_collection_parameters: The parameters to provide for the current - MongoDB Collection. Required. - :type create_update_mongo_db_collection_parameters: IO[bytes] + :param retrieve_throughput_parameters: The parameters to provide for retrieving throughput + distribution for the current MongoDB container. Required. + :type retrieve_throughput_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 MongoDBCollectionGetResults or the - result of cls(response) + :return: An instance of AsyncLROPoller that returns either + PhysicalPartitionThroughputInfoResult or the result of cls(response) :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.MongoDBCollectionGetResults] + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.PhysicalPartitionThroughputInfoResult] :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace_async - async def begin_create_update_mongo_db_collection( + async def begin_mongo_db_container_retrieve_throughput_distribution( # pylint: disable=name-too-long self, resource_group_name: str, account_name: str, database_name: str, collection_name: str, - create_update_mongo_db_collection_parameters: Union[_models.MongoDBCollectionCreateUpdateParameters, IO[bytes]], + retrieve_throughput_parameters: Union[_models.RetrieveThroughputParameters, IO[bytes]], **kwargs: Any - ) -> AsyncLROPoller[_models.MongoDBCollectionGetResults]: - """Create or update an Azure Cosmos DB MongoDB Collection. + ) -> AsyncLROPoller[_models.PhysicalPartitionThroughputInfoResult]: + """Retrieve throughput distribution for an Azure Cosmos DB MongoDB container. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -2330,15 +2543,15 @@ async def begin_create_update_mongo_db_collection( :type database_name: str :param collection_name: Cosmos DB collection name. Required. :type collection_name: str - :param create_update_mongo_db_collection_parameters: The parameters to provide for the current - MongoDB Collection. Is either a MongoDBCollectionCreateUpdateParameters type or a IO[bytes] - type. Required. - :type create_update_mongo_db_collection_parameters: - ~azure.mgmt.cosmosdb.models.MongoDBCollectionCreateUpdateParameters or IO[bytes] - :return: An instance of AsyncLROPoller that returns either MongoDBCollectionGetResults or the - result of cls(response) + :param retrieve_throughput_parameters: The parameters to provide for retrieving throughput + distribution for the current MongoDB container. Is either a RetrieveThroughputParameters type + or a IO[bytes] type. Required. + :type retrieve_throughput_parameters: ~azure.mgmt.cosmosdb.models.RetrieveThroughputParameters + or IO[bytes] + :return: An instance of AsyncLROPoller that returns either + PhysicalPartitionThroughputInfoResult or the result of cls(response) :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.MongoDBCollectionGetResults] + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.PhysicalPartitionThroughputInfoResult] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -2346,17 +2559,17 @@ async def begin_create_update_mongo_db_collection( 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.MongoDBCollectionGetResults] = kwargs.pop("cls", None) + cls: ClsType[_models.PhysicalPartitionThroughputInfoResult] = 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_update_mongo_db_collection_initial( + raw_result = await self._mongo_db_container_retrieve_throughput_distribution_initial( resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, collection_name=collection_name, - create_update_mongo_db_collection_parameters=create_update_mongo_db_collection_parameters, + retrieve_throughput_parameters=retrieve_throughput_parameters, api_version=api_version, content_type=content_type, cls=lambda x, y, z: x, @@ -2368,30 +2581,37 @@ async def begin_create_update_mongo_db_collection( kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("MongoDBCollectionGetResults", pipeline_response.http_response) + deserialized = self._deserialize("PhysicalPartitionThroughputInfoResult", 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, **kwargs)) + 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.MongoDBCollectionGetResults].from_continuation_token( + return AsyncLROPoller[_models.PhysicalPartitionThroughputInfoResult].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller[_models.MongoDBCollectionGetResults]( + return AsyncLROPoller[_models.PhysicalPartitionThroughputInfoResult]( self._client, raw_result, get_long_running_output, polling_method # type: ignore ) - async def _delete_mongo_db_collection_initial( - self, resource_group_name: str, account_name: str, database_name: str, collection_name: str, **kwargs: Any + async def _mongo_db_database_partition_merge_initial( # pylint: disable=name-too-long + self, + resource_group_name: str, + account_name: str, + database_name: str, + merge_parameters: Union[_models.MergeParameters, IO[bytes]], + **kwargs: Any ) -> AsyncIterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -2401,19 +2621,30 @@ async def _delete_mongo_db_collection_initial( } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) 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) - _request = build_delete_mongo_db_collection_request( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(merge_parameters, (IOBase, bytes)): + _content = merge_parameters + else: + _json = self._serialize.body(merge_parameters, "MergeParameters") + + _request = build_mongo_db_database_partition_merge_request( resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, - collection_name=collection_name, subscription_id=self._config.subscription_id, api_version=api_version, + content_type=content_type, + json=_json, + content=_content, headers=_headers, params=_params, ) @@ -2427,7 +2658,7 @@ async def _delete_mongo_db_collection_initial( response = pipeline_response.http_response - if response.status_code not in [202, 204]: + if response.status_code not in [200, 202]: try: await response.read() # Load the body in memory and close the socket except (StreamConsumedError, StreamClosedError): @@ -2437,10 +2668,11 @@ async def _delete_mongo_db_collection_initial( response_headers = {} if response.status_code == 202: - response_headers["azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("azure-AsyncOperation") + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") ) - response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) @@ -2449,154 +2681,18 @@ async def _delete_mongo_db_collection_initial( return deserialized # type: ignore - @distributed_trace_async - async def begin_delete_mongo_db_collection( - self, resource_group_name: str, account_name: str, database_name: str, collection_name: str, **kwargs: Any - ) -> AsyncLROPoller[None]: - """Deletes an existing Azure Cosmos DB MongoDB Collection. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param account_name: Cosmos DB database account name. Required. - :type account_name: str - :param database_name: Cosmos DB database name. Required. - :type database_name: str - :param collection_name: Cosmos DB collection name. Required. - :type collection_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_mongo_db_collection_initial( - resource_group_name=resource_group_name, - account_name=account_name, - database_name=database_name, - collection_name=collection_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, **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 _mongo_db_database_partition_merge_initial( # pylint: disable=name-too-long - self, - resource_group_name: str, - account_name: str, - database_name: str, - merge_parameters: Union[_models.MergeParameters, 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(merge_parameters, (IOBase, bytes)): - _content = merge_parameters - else: - _json = self._serialize.body(merge_parameters, "MergeParameters") - - _request = build_mongo_db_database_partition_merge_request( - resource_group_name=resource_group_name, - account_name=account_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) - raise HttpResponseError(response=response, 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")) - - 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_mongo_db_database_partition_merge( - self, - resource_group_name: str, - account_name: str, - database_name: str, - merge_parameters: _models.MergeParameters, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.PhysicalPartitionStorageInfoCollection]: - """Merges the partitions of a MongoDB database. + @overload + async def begin_mongo_db_database_partition_merge( + self, + resource_group_name: str, + account_name: str, + database_name: str, + merge_parameters: _models.MergeParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.PhysicalPartitionStorageInfoCollection]: + """Merges the partitions of a MongoDB database. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -2726,13 +2822,77 @@ def get_long_running_output(pipeline_response): self._client, raw_result, get_long_running_output, polling_method # type: ignore ) - async def _list_mongo_db_collection_partition_merge_initial( # pylint: disable=name-too-long + @distributed_trace_async + async def get_mongo_db_database_throughput( + self, resource_group_name: str, account_name: str, database_name: str, **kwargs: Any + ) -> _models.ThroughputSettingsGetResults: + """Gets the RUs per second of the MongoDB database under an existing Azure Cosmos DB database + account with the provided name. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param database_name: Cosmos DB database name. Required. + :type database_name: str + :return: ThroughputSettingsGetResults or the result of cls(response) + :rtype: ~azure.mgmt.cosmosdb.models.ThroughputSettingsGetResults + :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.ThroughputSettingsGetResults] = kwargs.pop("cls", None) + + _request = build_get_mongo_db_database_throughput_request( + resource_group_name=resource_group_name, + account_name=account_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("ThroughputSettingsGetResults", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + async def _update_mongo_db_database_throughput_initial( # pylint: disable=name-too-long self, resource_group_name: str, account_name: str, database_name: str, - collection_name: str, - merge_parameters: Union[_models.MergeParameters, IO[bytes]], + update_throughput_parameters: Union[_models.ThroughputSettingsUpdateParameters, IO[bytes]], **kwargs: Any ) -> AsyncIterator[bytes]: error_map: MutableMapping = { @@ -2753,16 +2913,15 @@ async def _list_mongo_db_collection_partition_merge_initial( # pylint: disable= content_type = content_type or "application/json" _json = None _content = None - if isinstance(merge_parameters, (IOBase, bytes)): - _content = merge_parameters + if isinstance(update_throughput_parameters, (IOBase, bytes)): + _content = update_throughput_parameters else: - _json = self._serialize.body(merge_parameters, "MergeParameters") + _json = self._serialize.body(update_throughput_parameters, "ThroughputSettingsUpdateParameters") - _request = build_list_mongo_db_collection_partition_merge_request( + _request = build_update_mongo_db_database_throughput_request( resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, - collection_name=collection_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, @@ -2791,10 +2950,11 @@ async def _list_mongo_db_collection_partition_merge_initial( # pylint: disable= response_headers = {} if response.status_code == 202: - response_headers["azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("azure-AsyncOperation") + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") ) - response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) @@ -2804,18 +2964,17 @@ async def _list_mongo_db_collection_partition_merge_initial( # pylint: disable= return deserialized # type: ignore @overload - async def begin_list_mongo_db_collection_partition_merge( # pylint: disable=name-too-long + async def begin_update_mongo_db_database_throughput( # pylint: disable=name-too-long self, resource_group_name: str, account_name: str, database_name: str, - collection_name: str, - merge_parameters: _models.MergeParameters, + update_throughput_parameters: _models.ThroughputSettingsUpdateParameters, *, content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller[_models.PhysicalPartitionStorageInfoCollection]: - """Merges the partitions of a MongoDB Collection. + ) -> AsyncLROPoller[_models.ThroughputSettingsGetResults]: + """Update RUs per second of the an Azure Cosmos DB MongoDB database. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -2824,33 +2983,32 @@ async def begin_list_mongo_db_collection_partition_merge( # pylint: disable=nam :type account_name: str :param database_name: Cosmos DB database name. Required. :type database_name: str - :param collection_name: Cosmos DB collection name. Required. - :type collection_name: str - :param merge_parameters: The parameters for the merge operation. Required. - :type merge_parameters: ~azure.mgmt.cosmosdb.models.MergeParameters + :param update_throughput_parameters: The RUs per second of the parameters to provide for the + current MongoDB database. Required. + :type update_throughput_parameters: + ~azure.mgmt.cosmosdb.models.ThroughputSettingsUpdateParameters :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 - PhysicalPartitionStorageInfoCollection or the result of cls(response) + :return: An instance of AsyncLROPoller that returns either ThroughputSettingsGetResults or the + result of cls(response) :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.PhysicalPartitionStorageInfoCollection] + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.ThroughputSettingsGetResults] :raises ~azure.core.exceptions.HttpResponseError: """ @overload - async def begin_list_mongo_db_collection_partition_merge( # pylint: disable=name-too-long + async def begin_update_mongo_db_database_throughput( # pylint: disable=name-too-long self, resource_group_name: str, account_name: str, database_name: str, - collection_name: str, - merge_parameters: IO[bytes], + update_throughput_parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller[_models.PhysicalPartitionStorageInfoCollection]: - """Merges the partitions of a MongoDB Collection. + ) -> AsyncLROPoller[_models.ThroughputSettingsGetResults]: + """Update RUs per second of the an Azure Cosmos DB MongoDB database. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -2859,31 +3017,29 @@ async def begin_list_mongo_db_collection_partition_merge( # pylint: disable=nam :type account_name: str :param database_name: Cosmos DB database name. Required. :type database_name: str - :param collection_name: Cosmos DB collection name. Required. - :type collection_name: str - :param merge_parameters: The parameters for the merge operation. Required. - :type merge_parameters: IO[bytes] + :param update_throughput_parameters: The RUs per second of the parameters to provide for the + current MongoDB database. Required. + :type update_throughput_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 - PhysicalPartitionStorageInfoCollection or the result of cls(response) + :return: An instance of AsyncLROPoller that returns either ThroughputSettingsGetResults or the + result of cls(response) :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.PhysicalPartitionStorageInfoCollection] + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.ThroughputSettingsGetResults] :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace_async - async def begin_list_mongo_db_collection_partition_merge( # pylint: disable=name-too-long + async def begin_update_mongo_db_database_throughput( # pylint: disable=name-too-long self, resource_group_name: str, account_name: str, database_name: str, - collection_name: str, - merge_parameters: Union[_models.MergeParameters, IO[bytes]], + update_throughput_parameters: Union[_models.ThroughputSettingsUpdateParameters, IO[bytes]], **kwargs: Any - ) -> AsyncLROPoller[_models.PhysicalPartitionStorageInfoCollection]: - """Merges the partitions of a MongoDB Collection. + ) -> AsyncLROPoller[_models.ThroughputSettingsGetResults]: + """Update RUs per second of the an Azure Cosmos DB MongoDB database. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -2892,15 +3048,15 @@ async def begin_list_mongo_db_collection_partition_merge( # pylint: disable=nam :type account_name: str :param database_name: Cosmos DB database name. Required. :type database_name: str - :param collection_name: Cosmos DB collection name. Required. - :type collection_name: str - :param merge_parameters: The parameters for the merge operation. Is either a MergeParameters - type or a IO[bytes] type. Required. - :type merge_parameters: ~azure.mgmt.cosmosdb.models.MergeParameters or IO[bytes] - :return: An instance of AsyncLROPoller that returns either - PhysicalPartitionStorageInfoCollection or the result of cls(response) + :param update_throughput_parameters: The RUs per second of the parameters to provide for the + current MongoDB database. Is either a ThroughputSettingsUpdateParameters type or a IO[bytes] + type. Required. + :type update_throughput_parameters: + ~azure.mgmt.cosmosdb.models.ThroughputSettingsUpdateParameters or IO[bytes] + :return: An instance of AsyncLROPoller that returns either ThroughputSettingsGetResults or the + result of cls(response) :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.PhysicalPartitionStorageInfoCollection] + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.ThroughputSettingsGetResults] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -2908,17 +3064,16 @@ async def begin_list_mongo_db_collection_partition_merge( # pylint: disable=nam 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.PhysicalPartitionStorageInfoCollection] = kwargs.pop("cls", None) + cls: ClsType[_models.ThroughputSettingsGetResults] = 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._list_mongo_db_collection_partition_merge_initial( + raw_result = await self._update_mongo_db_database_throughput_initial( resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, - collection_name=collection_name, - merge_parameters=merge_parameters, + update_throughput_parameters=update_throughput_parameters, api_version=api_version, content_type=content_type, cls=lambda x, y, z: x, @@ -2930,7 +3085,7 @@ async def begin_list_mongo_db_collection_partition_merge( # pylint: disable=nam kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("PhysicalPartitionStorageInfoCollection", pipeline_response.http_response) + deserialized = self._deserialize("ThroughputSettingsGetResults", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized @@ -2944,88 +3099,18 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller[_models.PhysicalPartitionStorageInfoCollection].from_continuation_token( + return AsyncLROPoller[_models.ThroughputSettingsGetResults].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller[_models.PhysicalPartitionStorageInfoCollection]( + return AsyncLROPoller[_models.ThroughputSettingsGetResults]( self._client, raw_result, get_long_running_output, polling_method # type: ignore ) - @distributed_trace_async - async def get_mongo_db_collection_throughput( - self, resource_group_name: str, account_name: str, database_name: str, collection_name: str, **kwargs: Any - ) -> _models.ThroughputSettingsGetResults: - """Gets the RUs per second of the MongoDB collection under an existing Azure Cosmos DB database - account with the provided name. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param account_name: Cosmos DB database account name. Required. - :type account_name: str - :param database_name: Cosmos DB database name. Required. - :type database_name: str - :param collection_name: Cosmos DB collection name. Required. - :type collection_name: str - :return: ThroughputSettingsGetResults or the result of cls(response) - :rtype: ~azure.mgmt.cosmosdb.models.ThroughputSettingsGetResults - :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.ThroughputSettingsGetResults] = kwargs.pop("cls", None) - - _request = build_get_mongo_db_collection_throughput_request( - resource_group_name=resource_group_name, - account_name=account_name, - database_name=database_name, - collection_name=collection_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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("ThroughputSettingsGetResults", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - async def _update_mongo_db_collection_throughput_initial( # pylint: disable=name-too-long - self, - resource_group_name: str, - account_name: str, - database_name: str, - collection_name: str, - update_throughput_parameters: Union[_models.ThroughputSettingsUpdateParameters, IO[bytes]], - **kwargs: Any + async def _migrate_mongo_db_database_to_autoscale_initial( # pylint: disable=name-too-long + self, resource_group_name: str, account_name: str, database_name: str, **kwargs: Any ) -> AsyncIterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -3035,31 +3120,18 @@ async def _update_mongo_db_collection_throughput_initial( # pylint: disable=nam } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = case_insensitive_dict(kwargs.pop("headers", {}) 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)) - 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(update_throughput_parameters, (IOBase, bytes)): - _content = update_throughput_parameters - else: - _json = self._serialize.body(update_throughput_parameters, "ThroughputSettingsUpdateParameters") - - _request = build_update_mongo_db_collection_throughput_request( + _request = build_migrate_mongo_db_database_to_autoscale_request( resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, - collection_name=collection_name, subscription_id=self._config.subscription_id, api_version=api_version, - content_type=content_type, - json=_json, - content=_content, headers=_headers, params=_params, ) @@ -3083,10 +3155,11 @@ async def _update_mongo_db_collection_throughput_initial( # pylint: disable=nam response_headers = {} if response.status_code == 202: - response_headers["azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("azure-AsyncOperation") + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") ) - response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) @@ -3095,90 +3168,11 @@ async def _update_mongo_db_collection_throughput_initial( # pylint: disable=nam return deserialized # type: ignore - @overload - async def begin_update_mongo_db_collection_throughput( # pylint: disable=name-too-long - self, - resource_group_name: str, - account_name: str, - database_name: str, - collection_name: str, - update_throughput_parameters: _models.ThroughputSettingsUpdateParameters, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.ThroughputSettingsGetResults]: - """Update the RUs per second of an Azure Cosmos DB MongoDB collection. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param account_name: Cosmos DB database account name. Required. - :type account_name: str - :param database_name: Cosmos DB database name. Required. - :type database_name: str - :param collection_name: Cosmos DB collection name. Required. - :type collection_name: str - :param update_throughput_parameters: The RUs per second of the parameters to provide for the - current MongoDB collection. Required. - :type update_throughput_parameters: - ~azure.mgmt.cosmosdb.models.ThroughputSettingsUpdateParameters - :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 ThroughputSettingsGetResults or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.ThroughputSettingsGetResults] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_update_mongo_db_collection_throughput( # pylint: disable=name-too-long - self, - resource_group_name: str, - account_name: str, - database_name: str, - collection_name: str, - update_throughput_parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.ThroughputSettingsGetResults]: - """Update the RUs per second of an Azure Cosmos DB MongoDB collection. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param account_name: Cosmos DB database account name. Required. - :type account_name: str - :param database_name: Cosmos DB database name. Required. - :type database_name: str - :param collection_name: Cosmos DB collection name. Required. - :type collection_name: str - :param update_throughput_parameters: The RUs per second of the parameters to provide for the - current MongoDB collection. Required. - :type update_throughput_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 ThroughputSettingsGetResults or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.ThroughputSettingsGetResults] - :raises ~azure.core.exceptions.HttpResponseError: - """ - @distributed_trace_async - async def begin_update_mongo_db_collection_throughput( # pylint: disable=name-too-long - self, - resource_group_name: str, - account_name: str, - database_name: str, - collection_name: str, - update_throughput_parameters: Union[_models.ThroughputSettingsUpdateParameters, IO[bytes]], - **kwargs: Any + async def begin_migrate_mongo_db_database_to_autoscale( # pylint: disable=name-too-long + self, resource_group_name: str, account_name: str, database_name: str, **kwargs: Any ) -> AsyncLROPoller[_models.ThroughputSettingsGetResults]: - """Update the RUs per second of an Azure Cosmos DB MongoDB collection. + """Migrate an Azure Cosmos DB MongoDB database from manual throughput to autoscale. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -3187,37 +3181,26 @@ async def begin_update_mongo_db_collection_throughput( # pylint: disable=name-t :type account_name: str :param database_name: Cosmos DB database name. Required. :type database_name: str - :param collection_name: Cosmos DB collection name. Required. - :type collection_name: str - :param update_throughput_parameters: The RUs per second of the parameters to provide for the - current MongoDB collection. Is either a ThroughputSettingsUpdateParameters type or a IO[bytes] - type. Required. - :type update_throughput_parameters: - ~azure.mgmt.cosmosdb.models.ThroughputSettingsUpdateParameters or IO[bytes] :return: An instance of AsyncLROPoller that returns either ThroughputSettingsGetResults or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.ThroughputSettingsGetResults] :raises ~azure.core.exceptions.HttpResponseError: """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) 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)) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.ThroughputSettingsGetResults] = 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_mongo_db_collection_throughput_initial( + raw_result = await self._migrate_mongo_db_database_to_autoscale_initial( resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, - collection_name=collection_name, - update_throughput_parameters=update_throughput_parameters, api_version=api_version, - content_type=content_type, cls=lambda x, y, z: x, headers=_headers, params=_params, @@ -3233,7 +3216,9 @@ def get_long_running_output(pipeline_response): return deserialized if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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: @@ -3249,8 +3234,8 @@ def get_long_running_output(pipeline_response): self._client, raw_result, get_long_running_output, polling_method # type: ignore ) - async def _migrate_mongo_db_collection_to_autoscale_initial( # pylint: disable=name-too-long - self, resource_group_name: str, account_name: str, database_name: str, collection_name: str, **kwargs: Any + async def _migrate_mongo_db_database_to_manual_throughput_initial( # pylint: disable=name-too-long + self, resource_group_name: str, account_name: str, database_name: str, **kwargs: Any ) -> AsyncIterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -3266,11 +3251,10 @@ async def _migrate_mongo_db_collection_to_autoscale_initial( # pylint: disable= 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_migrate_mongo_db_collection_to_autoscale_request( + _request = build_migrate_mongo_db_database_to_manual_throughput_request( resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, - collection_name=collection_name, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, @@ -3296,10 +3280,11 @@ async def _migrate_mongo_db_collection_to_autoscale_initial( # pylint: disable= response_headers = {} if response.status_code == 202: - response_headers["azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("azure-AsyncOperation") + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") ) - response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) @@ -3309,10 +3294,10 @@ async def _migrate_mongo_db_collection_to_autoscale_initial( # pylint: disable= return deserialized # type: ignore @distributed_trace_async - async def begin_migrate_mongo_db_collection_to_autoscale( # pylint: disable=name-too-long - self, resource_group_name: str, account_name: str, database_name: str, collection_name: str, **kwargs: Any + async def begin_migrate_mongo_db_database_to_manual_throughput( # pylint: disable=name-too-long + self, resource_group_name: str, account_name: str, database_name: str, **kwargs: Any ) -> AsyncLROPoller[_models.ThroughputSettingsGetResults]: - """Migrate an Azure Cosmos DB MongoDB collection from manual throughput to autoscale. + """Migrate an Azure Cosmos DB MongoDB database from autoscale to manual throughput. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -3321,8 +3306,6 @@ async def begin_migrate_mongo_db_collection_to_autoscale( # pylint: disable=nam :type account_name: str :param database_name: Cosmos DB database name. Required. :type database_name: str - :param collection_name: Cosmos DB collection name. Required. - :type collection_name: str :return: An instance of AsyncLROPoller that returns either ThroughputSettingsGetResults or the result of cls(response) :rtype: @@ -3338,11 +3321,10 @@ async def begin_migrate_mongo_db_collection_to_autoscale( # pylint: disable=nam 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_mongo_db_collection_to_autoscale_initial( + raw_result = await self._migrate_mongo_db_database_to_manual_throughput_initial( resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, - collection_name=collection_name, api_version=api_version, cls=lambda x, y, z: x, headers=_headers, @@ -3359,7 +3341,9 @@ def get_long_running_output(pipeline_response): return deserialized if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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: @@ -3375,30 +3359,46 @@ def get_long_running_output(pipeline_response): self._client, raw_result, get_long_running_output, polling_method # type: ignore ) - async def _migrate_mongo_db_collection_to_manual_throughput_initial( # pylint: disable=name-too-long - self, resource_group_name: str, account_name: str, database_name: str, collection_name: str, **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, + async def _mongo_db_database_redistribute_throughput_initial( # pylint: disable=name-too-long + self, + resource_group_name: str, + account_name: str, + database_name: str, + redistribute_throughput_parameters: Union[_models.RedistributeThroughputParameters, 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 = kwargs.pop("headers", {}) 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) - _request = build_migrate_mongo_db_collection_to_manual_throughput_request( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(redistribute_throughput_parameters, (IOBase, bytes)): + _content = redistribute_throughput_parameters + else: + _json = self._serialize.body(redistribute_throughput_parameters, "RedistributeThroughputParameters") + + _request = build_mongo_db_database_redistribute_throughput_request( resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, - collection_name=collection_name, subscription_id=self._config.subscription_id, api_version=api_version, + content_type=content_type, + json=_json, + content=_content, headers=_headers, params=_params, ) @@ -3422,10 +3422,11 @@ async def _migrate_mongo_db_collection_to_manual_throughput_initial( # pylint: response_headers = {} if response.status_code == 202: - response_headers["azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("azure-AsyncOperation") + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") ) - response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) @@ -3434,11 +3435,83 @@ async def _migrate_mongo_db_collection_to_manual_throughput_initial( # pylint: return deserialized # type: ignore + @overload + async def begin_mongo_db_database_redistribute_throughput( # pylint: disable=name-too-long + self, + resource_group_name: str, + account_name: str, + database_name: str, + redistribute_throughput_parameters: _models.RedistributeThroughputParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.PhysicalPartitionThroughputInfoResult]: + """Redistribute throughput for an Azure Cosmos DB MongoDB database. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param database_name: Cosmos DB database name. Required. + :type database_name: str + :param redistribute_throughput_parameters: The parameters to provide for redistributing + throughput for the current MongoDB database. Required. + :type redistribute_throughput_parameters: + ~azure.mgmt.cosmosdb.models.RedistributeThroughputParameters + :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 + PhysicalPartitionThroughputInfoResult or the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.PhysicalPartitionThroughputInfoResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_mongo_db_database_redistribute_throughput( # pylint: disable=name-too-long + self, + resource_group_name: str, + account_name: str, + database_name: str, + redistribute_throughput_parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.PhysicalPartitionThroughputInfoResult]: + """Redistribute throughput for an Azure Cosmos DB MongoDB database. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param database_name: Cosmos DB database name. Required. + :type database_name: str + :param redistribute_throughput_parameters: The parameters to provide for redistributing + throughput for the current MongoDB database. Required. + :type redistribute_throughput_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 + PhysicalPartitionThroughputInfoResult or the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.PhysicalPartitionThroughputInfoResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + @distributed_trace_async - async def begin_migrate_mongo_db_collection_to_manual_throughput( # pylint: disable=name-too-long - self, resource_group_name: str, account_name: str, database_name: str, collection_name: str, **kwargs: Any - ) -> AsyncLROPoller[_models.ThroughputSettingsGetResults]: - """Migrate an Azure Cosmos DB MongoDB collection from autoscale to manual throughput. + async def begin_mongo_db_database_redistribute_throughput( # pylint: disable=name-too-long + self, + resource_group_name: str, + account_name: str, + database_name: str, + redistribute_throughput_parameters: Union[_models.RedistributeThroughputParameters, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.PhysicalPartitionThroughputInfoResult]: + """Redistribute throughput for an Azure Cosmos DB MongoDB database. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -3447,29 +3520,34 @@ async def begin_migrate_mongo_db_collection_to_manual_throughput( # pylint: dis :type account_name: str :param database_name: Cosmos DB database name. Required. :type database_name: str - :param collection_name: Cosmos DB collection name. Required. - :type collection_name: str - :return: An instance of AsyncLROPoller that returns either ThroughputSettingsGetResults or the - result of cls(response) + :param redistribute_throughput_parameters: The parameters to provide for redistributing + throughput for the current MongoDB database. Is either a RedistributeThroughputParameters type + or a IO[bytes] type. Required. + :type redistribute_throughput_parameters: + ~azure.mgmt.cosmosdb.models.RedistributeThroughputParameters or IO[bytes] + :return: An instance of AsyncLROPoller that returns either + PhysicalPartitionThroughputInfoResult or the result of cls(response) :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.ThroughputSettingsGetResults] + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.PhysicalPartitionThroughputInfoResult] :raises ~azure.core.exceptions.HttpResponseError: """ - _headers = kwargs.pop("headers", {}) 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)) - cls: ClsType[_models.ThroughputSettingsGetResults] = kwargs.pop("cls", None) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.PhysicalPartitionThroughputInfoResult] = 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_mongo_db_collection_to_manual_throughput_initial( + raw_result = await self._mongo_db_database_redistribute_throughput_initial( resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, - collection_name=collection_name, + redistribute_throughput_parameters=redistribute_throughput_parameters, api_version=api_version, + content_type=content_type, cls=lambda x, y, z: x, headers=_headers, params=_params, @@ -3479,97 +3557,36 @@ async def begin_migrate_mongo_db_collection_to_manual_throughput( # pylint: dis kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ThroughputSettingsGetResults", pipeline_response.http_response) + deserialized = self._deserialize("PhysicalPartitionThroughputInfoResult", 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, **kwargs)) + 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.ThroughputSettingsGetResults].from_continuation_token( + return AsyncLROPoller[_models.PhysicalPartitionThroughputInfoResult].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller[_models.ThroughputSettingsGetResults]( + return AsyncLROPoller[_models.PhysicalPartitionThroughputInfoResult]( self._client, raw_result, get_long_running_output, polling_method # type: ignore ) - @distributed_trace_async - async def get_mongo_role_definition( - self, mongo_role_definition_id: str, resource_group_name: str, account_name: str, **kwargs: Any - ) -> _models.MongoRoleDefinitionGetResults: - """Retrieves the properties of an existing Azure Cosmos DB Mongo Role Definition with the given - Id. - - :param mongo_role_definition_id: The ID for the Role Definition {dbName.roleName}. Required. - :type mongo_role_definition_id: str - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param account_name: Cosmos DB database account name. Required. - :type account_name: str - :return: MongoRoleDefinitionGetResults or the result of cls(response) - :rtype: ~azure.mgmt.cosmosdb.models.MongoRoleDefinitionGetResults - :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.MongoRoleDefinitionGetResults] = kwargs.pop("cls", None) - - _request = build_get_mongo_role_definition_request( - mongo_role_definition_id=mongo_role_definition_id, - resource_group_name=resource_group_name, - account_name=account_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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("MongoRoleDefinitionGetResults", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - async def _create_update_mongo_role_definition_initial( # pylint: disable=name-too-long + async def _mongo_db_database_retrieve_throughput_distribution_initial( # pylint: disable=name-too-long self, - mongo_role_definition_id: str, resource_group_name: str, account_name: str, - create_update_mongo_role_definition_parameters: Union[ - _models.MongoRoleDefinitionCreateUpdateParameters, IO[bytes] - ], + database_name: str, + retrieve_throughput_parameters: Union[_models.RetrieveThroughputParameters, IO[bytes]], **kwargs: Any ) -> AsyncIterator[bytes]: error_map: MutableMapping = { @@ -3590,17 +3607,15 @@ async def _create_update_mongo_role_definition_initial( # pylint: disable=name- content_type = content_type or "application/json" _json = None _content = None - if isinstance(create_update_mongo_role_definition_parameters, (IOBase, bytes)): - _content = create_update_mongo_role_definition_parameters + if isinstance(retrieve_throughput_parameters, (IOBase, bytes)): + _content = retrieve_throughput_parameters else: - _json = self._serialize.body( - create_update_mongo_role_definition_parameters, "MongoRoleDefinitionCreateUpdateParameters" - ) + _json = self._serialize.body(retrieve_throughput_parameters, "RetrieveThroughputParameters") - _request = build_create_update_mongo_role_definition_request( - mongo_role_definition_id=mongo_role_definition_id, + _request = build_mongo_db_database_retrieve_throughput_distribution_request( resource_group_name=resource_group_name, account_name=account_name, + database_name=database_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, @@ -3627,109 +3642,114 @@ async def _create_update_mongo_role_definition_initial( # pylint: disable=name- map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, 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.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @overload - async def begin_create_update_mongo_role_definition( # pylint: disable=name-too-long + async def begin_mongo_db_database_retrieve_throughput_distribution( # pylint: disable=name-too-long self, - mongo_role_definition_id: str, resource_group_name: str, account_name: str, - create_update_mongo_role_definition_parameters: _models.MongoRoleDefinitionCreateUpdateParameters, + database_name: str, + retrieve_throughput_parameters: _models.RetrieveThroughputParameters, *, content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller[_models.MongoRoleDefinitionGetResults]: - """Creates or updates an Azure Cosmos DB Mongo Role Definition. + ) -> AsyncLROPoller[_models.PhysicalPartitionThroughputInfoResult]: + """Retrieve throughput distribution for an Azure Cosmos DB MongoDB database. - :param mongo_role_definition_id: The ID for the Role Definition {dbName.roleName}. Required. - :type mongo_role_definition_id: str :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param create_update_mongo_role_definition_parameters: The properties required to create or - update a Role Definition. Required. - :type create_update_mongo_role_definition_parameters: - ~azure.mgmt.cosmosdb.models.MongoRoleDefinitionCreateUpdateParameters + :param database_name: Cosmos DB database name. Required. + :type database_name: str + :param retrieve_throughput_parameters: The parameters to provide for retrieving throughput + distribution for the current MongoDB database. Required. + :type retrieve_throughput_parameters: ~azure.mgmt.cosmosdb.models.RetrieveThroughputParameters :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 MongoRoleDefinitionGetResults or the - result of cls(response) + :return: An instance of AsyncLROPoller that returns either + PhysicalPartitionThroughputInfoResult or the result of cls(response) :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.MongoRoleDefinitionGetResults] + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.PhysicalPartitionThroughputInfoResult] :raises ~azure.core.exceptions.HttpResponseError: """ @overload - async def begin_create_update_mongo_role_definition( # pylint: disable=name-too-long + async def begin_mongo_db_database_retrieve_throughput_distribution( # pylint: disable=name-too-long self, - mongo_role_definition_id: str, resource_group_name: str, account_name: str, - create_update_mongo_role_definition_parameters: IO[bytes], + database_name: str, + retrieve_throughput_parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller[_models.MongoRoleDefinitionGetResults]: - """Creates or updates an Azure Cosmos DB Mongo Role Definition. + ) -> AsyncLROPoller[_models.PhysicalPartitionThroughputInfoResult]: + """Retrieve throughput distribution for an Azure Cosmos DB MongoDB database. - :param mongo_role_definition_id: The ID for the Role Definition {dbName.roleName}. Required. - :type mongo_role_definition_id: str :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param create_update_mongo_role_definition_parameters: The properties required to create or - update a Role Definition. Required. - :type create_update_mongo_role_definition_parameters: IO[bytes] + :param database_name: Cosmos DB database name. Required. + :type database_name: str + :param retrieve_throughput_parameters: The parameters to provide for retrieving throughput + distribution for the current MongoDB database. Required. + :type retrieve_throughput_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 MongoRoleDefinitionGetResults or the - result of cls(response) + :return: An instance of AsyncLROPoller that returns either + PhysicalPartitionThroughputInfoResult or the result of cls(response) :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.MongoRoleDefinitionGetResults] + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.PhysicalPartitionThroughputInfoResult] :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace_async - async def begin_create_update_mongo_role_definition( # pylint: disable=name-too-long + async def begin_mongo_db_database_retrieve_throughput_distribution( # pylint: disable=name-too-long self, - mongo_role_definition_id: str, resource_group_name: str, account_name: str, - create_update_mongo_role_definition_parameters: Union[ - _models.MongoRoleDefinitionCreateUpdateParameters, IO[bytes] - ], + database_name: str, + retrieve_throughput_parameters: Union[_models.RetrieveThroughputParameters, IO[bytes]], **kwargs: Any - ) -> AsyncLROPoller[_models.MongoRoleDefinitionGetResults]: - """Creates or updates an Azure Cosmos DB Mongo Role Definition. + ) -> AsyncLROPoller[_models.PhysicalPartitionThroughputInfoResult]: + """Retrieve throughput distribution for an Azure Cosmos DB MongoDB database. - :param mongo_role_definition_id: The ID for the Role Definition {dbName.roleName}. Required. - :type mongo_role_definition_id: str :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param create_update_mongo_role_definition_parameters: The properties required to create or - update a Role Definition. Is either a MongoRoleDefinitionCreateUpdateParameters type or a - IO[bytes] type. Required. - :type create_update_mongo_role_definition_parameters: - ~azure.mgmt.cosmosdb.models.MongoRoleDefinitionCreateUpdateParameters or IO[bytes] - :return: An instance of AsyncLROPoller that returns either MongoRoleDefinitionGetResults or the - result of cls(response) + :param database_name: Cosmos DB database name. Required. + :type database_name: str + :param retrieve_throughput_parameters: The parameters to provide for retrieving throughput + distribution for the current MongoDB database. Is either a RetrieveThroughputParameters type or + a IO[bytes] type. Required. + :type retrieve_throughput_parameters: ~azure.mgmt.cosmosdb.models.RetrieveThroughputParameters + or IO[bytes] + :return: An instance of AsyncLROPoller that returns either + PhysicalPartitionThroughputInfoResult or the result of cls(response) :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.MongoRoleDefinitionGetResults] + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.PhysicalPartitionThroughputInfoResult] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -3737,16 +3757,16 @@ async def begin_create_update_mongo_role_definition( # pylint: disable=name-too 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.MongoRoleDefinitionGetResults] = kwargs.pop("cls", None) + cls: ClsType[_models.PhysicalPartitionThroughputInfoResult] = 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_update_mongo_role_definition_initial( - mongo_role_definition_id=mongo_role_definition_id, + raw_result = await self._mongo_db_database_retrieve_throughput_distribution_initial( resource_group_name=resource_group_name, account_name=account_name, - create_update_mongo_role_definition_parameters=create_update_mongo_role_definition_parameters, + database_name=database_name, + retrieve_throughput_parameters=retrieve_throughput_parameters, api_version=api_version, content_type=content_type, cls=lambda x, y, z: x, @@ -3758,137 +3778,30 @@ async def begin_create_update_mongo_role_definition( # pylint: disable=name-too kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("MongoRoleDefinitionGetResults", pipeline_response.http_response) + deserialized = self._deserialize("PhysicalPartitionThroughputInfoResult", 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, **kwargs)) + 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.MongoRoleDefinitionGetResults].from_continuation_token( + return AsyncLROPoller[_models.PhysicalPartitionThroughputInfoResult].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller[_models.MongoRoleDefinitionGetResults]( + return AsyncLROPoller[_models.PhysicalPartitionThroughputInfoResult]( self._client, raw_result, get_long_running_output, polling_method # type: ignore ) - async def _delete_mongo_role_definition_initial( - self, mongo_role_definition_id: str, resource_group_name: str, account_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_mongo_role_definition_request( - mongo_role_definition_id=mongo_role_definition_id, - resource_group_name=resource_group_name, - account_name=account_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, 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def begin_delete_mongo_role_definition( - self, mongo_role_definition_id: str, resource_group_name: str, account_name: str, **kwargs: Any - ) -> AsyncLROPoller[None]: - """Deletes an existing Azure Cosmos DB Mongo Role Definition. - - :param mongo_role_definition_id: The ID for the Role Definition {dbName.roleName}. Required. - :type mongo_role_definition_id: str - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param account_name: Cosmos DB database account name. Required. - :type account_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_mongo_role_definition_initial( - mongo_role_definition_id=mongo_role_definition_id, - resource_group_name=resource_group_name, - account_name=account_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, **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_mongo_role_definitions( self, resource_group_name: str, account_name: str, **kwargs: Any @@ -3955,7 +3868,7 @@ async def extract_data(pipeline_response): list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore - return None, AsyncList(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): _request = prepare_request(next_link) @@ -3975,21 +3888,21 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) @distributed_trace_async - async def get_mongo_user_definition( - self, mongo_user_definition_id: str, resource_group_name: str, account_name: str, **kwargs: Any - ) -> _models.MongoUserDefinitionGetResults: - """Retrieves the properties of an existing Azure Cosmos DB Mongo User Definition with the given + async def get_mongo_role_definition( + self, resource_group_name: str, account_name: str, mongo_role_definition_id: str, **kwargs: Any + ) -> _models.MongoRoleDefinitionGetResults: + """Retrieves the properties of an existing Azure Cosmos DB Mongo Role Definition with the given Id. - :param mongo_user_definition_id: The ID for the User Definition {dbName.userName}. Required. - :type mongo_user_definition_id: str :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param account_name: Cosmos DB database account name. Required. :type account_name: str - :return: MongoUserDefinitionGetResults or the result of cls(response) - :rtype: ~azure.mgmt.cosmosdb.models.MongoUserDefinitionGetResults + :param mongo_role_definition_id: The ID for the Role Definition {dbName.roleName}. Required. + :type mongo_role_definition_id: str + :return: MongoRoleDefinitionGetResults or the result of cls(response) + :rtype: ~azure.mgmt.cosmosdb.models.MongoRoleDefinitionGetResults :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -4004,12 +3917,12 @@ async def get_mongo_user_definition( _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.MongoUserDefinitionGetResults] = kwargs.pop("cls", None) + cls: ClsType[_models.MongoRoleDefinitionGetResults] = kwargs.pop("cls", None) - _request = build_get_mongo_user_definition_request( - mongo_user_definition_id=mongo_user_definition_id, + _request = build_get_mongo_role_definition_request( resource_group_name=resource_group_name, account_name=account_name, + mongo_role_definition_id=mongo_role_definition_id, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, @@ -4028,20 +3941,20 @@ async def get_mongo_user_definition( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("MongoUserDefinitionGetResults", pipeline_response.http_response) + deserialized = self._deserialize("MongoRoleDefinitionGetResults", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - async def _create_update_mongo_user_definition_initial( # pylint: disable=name-too-long + async def _create_update_mongo_role_definition_initial( # pylint: disable=name-too-long self, - mongo_user_definition_id: str, resource_group_name: str, account_name: str, - create_update_mongo_user_definition_parameters: Union[ - _models.MongoUserDefinitionCreateUpdateParameters, IO[bytes] + mongo_role_definition_id: str, + create_update_mongo_role_definition_parameters: Union[ + _models.MongoRoleDefinitionCreateUpdateParameters, IO[bytes] ], **kwargs: Any ) -> AsyncIterator[bytes]: @@ -4063,17 +3976,17 @@ async def _create_update_mongo_user_definition_initial( # pylint: disable=name- content_type = content_type or "application/json" _json = None _content = None - if isinstance(create_update_mongo_user_definition_parameters, (IOBase, bytes)): - _content = create_update_mongo_user_definition_parameters + if isinstance(create_update_mongo_role_definition_parameters, (IOBase, bytes)): + _content = create_update_mongo_role_definition_parameters else: _json = self._serialize.body( - create_update_mongo_user_definition_parameters, "MongoUserDefinitionCreateUpdateParameters" + create_update_mongo_role_definition_parameters, "MongoRoleDefinitionCreateUpdateParameters" ) - _request = build_create_update_mongo_user_definition_request( - mongo_user_definition_id=mongo_user_definition_id, + _request = build_create_update_mongo_role_definition_request( resource_group_name=resource_group_name, account_name=account_name, + mongo_role_definition_id=mongo_role_definition_id, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, @@ -4100,109 +4013,114 @@ async def _create_update_mongo_user_definition_initial( # pylint: disable=name- map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @overload - async def begin_create_update_mongo_user_definition( # pylint: disable=name-too-long + async def begin_create_update_mongo_role_definition( # pylint: disable=name-too-long self, - mongo_user_definition_id: str, resource_group_name: str, account_name: str, - create_update_mongo_user_definition_parameters: _models.MongoUserDefinitionCreateUpdateParameters, + mongo_role_definition_id: str, + create_update_mongo_role_definition_parameters: _models.MongoRoleDefinitionCreateUpdateParameters, *, content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller[_models.MongoUserDefinitionGetResults]: - """Creates or updates an Azure Cosmos DB Mongo User Definition. + ) -> AsyncLROPoller[_models.MongoRoleDefinitionGetResults]: + """Creates or updates an Azure Cosmos DB Mongo Role Definition. - :param mongo_user_definition_id: The ID for the User Definition {dbName.userName}. Required. - :type mongo_user_definition_id: str :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param create_update_mongo_user_definition_parameters: The properties required to create or - update a User Definition. Required. - :type create_update_mongo_user_definition_parameters: - ~azure.mgmt.cosmosdb.models.MongoUserDefinitionCreateUpdateParameters + :param mongo_role_definition_id: The ID for the Role Definition {dbName.roleName}. Required. + :type mongo_role_definition_id: str + :param create_update_mongo_role_definition_parameters: The properties required to create or + update a Role Definition. Required. + :type create_update_mongo_role_definition_parameters: + ~azure.mgmt.cosmosdb.models.MongoRoleDefinitionCreateUpdateParameters :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 MongoUserDefinitionGetResults or the + :return: An instance of AsyncLROPoller that returns either MongoRoleDefinitionGetResults or the result of cls(response) :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.MongoUserDefinitionGetResults] + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.MongoRoleDefinitionGetResults] :raises ~azure.core.exceptions.HttpResponseError: """ @overload - async def begin_create_update_mongo_user_definition( # pylint: disable=name-too-long + async def begin_create_update_mongo_role_definition( # pylint: disable=name-too-long self, - mongo_user_definition_id: str, resource_group_name: str, account_name: str, - create_update_mongo_user_definition_parameters: IO[bytes], + mongo_role_definition_id: str, + create_update_mongo_role_definition_parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller[_models.MongoUserDefinitionGetResults]: - """Creates or updates an Azure Cosmos DB Mongo User Definition. + ) -> AsyncLROPoller[_models.MongoRoleDefinitionGetResults]: + """Creates or updates an Azure Cosmos DB Mongo Role Definition. - :param mongo_user_definition_id: The ID for the User Definition {dbName.userName}. Required. - :type mongo_user_definition_id: str :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param create_update_mongo_user_definition_parameters: The properties required to create or - update a User Definition. Required. - :type create_update_mongo_user_definition_parameters: IO[bytes] + :param mongo_role_definition_id: The ID for the Role Definition {dbName.roleName}. Required. + :type mongo_role_definition_id: str + :param create_update_mongo_role_definition_parameters: The properties required to create or + update a Role Definition. Required. + :type create_update_mongo_role_definition_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 MongoUserDefinitionGetResults or the + :return: An instance of AsyncLROPoller that returns either MongoRoleDefinitionGetResults or the result of cls(response) :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.MongoUserDefinitionGetResults] + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.MongoRoleDefinitionGetResults] :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace_async - async def begin_create_update_mongo_user_definition( # pylint: disable=name-too-long + async def begin_create_update_mongo_role_definition( # pylint: disable=name-too-long self, - mongo_user_definition_id: str, resource_group_name: str, account_name: str, - create_update_mongo_user_definition_parameters: Union[ - _models.MongoUserDefinitionCreateUpdateParameters, IO[bytes] + mongo_role_definition_id: str, + create_update_mongo_role_definition_parameters: Union[ + _models.MongoRoleDefinitionCreateUpdateParameters, IO[bytes] ], **kwargs: Any - ) -> AsyncLROPoller[_models.MongoUserDefinitionGetResults]: - """Creates or updates an Azure Cosmos DB Mongo User Definition. + ) -> AsyncLROPoller[_models.MongoRoleDefinitionGetResults]: + """Creates or updates an Azure Cosmos DB Mongo Role Definition. - :param mongo_user_definition_id: The ID for the User Definition {dbName.userName}. Required. - :type mongo_user_definition_id: str :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param create_update_mongo_user_definition_parameters: The properties required to create or - update a User Definition. Is either a MongoUserDefinitionCreateUpdateParameters type or a + :param mongo_role_definition_id: The ID for the Role Definition {dbName.roleName}. Required. + :type mongo_role_definition_id: str + :param create_update_mongo_role_definition_parameters: The properties required to create or + update a Role Definition. Is either a MongoRoleDefinitionCreateUpdateParameters type or a IO[bytes] type. Required. - :type create_update_mongo_user_definition_parameters: - ~azure.mgmt.cosmosdb.models.MongoUserDefinitionCreateUpdateParameters or IO[bytes] - :return: An instance of AsyncLROPoller that returns either MongoUserDefinitionGetResults or the + :type create_update_mongo_role_definition_parameters: + ~azure.mgmt.cosmosdb.models.MongoRoleDefinitionCreateUpdateParameters or IO[bytes] + :return: An instance of AsyncLROPoller that returns either MongoRoleDefinitionGetResults or the result of cls(response) :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.MongoUserDefinitionGetResults] + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.MongoRoleDefinitionGetResults] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -4210,16 +4128,16 @@ async def begin_create_update_mongo_user_definition( # pylint: disable=name-too 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.MongoUserDefinitionGetResults] = kwargs.pop("cls", None) + cls: ClsType[_models.MongoRoleDefinitionGetResults] = 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_update_mongo_user_definition_initial( - mongo_user_definition_id=mongo_user_definition_id, + raw_result = await self._create_update_mongo_role_definition_initial( resource_group_name=resource_group_name, account_name=account_name, - create_update_mongo_user_definition_parameters=create_update_mongo_user_definition_parameters, + mongo_role_definition_id=mongo_role_definition_id, + create_update_mongo_role_definition_parameters=create_update_mongo_role_definition_parameters, api_version=api_version, content_type=content_type, cls=lambda x, y, z: x, @@ -4231,30 +4149,32 @@ async def begin_create_update_mongo_user_definition( # pylint: disable=name-too kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("MongoUserDefinitionGetResults", pipeline_response.http_response) + deserialized = self._deserialize("MongoRoleDefinitionGetResults", 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, **kwargs)) + 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.MongoUserDefinitionGetResults].from_continuation_token( + return AsyncLROPoller[_models.MongoRoleDefinitionGetResults].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller[_models.MongoUserDefinitionGetResults]( + return AsyncLROPoller[_models.MongoRoleDefinitionGetResults]( self._client, raw_result, get_long_running_output, polling_method # type: ignore ) - async def _delete_mongo_user_definition_initial( - self, mongo_user_definition_id: str, resource_group_name: str, account_name: str, **kwargs: Any + async def _delete_mongo_role_definition_initial( + self, resource_group_name: str, account_name: str, mongo_role_definition_id: str, **kwargs: Any ) -> AsyncIterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -4270,10 +4190,10 @@ async def _delete_mongo_user_definition_initial( 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_mongo_user_definition_request( - mongo_user_definition_id=mongo_user_definition_id, + _request = build_delete_mongo_role_definition_request( resource_group_name=resource_group_name, account_name=account_name, + mongo_role_definition_id=mongo_role_definition_id, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, @@ -4297,26 +4217,31 @@ async def _delete_mongo_user_definition_initial( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @distributed_trace_async - async def begin_delete_mongo_user_definition( - self, mongo_user_definition_id: str, resource_group_name: str, account_name: str, **kwargs: Any + async def begin_delete_mongo_role_definition( + self, resource_group_name: str, account_name: str, mongo_role_definition_id: str, **kwargs: Any ) -> AsyncLROPoller[None]: - """Deletes an existing Azure Cosmos DB Mongo User Definition. + """Deletes an existing Azure Cosmos DB Mongo Role Definition. - :param mongo_user_definition_id: The ID for the User Definition {dbName.userName}. Required. - :type mongo_user_definition_id: str :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param account_name: Cosmos DB database account name. Required. :type account_name: str + :param mongo_role_definition_id: The ID for the Role Definition {dbName.roleName}. Required. + :type mongo_role_definition_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: @@ -4330,10 +4255,10 @@ async def begin_delete_mongo_user_definition( 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_mongo_user_definition_initial( - mongo_user_definition_id=mongo_user_definition_id, + raw_result = await self._delete_mongo_role_definition_initial( resource_group_name=resource_group_name, account_name=account_name, + mongo_role_definition_id=mongo_role_definition_id, api_version=api_version, cls=lambda x, y, z: x, headers=_headers, @@ -4348,7 +4273,9 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- return cls(pipeline_response, None, {}) # type: ignore if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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: @@ -4428,7 +4355,7 @@ async def extract_data(pipeline_response): list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore - return None, AsyncList(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): _request = prepare_request(next_link) @@ -4447,13 +4374,75 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - async def _retrieve_continuous_backup_information_initial( # pylint: disable=name-too-long + @distributed_trace_async + async def get_mongo_user_definition( + self, resource_group_name: str, account_name: str, mongo_user_definition_id: str, **kwargs: Any + ) -> _models.MongoUserDefinitionGetResults: + """Retrieves the properties of an existing Azure Cosmos DB Mongo User Definition with the given + Id. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param mongo_user_definition_id: The ID for the User Definition {dbName.userName}. Required. + :type mongo_user_definition_id: str + :return: MongoUserDefinitionGetResults or the result of cls(response) + :rtype: ~azure.mgmt.cosmosdb.models.MongoUserDefinitionGetResults + :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.MongoUserDefinitionGetResults] = kwargs.pop("cls", None) + + _request = build_get_mongo_user_definition_request( + resource_group_name=resource_group_name, + account_name=account_name, + mongo_user_definition_id=mongo_user_definition_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("MongoUserDefinitionGetResults", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + async def _create_update_mongo_user_definition_initial( # pylint: disable=name-too-long self, resource_group_name: str, account_name: str, - database_name: str, - collection_name: str, - location: Union[_models.ContinuousBackupRestoreLocation, IO[bytes]], + mongo_user_definition_id: str, + create_update_mongo_user_definition_parameters: Union[ + _models.MongoUserDefinitionCreateUpdateParameters, IO[bytes] + ], **kwargs: Any ) -> AsyncIterator[bytes]: error_map: MutableMapping = { @@ -4474,16 +4463,17 @@ async def _retrieve_continuous_backup_information_initial( # pylint: disable=na content_type = content_type or "application/json" _json = None _content = None - if isinstance(location, (IOBase, bytes)): - _content = location + if isinstance(create_update_mongo_user_definition_parameters, (IOBase, bytes)): + _content = create_update_mongo_user_definition_parameters else: - _json = self._serialize.body(location, "ContinuousBackupRestoreLocation") + _json = self._serialize.body( + create_update_mongo_user_definition_parameters, "MongoUserDefinitionCreateUpdateParameters" + ) - _request = build_retrieve_continuous_backup_information_request( + _request = build_create_update_mongo_user_definition_request( resource_group_name=resource_group_name, account_name=account_name, - database_name=database_name, - collection_name=collection_name, + mongo_user_definition_id=mongo_user_definition_id, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, @@ -4510,108 +4500,114 @@ async def _retrieve_continuous_backup_information_initial( # pylint: disable=na map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @overload - async def begin_retrieve_continuous_backup_information( # pylint: disable=name-too-long + async def begin_create_update_mongo_user_definition( # pylint: disable=name-too-long self, resource_group_name: str, account_name: str, - database_name: str, - collection_name: str, - location: _models.ContinuousBackupRestoreLocation, + mongo_user_definition_id: str, + create_update_mongo_user_definition_parameters: _models.MongoUserDefinitionCreateUpdateParameters, *, content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller[_models.BackupInformation]: - """Retrieves continuous backup information for a Mongodb collection. + ) -> AsyncLROPoller[_models.MongoUserDefinitionGetResults]: + """Creates or updates an Azure Cosmos DB Mongo User Definition. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param database_name: Cosmos DB database name. Required. - :type database_name: str - :param collection_name: Cosmos DB collection name. Required. - :type collection_name: str - :param location: The name of the continuous backup restore location. Required. - :type location: ~azure.mgmt.cosmosdb.models.ContinuousBackupRestoreLocation + :param mongo_user_definition_id: The ID for the User Definition {dbName.userName}. Required. + :type mongo_user_definition_id: str + :param create_update_mongo_user_definition_parameters: The properties required to create or + update a User Definition. Required. + :type create_update_mongo_user_definition_parameters: + ~azure.mgmt.cosmosdb.models.MongoUserDefinitionCreateUpdateParameters :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 BackupInformation or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.BackupInformation] + :return: An instance of AsyncLROPoller that returns either MongoUserDefinitionGetResults or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.MongoUserDefinitionGetResults] :raises ~azure.core.exceptions.HttpResponseError: """ @overload - async def begin_retrieve_continuous_backup_information( # pylint: disable=name-too-long + async def begin_create_update_mongo_user_definition( # pylint: disable=name-too-long self, resource_group_name: str, account_name: str, - database_name: str, - collection_name: str, - location: IO[bytes], + mongo_user_definition_id: str, + create_update_mongo_user_definition_parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller[_models.BackupInformation]: - """Retrieves continuous backup information for a Mongodb collection. + ) -> AsyncLROPoller[_models.MongoUserDefinitionGetResults]: + """Creates or updates an Azure Cosmos DB Mongo User Definition. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param database_name: Cosmos DB database name. Required. - :type database_name: str - :param collection_name: Cosmos DB collection name. Required. - :type collection_name: str - :param location: The name of the continuous backup restore location. Required. - :type location: IO[bytes] + :param mongo_user_definition_id: The ID for the User Definition {dbName.userName}. Required. + :type mongo_user_definition_id: str + :param create_update_mongo_user_definition_parameters: The properties required to create or + update a User Definition. Required. + :type create_update_mongo_user_definition_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 BackupInformation or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.BackupInformation] + :return: An instance of AsyncLROPoller that returns either MongoUserDefinitionGetResults or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.MongoUserDefinitionGetResults] :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace_async - async def begin_retrieve_continuous_backup_information( # pylint: disable=name-too-long + async def begin_create_update_mongo_user_definition( # pylint: disable=name-too-long self, resource_group_name: str, account_name: str, - database_name: str, - collection_name: str, - location: Union[_models.ContinuousBackupRestoreLocation, IO[bytes]], + mongo_user_definition_id: str, + create_update_mongo_user_definition_parameters: Union[ + _models.MongoUserDefinitionCreateUpdateParameters, IO[bytes] + ], **kwargs: Any - ) -> AsyncLROPoller[_models.BackupInformation]: - """Retrieves continuous backup information for a Mongodb collection. + ) -> AsyncLROPoller[_models.MongoUserDefinitionGetResults]: + """Creates or updates an Azure Cosmos DB Mongo User Definition. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param database_name: Cosmos DB database name. Required. - :type database_name: str - :param collection_name: Cosmos DB collection name. Required. - :type collection_name: str - :param location: The name of the continuous backup restore location. Is either a - ContinuousBackupRestoreLocation type or a IO[bytes] type. Required. - :type location: ~azure.mgmt.cosmosdb.models.ContinuousBackupRestoreLocation or IO[bytes] - :return: An instance of AsyncLROPoller that returns either BackupInformation or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.BackupInformation] + :param mongo_user_definition_id: The ID for the User Definition {dbName.userName}. Required. + :type mongo_user_definition_id: str + :param create_update_mongo_user_definition_parameters: The properties required to create or + update a User Definition. Is either a MongoUserDefinitionCreateUpdateParameters type or a + IO[bytes] type. Required. + :type create_update_mongo_user_definition_parameters: + ~azure.mgmt.cosmosdb.models.MongoUserDefinitionCreateUpdateParameters or IO[bytes] + :return: An instance of AsyncLROPoller that returns either MongoUserDefinitionGetResults or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.MongoUserDefinitionGetResults] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -4619,17 +4615,16 @@ async def begin_retrieve_continuous_backup_information( # pylint: disable=name- 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.BackupInformation] = kwargs.pop("cls", None) + cls: ClsType[_models.MongoUserDefinitionGetResults] = 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._retrieve_continuous_backup_information_initial( + raw_result = await self._create_update_mongo_user_definition_initial( resource_group_name=resource_group_name, account_name=account_name, - database_name=database_name, - collection_name=collection_name, - location=location, + mongo_user_definition_id=mongo_user_definition_id, + create_update_mongo_user_definition_parameters=create_update_mongo_user_definition_parameters, api_version=api_version, content_type=content_type, cls=lambda x, y, z: x, @@ -4641,7 +4636,7 @@ async def begin_retrieve_continuous_backup_information( # pylint: disable=name- kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("BackupInformation", pipeline_response.http_response) + deserialized = self._deserialize("MongoUserDefinitionGetResults", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized @@ -4655,12 +4650,128 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller[_models.BackupInformation].from_continuation_token( + return AsyncLROPoller[_models.MongoUserDefinitionGetResults].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller[_models.BackupInformation]( + return AsyncLROPoller[_models.MongoUserDefinitionGetResults]( self._client, raw_result, get_long_running_output, polling_method # type: ignore ) + + async def _delete_mongo_user_definition_initial( + self, resource_group_name: str, account_name: str, mongo_user_definition_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_mongo_user_definition_request( + resource_group_name=resource_group_name, + account_name=account_name, + mongo_user_definition_id=mongo_user_definition_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 [200, 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + 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_mongo_user_definition( + self, resource_group_name: str, account_name: str, mongo_user_definition_id: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Deletes an existing Azure Cosmos DB Mongo User Definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param mongo_user_definition_id: The ID for the User Definition {dbName.userName}. Required. + :type mongo_user_definition_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_mongo_user_definition_initial( + resource_group_name=resource_group_name, + account_name=account_name, + mongo_user_definition_id=mongo_user_definition_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 diff --git a/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/aio/operations/_mongo_mi_resources_operations.py b/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/aio/operations/_mongo_mi_resources_operations.py index acee6bfbab6..e74d8b8077c 100644 --- a/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/aio/operations/_mongo_mi_resources_operations.py +++ b/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/aio/operations/_mongo_mi_resources_operations.py @@ -70,11 +70,100 @@ def __init__(self, *args, **kwargs) -> None: 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_mongo_mi_role_assignments( + self, resource_group_name: str, account_name: str, **kwargs: Any + ) -> AsyncItemPaged["_models.MongoMIRoleAssignmentResource"]: + """Retrieves the list of all Azure Cosmos DB MongoMI Role Assignments. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :return: An iterator like instance of either MongoMIRoleAssignmentResource or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.MongoMIRoleAssignmentResource] + :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.MongoMIRoleAssignmentListResult] = 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_mongo_mi_role_assignments_request( + resource_group_name=resource_group_name, + account_name=account_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("MongoMIRoleAssignmentListResult", 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_mongo_mi_role_definition( - self, resource_group_name: str, account_name: str, role_definition_id: str, **kwargs: Any - ) -> _models.MongoMIRoleDefinitionResource: - """Retrieves the properties of an existing Azure Cosmos DB MongoMI Role Definition with the given + async def get_mongo_mi_role_assignment( + self, resource_group_name: str, account_name: str, role_assignment_id: str, **kwargs: Any + ) -> _models.MongoMIRoleAssignmentResource: + """Retrieves the properties of an existing Azure Cosmos DB MongoMI Role Assignment with the given Id. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -82,10 +171,10 @@ async def get_mongo_mi_role_definition( :type resource_group_name: str :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param role_definition_id: The GUID for the Role Definition. Required. - :type role_definition_id: str - :return: MongoMIRoleDefinitionResource or the result of cls(response) - :rtype: ~azure.mgmt.cosmosdb.models.MongoMIRoleDefinitionResource + :param role_assignment_id: The GUID for the Role Assignment. Required. + :type role_assignment_id: str + :return: MongoMIRoleAssignmentResource or the result of cls(response) + :rtype: ~azure.mgmt.cosmosdb.models.MongoMIRoleAssignmentResource :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -100,12 +189,12 @@ async def get_mongo_mi_role_definition( _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.MongoMIRoleDefinitionResource] = kwargs.pop("cls", None) + cls: ClsType[_models.MongoMIRoleAssignmentResource] = kwargs.pop("cls", None) - _request = build_get_mongo_mi_role_definition_request( + _request = build_get_mongo_mi_role_assignment_request( resource_group_name=resource_group_name, account_name=account_name, - role_definition_id=role_definition_id, + role_assignment_id=role_assignment_id, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, @@ -128,19 +217,19 @@ async def get_mongo_mi_role_definition( ) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("MongoMIRoleDefinitionResource", pipeline_response.http_response) + deserialized = self._deserialize("MongoMIRoleAssignmentResource", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - async def _create_update_mongo_mi_role_definition_initial( # pylint: disable=name-too-long + async def _create_update_mongo_mi_role_assignment_initial( # pylint: disable=name-too-long self, resource_group_name: str, account_name: str, - role_definition_id: str, - create_update_mongo_mi_role_definition_parameters: Union[_models.MongoMIRoleDefinitionResource, IO[bytes]], + role_assignment_id: str, + create_update_mongo_mi_role_assignment_parameters: Union[_models.MongoMIRoleAssignmentResource, IO[bytes]], **kwargs: Any ) -> AsyncIterator[bytes]: error_map: MutableMapping = { @@ -161,17 +250,17 @@ async def _create_update_mongo_mi_role_definition_initial( # pylint: disable=na content_type = content_type or "application/json" _json = None _content = None - if isinstance(create_update_mongo_mi_role_definition_parameters, (IOBase, bytes)): - _content = create_update_mongo_mi_role_definition_parameters + if isinstance(create_update_mongo_mi_role_assignment_parameters, (IOBase, bytes)): + _content = create_update_mongo_mi_role_assignment_parameters else: _json = self._serialize.body( - create_update_mongo_mi_role_definition_parameters, "MongoMIRoleDefinitionResource" + create_update_mongo_mi_role_assignment_parameters, "MongoMIRoleAssignmentResource" ) - _request = build_create_update_mongo_mi_role_definition_request( + _request = build_create_update_mongo_mi_role_assignment_request( resource_group_name=resource_group_name, account_name=account_name, - role_definition_id=role_definition_id, + role_assignment_id=role_assignment_id, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, @@ -204,10 +293,11 @@ async def _create_update_mongo_mi_role_definition_initial( # pylint: disable=na response_headers = {} if response.status_code == 202: - response_headers["azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("azure-AsyncOperation") + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") ) - response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) @@ -217,99 +307,99 @@ async def _create_update_mongo_mi_role_definition_initial( # pylint: disable=na return deserialized # type: ignore @overload - async def begin_create_update_mongo_mi_role_definition( # pylint: disable=name-too-long + async def begin_create_update_mongo_mi_role_assignment( # pylint: disable=name-too-long self, resource_group_name: str, account_name: str, - role_definition_id: str, - create_update_mongo_mi_role_definition_parameters: _models.MongoMIRoleDefinitionResource, + role_assignment_id: str, + create_update_mongo_mi_role_assignment_parameters: _models.MongoMIRoleAssignmentResource, *, content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller[_models.MongoMIRoleDefinitionResource]: - """Creates or updates an Azure Cosmos DB MongoMI Role Definition. + ) -> AsyncLROPoller[_models.MongoMIRoleAssignmentResource]: + """Creates or updates an Azure Cosmos DB MongoMI Role Assignment. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param role_definition_id: The GUID for the Role Definition. Required. - :type role_definition_id: str - :param create_update_mongo_mi_role_definition_parameters: The properties required to create or - update a Role Definition. Required. - :type create_update_mongo_mi_role_definition_parameters: - ~azure.mgmt.cosmosdb.models.MongoMIRoleDefinitionResource + :param role_assignment_id: The GUID for the Role Assignment. Required. + :type role_assignment_id: str + :param create_update_mongo_mi_role_assignment_parameters: The properties required to create or + update a Role Assignment. Required. + :type create_update_mongo_mi_role_assignment_parameters: + ~azure.mgmt.cosmosdb.models.MongoMIRoleAssignmentResource :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 MongoMIRoleDefinitionResource or the + :return: An instance of AsyncLROPoller that returns either MongoMIRoleAssignmentResource or the result of cls(response) :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.MongoMIRoleDefinitionResource] + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.MongoMIRoleAssignmentResource] :raises ~azure.core.exceptions.HttpResponseError: """ @overload - async def begin_create_update_mongo_mi_role_definition( # pylint: disable=name-too-long + async def begin_create_update_mongo_mi_role_assignment( # pylint: disable=name-too-long self, resource_group_name: str, account_name: str, - role_definition_id: str, - create_update_mongo_mi_role_definition_parameters: IO[bytes], + role_assignment_id: str, + create_update_mongo_mi_role_assignment_parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller[_models.MongoMIRoleDefinitionResource]: - """Creates or updates an Azure Cosmos DB MongoMI Role Definition. + ) -> AsyncLROPoller[_models.MongoMIRoleAssignmentResource]: + """Creates or updates an Azure Cosmos DB MongoMI Role Assignment. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param role_definition_id: The GUID for the Role Definition. Required. - :type role_definition_id: str - :param create_update_mongo_mi_role_definition_parameters: The properties required to create or - update a Role Definition. Required. - :type create_update_mongo_mi_role_definition_parameters: IO[bytes] + :param role_assignment_id: The GUID for the Role Assignment. Required. + :type role_assignment_id: str + :param create_update_mongo_mi_role_assignment_parameters: The properties required to create or + update a Role Assignment. Required. + :type create_update_mongo_mi_role_assignment_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 MongoMIRoleDefinitionResource or the + :return: An instance of AsyncLROPoller that returns either MongoMIRoleAssignmentResource or the result of cls(response) :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.MongoMIRoleDefinitionResource] + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.MongoMIRoleAssignmentResource] :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace_async - async def begin_create_update_mongo_mi_role_definition( # pylint: disable=name-too-long + async def begin_create_update_mongo_mi_role_assignment( # pylint: disable=name-too-long self, resource_group_name: str, account_name: str, - role_definition_id: str, - create_update_mongo_mi_role_definition_parameters: Union[_models.MongoMIRoleDefinitionResource, IO[bytes]], + role_assignment_id: str, + create_update_mongo_mi_role_assignment_parameters: Union[_models.MongoMIRoleAssignmentResource, IO[bytes]], **kwargs: Any - ) -> AsyncLROPoller[_models.MongoMIRoleDefinitionResource]: - """Creates or updates an Azure Cosmos DB MongoMI Role Definition. + ) -> AsyncLROPoller[_models.MongoMIRoleAssignmentResource]: + """Creates or updates an Azure Cosmos DB MongoMI Role Assignment. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param role_definition_id: The GUID for the Role Definition. Required. - :type role_definition_id: str - :param create_update_mongo_mi_role_definition_parameters: The properties required to create or - update a Role Definition. Is either a MongoMIRoleDefinitionResource type or a IO[bytes] type. + :param role_assignment_id: The GUID for the Role Assignment. Required. + :type role_assignment_id: str + :param create_update_mongo_mi_role_assignment_parameters: The properties required to create or + update a Role Assignment. Is either a MongoMIRoleAssignmentResource type or a IO[bytes] type. Required. - :type create_update_mongo_mi_role_definition_parameters: - ~azure.mgmt.cosmosdb.models.MongoMIRoleDefinitionResource or IO[bytes] - :return: An instance of AsyncLROPoller that returns either MongoMIRoleDefinitionResource or the + :type create_update_mongo_mi_role_assignment_parameters: + ~azure.mgmt.cosmosdb.models.MongoMIRoleAssignmentResource or IO[bytes] + :return: An instance of AsyncLROPoller that returns either MongoMIRoleAssignmentResource or the result of cls(response) :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.MongoMIRoleDefinitionResource] + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.MongoMIRoleAssignmentResource] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -317,16 +407,16 @@ async def begin_create_update_mongo_mi_role_definition( # pylint: disable=name- 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.MongoMIRoleDefinitionResource] = kwargs.pop("cls", None) + cls: ClsType[_models.MongoMIRoleAssignmentResource] = 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_update_mongo_mi_role_definition_initial( + raw_result = await self._create_update_mongo_mi_role_assignment_initial( resource_group_name=resource_group_name, account_name=account_name, - role_definition_id=role_definition_id, - create_update_mongo_mi_role_definition_parameters=create_update_mongo_mi_role_definition_parameters, + role_assignment_id=role_assignment_id, + create_update_mongo_mi_role_assignment_parameters=create_update_mongo_mi_role_assignment_parameters, api_version=api_version, content_type=content_type, cls=lambda x, y, z: x, @@ -338,30 +428,32 @@ async def begin_create_update_mongo_mi_role_definition( # pylint: disable=name- kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("MongoMIRoleDefinitionResource", pipeline_response.http_response) + deserialized = self._deserialize("MongoMIRoleAssignmentResource", 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, **kwargs)) + 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.MongoMIRoleDefinitionResource].from_continuation_token( + return AsyncLROPoller[_models.MongoMIRoleAssignmentResource].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller[_models.MongoMIRoleDefinitionResource]( + return AsyncLROPoller[_models.MongoMIRoleAssignmentResource]( self._client, raw_result, get_long_running_output, polling_method # type: ignore ) - async def _delete_mongo_mi_role_definition_initial( - self, resource_group_name: str, account_name: str, role_definition_id: str, **kwargs: Any + async def _delete_mongo_mi_role_assignment_initial( + self, resource_group_name: str, account_name: str, role_assignment_id: str, **kwargs: Any ) -> AsyncIterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -377,10 +469,10 @@ async def _delete_mongo_mi_role_definition_initial( 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_mongo_mi_role_definition_request( + _request = build_delete_mongo_mi_role_assignment_request( resource_group_name=resource_group_name, account_name=account_name, - role_definition_id=role_definition_id, + role_assignment_id=role_assignment_id, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, @@ -410,10 +502,10 @@ async def _delete_mongo_mi_role_definition_initial( response_headers = {} if response.status_code == 202: - response_headers["azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("azure-AsyncOperation") + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") ) - response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) @@ -423,18 +515,18 @@ async def _delete_mongo_mi_role_definition_initial( return deserialized # type: ignore @distributed_trace_async - async def begin_delete_mongo_mi_role_definition( - self, resource_group_name: str, account_name: str, role_definition_id: str, **kwargs: Any + async def begin_delete_mongo_mi_role_assignment( + self, resource_group_name: str, account_name: str, role_assignment_id: str, **kwargs: Any ) -> AsyncLROPoller[None]: - """Deletes an existing Azure Cosmos DB MongoMI Role Definition. + """Deletes an existing Azure Cosmos DB MongoMI Role Assignment. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param role_definition_id: The GUID for the Role Definition. Required. - :type role_definition_id: str + :param role_assignment_id: The GUID for the Role Assignment. Required. + :type role_assignment_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: @@ -448,10 +540,10 @@ async def begin_delete_mongo_mi_role_definition( 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_mongo_mi_role_definition_initial( + raw_result = await self._delete_mongo_mi_role_assignment_initial( resource_group_name=resource_group_name, account_name=account_name, - role_definition_id=role_definition_id, + role_assignment_id=role_assignment_id, api_version=api_version, cls=lambda x, y, z: x, headers=_headers, @@ -466,7 +558,9 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- return cls(pipeline_response, None, {}) # type: ignore if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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: @@ -546,7 +640,7 @@ async def extract_data(pipeline_response): list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore - return None, AsyncList(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): _request = prepare_request(next_link) @@ -570,10 +664,10 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) @distributed_trace_async - async def get_mongo_mi_role_assignment( - self, resource_group_name: str, account_name: str, role_assignment_id: str, **kwargs: Any - ) -> _models.MongoMIRoleAssignmentResource: - """Retrieves the properties of an existing Azure Cosmos DB MongoMI Role Assignment with the given + async def get_mongo_mi_role_definition( + self, resource_group_name: str, account_name: str, role_definition_id: str, **kwargs: Any + ) -> _models.MongoMIRoleDefinitionResource: + """Retrieves the properties of an existing Azure Cosmos DB MongoMI Role Definition with the given Id. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -581,10 +675,10 @@ async def get_mongo_mi_role_assignment( :type resource_group_name: str :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param role_assignment_id: The GUID for the Role Assignment. Required. - :type role_assignment_id: str - :return: MongoMIRoleAssignmentResource or the result of cls(response) - :rtype: ~azure.mgmt.cosmosdb.models.MongoMIRoleAssignmentResource + :param role_definition_id: The GUID for the Role Definition. Required. + :type role_definition_id: str + :return: MongoMIRoleDefinitionResource or the result of cls(response) + :rtype: ~azure.mgmt.cosmosdb.models.MongoMIRoleDefinitionResource :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -599,12 +693,12 @@ async def get_mongo_mi_role_assignment( _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.MongoMIRoleAssignmentResource] = kwargs.pop("cls", None) + cls: ClsType[_models.MongoMIRoleDefinitionResource] = kwargs.pop("cls", None) - _request = build_get_mongo_mi_role_assignment_request( + _request = build_get_mongo_mi_role_definition_request( resource_group_name=resource_group_name, account_name=account_name, - role_assignment_id=role_assignment_id, + role_definition_id=role_definition_id, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, @@ -627,19 +721,19 @@ async def get_mongo_mi_role_assignment( ) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("MongoMIRoleAssignmentResource", pipeline_response.http_response) + deserialized = self._deserialize("MongoMIRoleDefinitionResource", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - async def _create_update_mongo_mi_role_assignment_initial( # pylint: disable=name-too-long + async def _create_update_mongo_mi_role_definition_initial( # pylint: disable=name-too-long self, resource_group_name: str, account_name: str, - role_assignment_id: str, - create_update_mongo_mi_role_assignment_parameters: Union[_models.MongoMIRoleAssignmentResource, IO[bytes]], + role_definition_id: str, + create_update_mongo_mi_role_definition_parameters: Union[_models.MongoMIRoleDefinitionResource, IO[bytes]], **kwargs: Any ) -> AsyncIterator[bytes]: error_map: MutableMapping = { @@ -660,17 +754,17 @@ async def _create_update_mongo_mi_role_assignment_initial( # pylint: disable=na content_type = content_type or "application/json" _json = None _content = None - if isinstance(create_update_mongo_mi_role_assignment_parameters, (IOBase, bytes)): - _content = create_update_mongo_mi_role_assignment_parameters + if isinstance(create_update_mongo_mi_role_definition_parameters, (IOBase, bytes)): + _content = create_update_mongo_mi_role_definition_parameters else: _json = self._serialize.body( - create_update_mongo_mi_role_assignment_parameters, "MongoMIRoleAssignmentResource" + create_update_mongo_mi_role_definition_parameters, "MongoMIRoleDefinitionResource" ) - _request = build_create_update_mongo_mi_role_assignment_request( + _request = build_create_update_mongo_mi_role_definition_request( resource_group_name=resource_group_name, account_name=account_name, - role_assignment_id=role_assignment_id, + role_definition_id=role_definition_id, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, @@ -703,10 +797,11 @@ async def _create_update_mongo_mi_role_assignment_initial( # pylint: disable=na response_headers = {} if response.status_code == 202: - response_headers["azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("azure-AsyncOperation") + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") ) - response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) @@ -716,99 +811,99 @@ async def _create_update_mongo_mi_role_assignment_initial( # pylint: disable=na return deserialized # type: ignore @overload - async def begin_create_update_mongo_mi_role_assignment( # pylint: disable=name-too-long + async def begin_create_update_mongo_mi_role_definition( # pylint: disable=name-too-long self, resource_group_name: str, account_name: str, - role_assignment_id: str, - create_update_mongo_mi_role_assignment_parameters: _models.MongoMIRoleAssignmentResource, + role_definition_id: str, + create_update_mongo_mi_role_definition_parameters: _models.MongoMIRoleDefinitionResource, *, content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller[_models.MongoMIRoleAssignmentResource]: - """Creates or updates an Azure Cosmos DB MongoMI Role Assignment. + ) -> AsyncLROPoller[_models.MongoMIRoleDefinitionResource]: + """Creates or updates an Azure Cosmos DB MongoMI Role Definition. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param role_assignment_id: The GUID for the Role Assignment. Required. - :type role_assignment_id: str - :param create_update_mongo_mi_role_assignment_parameters: The properties required to create or - update a Role Assignment. Required. - :type create_update_mongo_mi_role_assignment_parameters: - ~azure.mgmt.cosmosdb.models.MongoMIRoleAssignmentResource + :param role_definition_id: The GUID for the Role Definition. Required. + :type role_definition_id: str + :param create_update_mongo_mi_role_definition_parameters: The properties required to create or + update a Role Definition. Required. + :type create_update_mongo_mi_role_definition_parameters: + ~azure.mgmt.cosmosdb.models.MongoMIRoleDefinitionResource :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 MongoMIRoleAssignmentResource or the + :return: An instance of AsyncLROPoller that returns either MongoMIRoleDefinitionResource or the result of cls(response) :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.MongoMIRoleAssignmentResource] + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.MongoMIRoleDefinitionResource] :raises ~azure.core.exceptions.HttpResponseError: """ @overload - async def begin_create_update_mongo_mi_role_assignment( # pylint: disable=name-too-long + async def begin_create_update_mongo_mi_role_definition( # pylint: disable=name-too-long self, resource_group_name: str, account_name: str, - role_assignment_id: str, - create_update_mongo_mi_role_assignment_parameters: IO[bytes], + role_definition_id: str, + create_update_mongo_mi_role_definition_parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller[_models.MongoMIRoleAssignmentResource]: - """Creates or updates an Azure Cosmos DB MongoMI Role Assignment. + ) -> AsyncLROPoller[_models.MongoMIRoleDefinitionResource]: + """Creates or updates an Azure Cosmos DB MongoMI Role Definition. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param role_assignment_id: The GUID for the Role Assignment. Required. - :type role_assignment_id: str - :param create_update_mongo_mi_role_assignment_parameters: The properties required to create or - update a Role Assignment. Required. - :type create_update_mongo_mi_role_assignment_parameters: IO[bytes] + :param role_definition_id: The GUID for the Role Definition. Required. + :type role_definition_id: str + :param create_update_mongo_mi_role_definition_parameters: The properties required to create or + update a Role Definition. Required. + :type create_update_mongo_mi_role_definition_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 MongoMIRoleAssignmentResource or the + :return: An instance of AsyncLROPoller that returns either MongoMIRoleDefinitionResource or the result of cls(response) :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.MongoMIRoleAssignmentResource] + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.MongoMIRoleDefinitionResource] :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace_async - async def begin_create_update_mongo_mi_role_assignment( # pylint: disable=name-too-long + async def begin_create_update_mongo_mi_role_definition( # pylint: disable=name-too-long self, resource_group_name: str, account_name: str, - role_assignment_id: str, - create_update_mongo_mi_role_assignment_parameters: Union[_models.MongoMIRoleAssignmentResource, IO[bytes]], + role_definition_id: str, + create_update_mongo_mi_role_definition_parameters: Union[_models.MongoMIRoleDefinitionResource, IO[bytes]], **kwargs: Any - ) -> AsyncLROPoller[_models.MongoMIRoleAssignmentResource]: - """Creates or updates an Azure Cosmos DB MongoMI Role Assignment. + ) -> AsyncLROPoller[_models.MongoMIRoleDefinitionResource]: + """Creates or updates an Azure Cosmos DB MongoMI Role Definition. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param role_assignment_id: The GUID for the Role Assignment. Required. - :type role_assignment_id: str - :param create_update_mongo_mi_role_assignment_parameters: The properties required to create or - update a Role Assignment. Is either a MongoMIRoleAssignmentResource type or a IO[bytes] type. + :param role_definition_id: The GUID for the Role Definition. Required. + :type role_definition_id: str + :param create_update_mongo_mi_role_definition_parameters: The properties required to create or + update a Role Definition. Is either a MongoMIRoleDefinitionResource type or a IO[bytes] type. Required. - :type create_update_mongo_mi_role_assignment_parameters: - ~azure.mgmt.cosmosdb.models.MongoMIRoleAssignmentResource or IO[bytes] - :return: An instance of AsyncLROPoller that returns either MongoMIRoleAssignmentResource or the + :type create_update_mongo_mi_role_definition_parameters: + ~azure.mgmt.cosmosdb.models.MongoMIRoleDefinitionResource or IO[bytes] + :return: An instance of AsyncLROPoller that returns either MongoMIRoleDefinitionResource or the result of cls(response) :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.MongoMIRoleAssignmentResource] + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.MongoMIRoleDefinitionResource] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -816,16 +911,16 @@ async def begin_create_update_mongo_mi_role_assignment( # pylint: disable=name- 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.MongoMIRoleAssignmentResource] = kwargs.pop("cls", None) + cls: ClsType[_models.MongoMIRoleDefinitionResource] = 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_update_mongo_mi_role_assignment_initial( + raw_result = await self._create_update_mongo_mi_role_definition_initial( resource_group_name=resource_group_name, account_name=account_name, - role_assignment_id=role_assignment_id, - create_update_mongo_mi_role_assignment_parameters=create_update_mongo_mi_role_assignment_parameters, + role_definition_id=role_definition_id, + create_update_mongo_mi_role_definition_parameters=create_update_mongo_mi_role_definition_parameters, api_version=api_version, content_type=content_type, cls=lambda x, y, z: x, @@ -837,30 +932,32 @@ async def begin_create_update_mongo_mi_role_assignment( # pylint: disable=name- kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("MongoMIRoleAssignmentResource", pipeline_response.http_response) + deserialized = self._deserialize("MongoMIRoleDefinitionResource", 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, **kwargs)) + 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.MongoMIRoleAssignmentResource].from_continuation_token( + return AsyncLROPoller[_models.MongoMIRoleDefinitionResource].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller[_models.MongoMIRoleAssignmentResource]( + return AsyncLROPoller[_models.MongoMIRoleDefinitionResource]( self._client, raw_result, get_long_running_output, polling_method # type: ignore ) - async def _delete_mongo_mi_role_assignment_initial( - self, resource_group_name: str, account_name: str, role_assignment_id: str, **kwargs: Any + async def _delete_mongo_mi_role_definition_initial( + self, resource_group_name: str, account_name: str, role_definition_id: str, **kwargs: Any ) -> AsyncIterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -876,10 +973,10 @@ async def _delete_mongo_mi_role_assignment_initial( 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_mongo_mi_role_assignment_request( + _request = build_delete_mongo_mi_role_definition_request( resource_group_name=resource_group_name, account_name=account_name, - role_assignment_id=role_assignment_id, + role_definition_id=role_definition_id, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, @@ -909,10 +1006,10 @@ async def _delete_mongo_mi_role_assignment_initial( response_headers = {} if response.status_code == 202: - response_headers["azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("azure-AsyncOperation") + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") ) - response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) @@ -922,18 +1019,18 @@ async def _delete_mongo_mi_role_assignment_initial( return deserialized # type: ignore @distributed_trace_async - async def begin_delete_mongo_mi_role_assignment( - self, resource_group_name: str, account_name: str, role_assignment_id: str, **kwargs: Any + async def begin_delete_mongo_mi_role_definition( + self, resource_group_name: str, account_name: str, role_definition_id: str, **kwargs: Any ) -> AsyncLROPoller[None]: - """Deletes an existing Azure Cosmos DB MongoMI Role Assignment. + """Deletes an existing Azure Cosmos DB MongoMI Role Definition. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param role_assignment_id: The GUID for the Role Assignment. Required. - :type role_assignment_id: str + :param role_definition_id: The GUID for the Role Definition. Required. + :type role_definition_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: @@ -947,10 +1044,10 @@ async def begin_delete_mongo_mi_role_assignment( 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_mongo_mi_role_assignment_initial( + raw_result = await self._delete_mongo_mi_role_definition_initial( resource_group_name=resource_group_name, account_name=account_name, - role_assignment_id=role_assignment_id, + role_definition_id=role_definition_id, api_version=api_version, cls=lambda x, y, z: x, headers=_headers, @@ -965,7 +1062,9 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- return cls(pipeline_response, None, {}) # type: ignore if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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: @@ -978,92 +1077,3 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- 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_mongo_mi_role_assignments( - self, resource_group_name: str, account_name: str, **kwargs: Any - ) -> AsyncItemPaged["_models.MongoMIRoleAssignmentResource"]: - """Retrieves the list of all Azure Cosmos DB MongoMI Role Assignments. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param account_name: Cosmos DB database account name. Required. - :type account_name: str - :return: An iterator like instance of either MongoMIRoleAssignmentResource or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.MongoMIRoleAssignmentResource] - :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.MongoMIRoleAssignmentListResult] = 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_mongo_mi_role_assignments_request( - resource_group_name=resource_group_name, - account_name=account_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("MongoMIRoleAssignmentListResult", 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/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/aio/operations/_network_security_perimeter_configurations_operations.py b/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/aio/operations/_network_security_perimeter_configurations_operations.py index 6807d3ae603..76c5ccf7ff5 100644 --- a/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/aio/operations/_network_security_perimeter_configurations_operations.py +++ b/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/aio/operations/_network_security_perimeter_configurations_operations.py @@ -275,6 +275,7 @@ async def _reconcile_initial( response_headers = {} response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) diff --git a/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/aio/operations/_notebook_workspaces_operations.py b/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/aio/operations/_notebook_workspaces_operations.py index 3df3a3cff06..5a2508ce7d2 100644 --- a/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/aio/operations/_notebook_workspaces_operations.py +++ b/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/aio/operations/_notebook_workspaces_operations.py @@ -132,7 +132,7 @@ async def extract_data(pipeline_response): list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore - return None, AsyncList(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): _request = prepare_request(next_link) @@ -146,7 +146,7 @@ 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( - _models.ErrorResponseAutoGenerated2, + _models.ErrorResponse, pipeline_response, ) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -212,7 +212,7 @@ async def get( 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.ErrorResponseAutoGenerated2, + _models.ErrorResponse, pipeline_response, ) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -284,15 +284,18 @@ async def _create_or_update_initial( pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize( - _models.ErrorResponseAutoGenerated2, + _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")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @@ -418,13 +421,19 @@ async def begin_create_or_update( kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): + response_headers = {} + response = pipeline_response.http_response + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + deserialized = self._deserialize("NotebookWorkspace", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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: @@ -487,15 +496,20 @@ async def _delete_initial( pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize( - _models.ErrorResponseAutoGenerated2, + _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["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @@ -548,7 +562,9 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- return cls(pipeline_response, None, {}) # type: ignore if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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: @@ -619,7 +635,7 @@ async def list_connection_info( 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.ErrorResponseAutoGenerated2, + _models.ErrorResponse, pipeline_response, ) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -678,15 +694,20 @@ async def _regenerate_auth_token_initial( pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize( - _models.ErrorResponseAutoGenerated2, + _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["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @@ -739,7 +760,9 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- return cls(pipeline_response, None, {}) # type: ignore if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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: @@ -800,15 +823,20 @@ async def _start_initial( pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize( - _models.ErrorResponseAutoGenerated2, + _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["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @@ -861,7 +889,9 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- return cls(pipeline_response, None, {}) # type: ignore if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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: diff --git a/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/aio/operations/_operations.py b/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/aio/operations/_operations.py index 8487989cb33..d6785118260 100644 --- a/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/aio/operations/_operations.py +++ b/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/aio/operations/_operations.py @@ -121,7 +121,11 @@ 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response diff --git a/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/aio/operations/_partition_key_range_id_operations.py b/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/aio/operations/_partition_key_range_id_operations.py index bdfd50744f4..ef36ad673f3 100644 --- a/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/aio/operations/_partition_key_range_id_operations.py +++ b/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/aio/operations/_partition_key_range_id_operations.py @@ -139,7 +139,7 @@ async def extract_data(pipeline_response): list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore - return None, AsyncList(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): _request = prepare_request(next_link) @@ -152,7 +152,11 @@ 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response diff --git a/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/aio/operations/_partition_key_range_id_region_operations.py b/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/aio/operations/_partition_key_range_id_region_operations.py index 8a29d15f7da..b7338b9413f 100644 --- a/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/aio/operations/_partition_key_range_id_region_operations.py +++ b/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/aio/operations/_partition_key_range_id_region_operations.py @@ -144,7 +144,7 @@ async def extract_data(pipeline_response): list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore - return None, AsyncList(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): _request = prepare_request(next_link) @@ -157,7 +157,11 @@ 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response diff --git a/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/aio/operations/_patch.py b/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/aio/operations/_patch.py index f7dd3251033..87676c65a8f 100644 --- a/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/aio/operations/_patch.py +++ b/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/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/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/aio/operations/_percentile_operations.py b/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/aio/operations/_percentile_operations.py index fd870fd936e..91fcb5cd803 100644 --- a/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/aio/operations/_percentile_operations.py +++ b/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/aio/operations/_percentile_operations.py @@ -124,7 +124,7 @@ async def extract_data(pipeline_response): list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore - return None, AsyncList(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): _request = prepare_request(next_link) @@ -137,7 +137,11 @@ 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response diff --git a/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/aio/operations/_percentile_source_target_operations.py b/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/aio/operations/_percentile_source_target_operations.py index aa6f8c1f6e1..674dbf8157a 100644 --- a/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/aio/operations/_percentile_source_target_operations.py +++ b/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/aio/operations/_percentile_source_target_operations.py @@ -138,7 +138,7 @@ async def extract_data(pipeline_response): list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore - return None, AsyncList(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): _request = prepare_request(next_link) @@ -151,7 +151,11 @@ 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response diff --git a/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/aio/operations/_percentile_target_operations.py b/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/aio/operations/_percentile_target_operations.py index 58c5b28744a..09d9b9e288b 100644 --- a/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/aio/operations/_percentile_target_operations.py +++ b/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/aio/operations/_percentile_target_operations.py @@ -128,7 +128,7 @@ async def extract_data(pipeline_response): list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore - return None, AsyncList(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): _request = prepare_request(next_link) @@ -141,7 +141,11 @@ 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response diff --git a/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/aio/operations/_private_endpoint_connections_operations.py b/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/aio/operations/_private_endpoint_connections_operations.py index 7bbb0d32d5b..967958d1326 100644 --- a/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/aio/operations/_private_endpoint_connections_operations.py +++ b/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/aio/operations/_private_endpoint_connections_operations.py @@ -131,7 +131,7 @@ async def extract_data(pipeline_response): list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore - return None, AsyncList(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): _request = prepare_request(next_link) @@ -144,7 +144,11 @@ 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response @@ -201,7 +205,11 @@ async def get( if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + 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) @@ -275,10 +283,15 @@ async def _create_or_update_initial( ) 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["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @@ -404,7 +417,9 @@ def get_long_running_output(pipeline_response): return deserialized if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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: @@ -468,10 +483,15 @@ async def _delete_initial( ) 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["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @@ -519,7 +539,9 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- return cls(pipeline_response, None, {}) # type: ignore if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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: diff --git a/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/aio/operations/_private_link_resources_operations.py b/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/aio/operations/_private_link_resources_operations.py index 19e69f74758..b8372b13230 100644 --- a/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/aio/operations/_private_link_resources_operations.py +++ b/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/aio/operations/_private_link_resources_operations.py @@ -120,7 +120,7 @@ async def extract_data(pipeline_response): list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore - return None, AsyncList(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): _request = prepare_request(next_link) @@ -133,7 +133,11 @@ 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response @@ -190,7 +194,11 @@ async def get( if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + 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) diff --git a/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/aio/operations/_restorable_database_accounts_operations.py b/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/aio/operations/_restorable_database_accounts_operations.py index 04f88c3b488..7b94d309455 100644 --- a/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/aio/operations/_restorable_database_accounts_operations.py +++ b/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/aio/operations/_restorable_database_accounts_operations.py @@ -124,7 +124,7 @@ async def extract_data(pipeline_response): list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore - return None, AsyncList(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): _request = prepare_request(next_link) @@ -143,6 +143,64 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) + @distributed_trace_async + async def get_by_location( + self, location: str, instance_id: str, **kwargs: Any + ) -> _models.RestorableDatabaseAccountGetResult: + """Retrieves the properties of an existing Azure Cosmos DB restorable database account. This call + requires 'Microsoft.DocumentDB/locations/restorableDatabaseAccounts/read/*' permission. + + :param location: Cosmos DB region, with spaces between words and each word capitalized. + Required. + :type location: str + :param instance_id: The instanceId GUID of a restorable database account. Required. + :type instance_id: str + :return: RestorableDatabaseAccountGetResult or the result of cls(response) + :rtype: ~azure.mgmt.cosmosdb.models.RestorableDatabaseAccountGetResult + :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.RestorableDatabaseAccountGetResult] = kwargs.pop("cls", None) + + _request = build_get_by_location_request( + location=location, + instance_id=instance_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("RestorableDatabaseAccountGetResult", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + @distributed_trace def list(self, **kwargs: Any) -> AsyncItemPaged["_models.RestorableDatabaseAccountGetResult"]: """Lists all the restorable Azure Cosmos DB database accounts available under the subscription. @@ -201,7 +259,7 @@ async def extract_data(pipeline_response): list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore - return None, AsyncList(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): _request = prepare_request(next_link) @@ -219,61 +277,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - @distributed_trace_async - async def get_by_location( - self, location: str, instance_id: str, **kwargs: Any - ) -> _models.RestorableDatabaseAccountGetResult: - """Retrieves the properties of an existing Azure Cosmos DB restorable database account. This call - requires 'Microsoft.DocumentDB/locations/restorableDatabaseAccounts/read/*' permission. - - :param location: Cosmos DB region, with spaces between words and each word capitalized. - Required. - :type location: str - :param instance_id: The instanceId GUID of a restorable database account. Required. - :type instance_id: str - :return: RestorableDatabaseAccountGetResult or the result of cls(response) - :rtype: ~azure.mgmt.cosmosdb.models.RestorableDatabaseAccountGetResult - :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.RestorableDatabaseAccountGetResult] = kwargs.pop("cls", None) - - _request = build_get_by_location_request( - location=location, - instance_id=instance_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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("RestorableDatabaseAccountGetResult", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/aio/operations/_restorable_gremlin_databases_operations.py b/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/aio/operations/_restorable_gremlin_databases_operations.py index 47aa8a064be..0731b9256bd 100644 --- a/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/aio/operations/_restorable_gremlin_databases_operations.py +++ b/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/aio/operations/_restorable_gremlin_databases_operations.py @@ -123,7 +123,7 @@ async def extract_data(pipeline_response): list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore - return None, AsyncList(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): _request = prepare_request(next_link) diff --git a/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/aio/operations/_restorable_gremlin_graphs_operations.py b/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/aio/operations/_restorable_gremlin_graphs_operations.py index 2d6eb85f75b..57504895592 100644 --- a/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/aio/operations/_restorable_gremlin_graphs_operations.py +++ b/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/aio/operations/_restorable_gremlin_graphs_operations.py @@ -138,7 +138,7 @@ async def extract_data(pipeline_response): list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore - return None, AsyncList(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): _request = prepare_request(next_link) diff --git a/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/aio/operations/_restorable_gremlin_resources_operations.py b/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/aio/operations/_restorable_gremlin_resources_operations.py index ca83dc9f788..44ba0422a31 100644 --- a/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/aio/operations/_restorable_gremlin_resources_operations.py +++ b/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/aio/operations/_restorable_gremlin_resources_operations.py @@ -136,7 +136,7 @@ async def extract_data(pipeline_response): list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore - return None, AsyncList(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): _request = prepare_request(next_link) diff --git a/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/aio/operations/_restorable_mongodb_collections_operations.py b/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/aio/operations/_restorable_mongodb_collections_operations.py index b8d0ecccc34..53985c41aa0 100644 --- a/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/aio/operations/_restorable_mongodb_collections_operations.py +++ b/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/aio/operations/_restorable_mongodb_collections_operations.py @@ -138,7 +138,7 @@ async def extract_data(pipeline_response): list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore - return None, AsyncList(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): _request = prepare_request(next_link) diff --git a/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/aio/operations/_restorable_mongodb_databases_operations.py b/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/aio/operations/_restorable_mongodb_databases_operations.py index e5e3d1f6406..70f698d71c0 100644 --- a/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/aio/operations/_restorable_mongodb_databases_operations.py +++ b/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/aio/operations/_restorable_mongodb_databases_operations.py @@ -123,7 +123,7 @@ async def extract_data(pipeline_response): list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore - return None, AsyncList(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): _request = prepare_request(next_link) diff --git a/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/aio/operations/_restorable_mongodb_resources_operations.py b/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/aio/operations/_restorable_mongodb_resources_operations.py index 43ba3393947..b9ae9ae17ca 100644 --- a/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/aio/operations/_restorable_mongodb_resources_operations.py +++ b/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/aio/operations/_restorable_mongodb_resources_operations.py @@ -136,7 +136,7 @@ async def extract_data(pipeline_response): list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore - return None, AsyncList(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): _request = prepare_request(next_link) diff --git a/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/aio/operations/_restorable_sql_containers_operations.py b/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/aio/operations/_restorable_sql_containers_operations.py index c7c0422287b..e8345d6296a 100644 --- a/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/aio/operations/_restorable_sql_containers_operations.py +++ b/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/aio/operations/_restorable_sql_containers_operations.py @@ -137,7 +137,7 @@ async def extract_data(pipeline_response): list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore - return None, AsyncList(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): _request = prepare_request(next_link) diff --git a/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/aio/operations/_restorable_sql_databases_operations.py b/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/aio/operations/_restorable_sql_databases_operations.py index 05adc411ff1..9ebc26cb73c 100644 --- a/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/aio/operations/_restorable_sql_databases_operations.py +++ b/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/aio/operations/_restorable_sql_databases_operations.py @@ -123,7 +123,7 @@ async def extract_data(pipeline_response): list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore - return None, AsyncList(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): _request = prepare_request(next_link) diff --git a/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/aio/operations/_restorable_sql_resources_operations.py b/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/aio/operations/_restorable_sql_resources_operations.py index 57888d08907..977d6bcbed6 100644 --- a/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/aio/operations/_restorable_sql_resources_operations.py +++ b/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/aio/operations/_restorable_sql_resources_operations.py @@ -136,7 +136,7 @@ async def extract_data(pipeline_response): list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore - return None, AsyncList(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): _request = prepare_request(next_link) diff --git a/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/aio/operations/_restorable_table_resources_operations.py b/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/aio/operations/_restorable_table_resources_operations.py index 750a0c5451c..6c15f413b92 100644 --- a/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/aio/operations/_restorable_table_resources_operations.py +++ b/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/aio/operations/_restorable_table_resources_operations.py @@ -135,7 +135,7 @@ async def extract_data(pipeline_response): list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore - return None, AsyncList(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): _request = prepare_request(next_link) diff --git a/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/aio/operations/_restorable_tables_operations.py b/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/aio/operations/_restorable_tables_operations.py index ce8780126c5..f5db400c050 100644 --- a/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/aio/operations/_restorable_tables_operations.py +++ b/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/aio/operations/_restorable_tables_operations.py @@ -133,7 +133,7 @@ async def extract_data(pipeline_response): list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore - return None, AsyncList(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): _request = prepare_request(next_link) diff --git a/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/aio/operations/_service_operations.py b/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/aio/operations/_service_operations.py index fb6b3abc5bc..a374dc53b3e 100644 --- a/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/aio/operations/_service_operations.py +++ b/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/aio/operations/_service_operations.py @@ -129,7 +129,7 @@ async def extract_data(pipeline_response): list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore - return None, AsyncList(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): _request = prepare_request(next_link) @@ -148,6 +148,66 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) + @distributed_trace_async + async def get( + self, resource_group_name: str, account_name: str, service_name: str, **kwargs: Any + ) -> _models.ServiceResource: + """Gets the status of service. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param service_name: Cosmos DB service name. Required. + :type service_name: str + :return: ServiceResource or the result of cls(response) + :rtype: ~azure.mgmt.cosmosdb.models.ServiceResource + :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.ServiceResource] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + account_name=account_name, + service_name=service_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ServiceResource", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + async def _create_initial( self, resource_group_name: str, @@ -209,10 +269,15 @@ async def _create_initial( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @@ -338,7 +403,9 @@ def get_long_running_output(pipeline_response): return deserialized if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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: @@ -354,66 +421,6 @@ def get_long_running_output(pipeline_response): self._client, raw_result, get_long_running_output, polling_method # type: ignore ) - @distributed_trace_async - async def get( - self, resource_group_name: str, account_name: str, service_name: str, **kwargs: Any - ) -> _models.ServiceResource: - """Gets the status of service. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param account_name: Cosmos DB database account name. Required. - :type account_name: str - :param service_name: Cosmos DB service name. Required. - :type service_name: str - :return: ServiceResource or the result of cls(response) - :rtype: ~azure.mgmt.cosmosdb.models.ServiceResource - :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.ServiceResource] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - account_name=account_name, - service_name=service_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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("ServiceResource", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - async def _delete_initial( self, resource_group_name: str, account_name: str, service_name: str, **kwargs: Any ) -> AsyncIterator[bytes]: @@ -460,10 +467,10 @@ async def _delete_initial( response_headers = {} if response.status_code == 202: - response_headers["azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("azure-AsyncOperation") + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") ) - response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) @@ -516,7 +523,9 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- return cls(pipeline_response, None, {}) # type: ignore if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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: diff --git a/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/aio/operations/_soft_deleted_database_accounts_operations.py b/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/aio/operations/_soft_deleted_database_accounts_operations.py new file mode 100644 index 00000000000..ae28458f19f --- /dev/null +++ b/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/aio/operations/_soft_deleted_database_accounts_operations.py @@ -0,0 +1,580 @@ +# 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._soft_deleted_database_accounts_operations import ( + build_get_request, + build_list_by_location_request, + build_list_by_resource_group_and_location_request, + build_purge_request, + build_restore_request, +) +from .._configuration import CosmosDBManagementClientConfiguration + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] +List = list + + +class SoftDeletedDatabaseAccountsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.cosmosdb.aio.CosmosDBManagementClient`'s + :attr:`soft_deleted_database_accounts` 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: CosmosDBManagementClientConfiguration = 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_location( + self, location: str, **kwargs: Any + ) -> AsyncItemPaged["_models.SoftDeletedDatabaseAccountGetResult"]: + """Lists all the soft-deleted Azure Cosmos DB database accounts available under the subscription + and in a region. This call requires + 'Microsoft.DocumentDB/locations/softDeletedDatabaseAccounts/read' permission. + + :param location: The name of the Azure region. Required. + :type location: str + :return: An iterator like instance of either SoftDeletedDatabaseAccountGetResult or the result + of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.SoftDeletedDatabaseAccountGetResult] + :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.SoftDeletedDatabaseAccountsListResult] = 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_location_request( + location=location, + 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("SoftDeletedDatabaseAccountsListResult", 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_resource_group_and_location( + self, resource_group_name: str, location: str, **kwargs: Any + ) -> AsyncItemPaged["_models.SoftDeletedDatabaseAccountGetResult"]: + """Lists all the soft-deleted Azure Cosmos DB database accounts available under the given resource + group and in a region. This call requires + 'Microsoft.DocumentDB/locations/softDeletedDatabaseAccounts/read' permission. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param location: The name of the Azure region. Required. + :type location: str + :return: An iterator like instance of either SoftDeletedDatabaseAccountGetResult or the result + of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.SoftDeletedDatabaseAccountGetResult] + :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.SoftDeletedDatabaseAccountsListResult] = 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_and_location_request( + resource_group_name=resource_group_name, + location=location, + 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("SoftDeletedDatabaseAccountsListResult", 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, location: str, account_name: str, **kwargs: Any + ) -> _models.SoftDeletedDatabaseAccountGetResult: + """Retrieves the properties of a soft-deleted Azure Cosmos DB database account by location and + accountName. This call requires + 'Microsoft.DocumentDB/locations/softDeletedDatabaseAccounts/read' permission. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param location: The name of the Azure region. Required. + :type location: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :return: SoftDeletedDatabaseAccountGetResult or the result of cls(response) + :rtype: ~azure.mgmt.cosmosdb.models.SoftDeletedDatabaseAccountGetResult + :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.SoftDeletedDatabaseAccountGetResult] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + location=location, + account_name=account_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("SoftDeletedDatabaseAccountGetResult", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + async def _purge_initial( + self, + resource_group_name: str, + location: str, + account_name: str, + soft_delete_action_kind: Optional[Union[str, _models.SoftDeleteActionKind]] = 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 = 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_purge_request( + resource_group_name=resource_group_name, + location=location, + account_name=account_name, + subscription_id=self._config.subscription_id, + soft_delete_action_kind=soft_delete_action_kind, + 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["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + 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_purge( + self, + resource_group_name: str, + location: str, + account_name: str, + soft_delete_action_kind: Optional[Union[str, _models.SoftDeleteActionKind]] = None, + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Permanently deletes (purges) a soft-deleted Azure Cosmos DB database account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param location: The name of the Azure region. Required. + :type location: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param soft_delete_action_kind: The kind of soft delete action to perform. Known values are: + "RestoreSoftDeletedResource" and "PermanentDeleteResource". Default value is None. + :type soft_delete_action_kind: str or ~azure.mgmt.cosmosdb.models.SoftDeleteActionKind + :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._purge_initial( + resource_group_name=resource_group_name, + location=location, + account_name=account_name, + soft_delete_action_kind=soft_delete_action_kind, + 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 _restore_initial( + self, + resource_group_name: str, + location: str, + account_name: str, + soft_delete_action_kind: Optional[Union[str, _models.SoftDeleteActionKind]] = 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 = 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_restore_request( + resource_group_name=resource_group_name, + location=location, + account_name=account_name, + subscription_id=self._config.subscription_id, + soft_delete_action_kind=soft_delete_action_kind, + 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["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + 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_restore( + self, + resource_group_name: str, + location: str, + account_name: str, + soft_delete_action_kind: Optional[Union[str, _models.SoftDeleteActionKind]] = None, + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Restores a soft-deleted Azure Cosmos DB database account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param location: The name of the Azure region. Required. + :type location: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param soft_delete_action_kind: The kind of soft delete action to perform. Known values are: + "RestoreSoftDeletedResource" and "PermanentDeleteResource". Default value is None. + :type soft_delete_action_kind: str or ~azure.mgmt.cosmosdb.models.SoftDeleteActionKind + :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._restore_initial( + resource_group_name=resource_group_name, + location=location, + account_name=account_name, + soft_delete_action_kind=soft_delete_action_kind, + 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/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/aio/operations/_soft_deleted_sql_containers_operations.py b/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/aio/operations/_soft_deleted_sql_containers_operations.py new file mode 100644 index 00000000000..e30e47bdadf --- /dev/null +++ b/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/aio/operations/_soft_deleted_sql_containers_operations.py @@ -0,0 +1,536 @@ +# 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._soft_deleted_sql_containers_operations import ( + build_get_request, + build_list_request, + build_purge_request, + build_restore_request, +) +from .._configuration import CosmosDBManagementClientConfiguration + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] +List = list + + +class SoftDeletedSqlContainersOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.cosmosdb.aio.CosmosDBManagementClient`'s + :attr:`soft_deleted_sql_containers` 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: CosmosDBManagementClientConfiguration = 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, location: str, account_name: str, database_name: str, **kwargs: Any + ) -> AsyncItemPaged["_models.SoftDeletedSqlContainerGetResult"]: + """Lists all the soft-deleted Azure Cosmos DB SQL containers under a soft-deleted SQL database. + This call requires + 'Microsoft.DocumentDB/locations/softDeletedDatabaseAccounts/softDeletedSqlDatabases/softDeletedSqlContainers/read' + permission. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param location: The name of the Azure region. Required. + :type location: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param database_name: Cosmos DB SQL database name. Required. + :type database_name: str + :return: An iterator like instance of either SoftDeletedSqlContainerGetResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.SoftDeletedSqlContainerGetResult] + :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.SoftDeletedSqlContainersListResult] = 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, + location=location, + account_name=account_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) + + 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("SoftDeletedSqlContainersListResult", 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, + location: str, + account_name: str, + database_name: str, + container_name: str, + **kwargs: Any + ) -> _models.SoftDeletedSqlContainerGetResult: + """Retrieves the properties of a soft-deleted Azure Cosmos DB SQL container. This call requires + 'Microsoft.DocumentDB/locations/softDeletedDatabaseAccounts/softDeletedSqlDatabases/softDeletedSqlContainers/read' + permission. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param location: The name of the Azure region. Required. + :type location: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param database_name: Cosmos DB SQL database name. Required. + :type database_name: str + :param container_name: Cosmos DB SQL container name. Required. + :type container_name: str + :return: SoftDeletedSqlContainerGetResult or the result of cls(response) + :rtype: ~azure.mgmt.cosmosdb.models.SoftDeletedSqlContainerGetResult + :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.SoftDeletedSqlContainerGetResult] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + location=location, + account_name=account_name, + database_name=database_name, + container_name=container_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("SoftDeletedSqlContainerGetResult", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + async def _purge_initial( + self, + resource_group_name: str, + location: str, + account_name: str, + database_name: str, + container_name: str, + soft_delete_action_kind: Optional[Union[str, _models.SoftDeleteActionKind]] = 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 = 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_purge_request( + resource_group_name=resource_group_name, + location=location, + account_name=account_name, + database_name=database_name, + container_name=container_name, + subscription_id=self._config.subscription_id, + soft_delete_action_kind=soft_delete_action_kind, + 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["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + 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_purge( + self, + resource_group_name: str, + location: str, + account_name: str, + database_name: str, + container_name: str, + soft_delete_action_kind: Optional[Union[str, _models.SoftDeleteActionKind]] = None, + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Permanently deletes a soft-deleted Azure Cosmos DB SQL container. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param location: The name of the Azure region. Required. + :type location: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param database_name: Cosmos DB SQL database name. Required. + :type database_name: str + :param container_name: Cosmos DB SQL container name. Required. + :type container_name: str + :param soft_delete_action_kind: The kind of soft delete action to perform. Known values are: + "RestoreSoftDeletedResource" and "PermanentDeleteResource". Default value is None. + :type soft_delete_action_kind: str or ~azure.mgmt.cosmosdb.models.SoftDeleteActionKind + :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._purge_initial( + resource_group_name=resource_group_name, + location=location, + account_name=account_name, + database_name=database_name, + container_name=container_name, + soft_delete_action_kind=soft_delete_action_kind, + 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 _restore_initial( + self, + resource_group_name: str, + location: str, + account_name: str, + database_name: str, + container_name: str, + soft_delete_action_kind: Optional[Union[str, _models.SoftDeleteActionKind]] = 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 = 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_restore_request( + resource_group_name=resource_group_name, + location=location, + account_name=account_name, + database_name=database_name, + container_name=container_name, + subscription_id=self._config.subscription_id, + soft_delete_action_kind=soft_delete_action_kind, + 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["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + 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_restore( + self, + resource_group_name: str, + location: str, + account_name: str, + database_name: str, + container_name: str, + soft_delete_action_kind: Optional[Union[str, _models.SoftDeleteActionKind]] = None, + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Restores a soft-deleted Azure Cosmos DB SQL container to active state. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param location: The name of the Azure region. Required. + :type location: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param database_name: Cosmos DB SQL database name. Required. + :type database_name: str + :param container_name: Cosmos DB SQL container name. Required. + :type container_name: str + :param soft_delete_action_kind: The kind of soft delete action to perform. Known values are: + "RestoreSoftDeletedResource" and "PermanentDeleteResource". Default value is None. + :type soft_delete_action_kind: str or ~azure.mgmt.cosmosdb.models.SoftDeleteActionKind + :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._restore_initial( + resource_group_name=resource_group_name, + location=location, + account_name=account_name, + database_name=database_name, + container_name=container_name, + soft_delete_action_kind=soft_delete_action_kind, + 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/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/aio/operations/_soft_deleted_sql_databases_operations.py b/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/aio/operations/_soft_deleted_sql_databases_operations.py new file mode 100644 index 00000000000..01c0f744ca4 --- /dev/null +++ b/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/aio/operations/_soft_deleted_sql_databases_operations.py @@ -0,0 +1,511 @@ +# 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._soft_deleted_sql_databases_operations import ( + build_get_request, + build_list_request, + build_purge_request, + build_restore_request, +) +from .._configuration import CosmosDBManagementClientConfiguration + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] +List = list + + +class SoftDeletedSqlDatabasesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.cosmosdb.aio.CosmosDBManagementClient`'s + :attr:`soft_deleted_sql_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: CosmosDBManagementClientConfiguration = 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, location: str, account_name: str, **kwargs: Any + ) -> AsyncItemPaged["_models.SoftDeletedSqlDatabaseGetResult"]: + """Lists all the soft-deleted Azure Cosmos DB SQL databases under a soft-deleted database account. + This call requires + 'Microsoft.DocumentDB/locations/softDeletedDatabaseAccounts/softDeletedSqlDatabases/read' + permission. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param location: The name of the Azure region. Required. + :type location: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :return: An iterator like instance of either SoftDeletedSqlDatabaseGetResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.SoftDeletedSqlDatabaseGetResult] + :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.SoftDeletedSqlDatabasesListResult] = 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, + location=location, + account_name=account_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("SoftDeletedSqlDatabasesListResult", 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, location: str, account_name: str, database_name: str, **kwargs: Any + ) -> _models.SoftDeletedSqlDatabaseGetResult: + """Retrieves the properties of a soft-deleted Azure Cosmos DB SQL database. This call requires + 'Microsoft.DocumentDB/locations/softDeletedDatabaseAccounts/softDeletedSqlDatabases/read' + permission. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param location: The name of the Azure region. Required. + :type location: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param database_name: Cosmos DB SQL database name. Required. + :type database_name: str + :return: SoftDeletedSqlDatabaseGetResult or the result of cls(response) + :rtype: ~azure.mgmt.cosmosdb.models.SoftDeletedSqlDatabaseGetResult + :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.SoftDeletedSqlDatabaseGetResult] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + location=location, + account_name=account_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("SoftDeletedSqlDatabaseGetResult", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + async def _purge_initial( + self, + resource_group_name: str, + location: str, + account_name: str, + database_name: str, + soft_delete_action_kind: Optional[Union[str, _models.SoftDeleteActionKind]] = 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 = 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_purge_request( + resource_group_name=resource_group_name, + location=location, + account_name=account_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + soft_delete_action_kind=soft_delete_action_kind, + 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["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + 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_purge( + self, + resource_group_name: str, + location: str, + account_name: str, + database_name: str, + soft_delete_action_kind: Optional[Union[str, _models.SoftDeleteActionKind]] = None, + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Permanently deletes a soft-deleted Azure Cosmos DB SQL database. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param location: The name of the Azure region. Required. + :type location: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param database_name: Cosmos DB SQL database name. Required. + :type database_name: str + :param soft_delete_action_kind: The kind of soft delete action to perform. Known values are: + "RestoreSoftDeletedResource" and "PermanentDeleteResource". Default value is None. + :type soft_delete_action_kind: str or ~azure.mgmt.cosmosdb.models.SoftDeleteActionKind + :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._purge_initial( + resource_group_name=resource_group_name, + location=location, + account_name=account_name, + database_name=database_name, + soft_delete_action_kind=soft_delete_action_kind, + 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 _restore_initial( + self, + resource_group_name: str, + location: str, + account_name: str, + database_name: str, + soft_delete_action_kind: Optional[Union[str, _models.SoftDeleteActionKind]] = 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 = 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_restore_request( + resource_group_name=resource_group_name, + location=location, + account_name=account_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + soft_delete_action_kind=soft_delete_action_kind, + 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["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + 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_restore( + self, + resource_group_name: str, + location: str, + account_name: str, + database_name: str, + soft_delete_action_kind: Optional[Union[str, _models.SoftDeleteActionKind]] = None, + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Restores a soft-deleted Azure Cosmos DB SQL database. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param location: The name of the Azure region. Required. + :type location: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param database_name: Cosmos DB SQL database name. Required. + :type database_name: str + :param soft_delete_action_kind: The kind of soft delete action to perform. Known values are: + "RestoreSoftDeletedResource" and "PermanentDeleteResource". Default value is None. + :type soft_delete_action_kind: str or ~azure.mgmt.cosmosdb.models.SoftDeleteActionKind + :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._restore_initial( + resource_group_name=resource_group_name, + location=location, + account_name=account_name, + database_name=database_name, + soft_delete_action_kind=soft_delete_action_kind, + 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/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/aio/operations/_sql_resources_operations.py b/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/aio/operations/_sql_resources_operations.py index 90641f9c344..a98a972d6b0 100644 --- a/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/aio/operations/_sql_resources_operations.py +++ b/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/aio/operations/_sql_resources_operations.py @@ -174,7 +174,7 @@ async def extract_data(pipeline_response): list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore - return None, AsyncList(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): _request = prepare_request(next_link) @@ -187,7 +187,11 @@ 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response @@ -245,7 +249,11 @@ async def get_sql_database( if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("SqlDatabaseGetResults", pipeline_response.http_response) @@ -313,14 +321,19 @@ async def _create_update_sql_database_initial( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + 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["azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("azure-AsyncOperation") + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") ) - response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) @@ -453,7 +466,9 @@ def get_long_running_output(pipeline_response): return deserialized if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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: @@ -511,14 +526,18 @@ async def _delete_sql_database_initial( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + 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["azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("azure-AsyncOperation") + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") ) - response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) @@ -571,7 +590,9 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- return cls(pipeline_response, None, {}) # type: ignore if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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: @@ -585,12 +606,11 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- ) return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - @distributed_trace_async - async def get_sql_database_throughput( + @distributed_trace + def list_client_encryption_keys( self, resource_group_name: str, account_name: str, database_name: str, **kwargs: Any - ) -> _models.ThroughputSettingsGetResults: - """Gets the RUs per second of the SQL database under an existing Azure Cosmos DB database account - with the provided name. + ) -> AsyncItemPaged["_models.ClientEncryptionKeyGetResults"]: + """Lists the ClientEncryptionKeys under an existing Azure Cosmos DB SQL database. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -599,8 +619,107 @@ async def get_sql_database_throughput( :type account_name: str :param database_name: Cosmos DB database name. Required. :type database_name: str - :return: ThroughputSettingsGetResults or the result of cls(response) - :rtype: ~azure.mgmt.cosmosdb.models.ThroughputSettingsGetResults + :return: An iterator like instance of either ClientEncryptionKeyGetResults or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.ClientEncryptionKeyGetResults] + :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.ClientEncryptionKeysListResult] = 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_client_encryption_keys_request( + resource_group_name=resource_group_name, + account_name=account_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) + + 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("ClientEncryptionKeysListResult", 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_client_encryption_key( + self, + resource_group_name: str, + account_name: str, + database_name: str, + client_encryption_key_name: str, + **kwargs: Any + ) -> _models.ClientEncryptionKeyGetResults: + """Gets the ClientEncryptionKey under an existing Azure Cosmos DB SQL database. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param database_name: Cosmos DB database name. Required. + :type database_name: str + :param client_encryption_key_name: Cosmos DB ClientEncryptionKey name. Required. + :type client_encryption_key_name: str + :return: ClientEncryptionKeyGetResults or the result of cls(response) + :rtype: ~azure.mgmt.cosmosdb.models.ClientEncryptionKeyGetResults :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -615,12 +734,13 @@ async def get_sql_database_throughput( _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.ThroughputSettingsGetResults] = kwargs.pop("cls", None) + cls: ClsType[_models.ClientEncryptionKeyGetResults] = kwargs.pop("cls", None) - _request = build_get_sql_database_throughput_request( + _request = build_get_client_encryption_key_request( resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, + client_encryption_key_name=client_encryption_key_name, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, @@ -637,21 +757,28 @@ async def get_sql_database_throughput( if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("ThroughputSettingsGetResults", pipeline_response.http_response) + deserialized = self._deserialize("ClientEncryptionKeyGetResults", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - async def _update_sql_database_throughput_initial( + async def _create_update_client_encryption_key_initial( # pylint: disable=name-too-long self, resource_group_name: str, account_name: str, database_name: str, - update_throughput_parameters: Union[_models.ThroughputSettingsUpdateParameters, IO[bytes]], + client_encryption_key_name: str, + create_update_client_encryption_key_parameters: Union[ + _models.ClientEncryptionKeyCreateUpdateParameters, IO[bytes] + ], **kwargs: Any ) -> AsyncIterator[bytes]: error_map: MutableMapping = { @@ -672,15 +799,18 @@ async def _update_sql_database_throughput_initial( content_type = content_type or "application/json" _json = None _content = None - if isinstance(update_throughput_parameters, (IOBase, bytes)): - _content = update_throughput_parameters + if isinstance(create_update_client_encryption_key_parameters, (IOBase, bytes)): + _content = create_update_client_encryption_key_parameters else: - _json = self._serialize.body(update_throughput_parameters, "ThroughputSettingsUpdateParameters") + _json = self._serialize.body( + create_update_client_encryption_key_parameters, "ClientEncryptionKeyCreateUpdateParameters" + ) - _request = build_update_sql_database_throughput_request( + _request = build_create_update_client_encryption_key_request( resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, + client_encryption_key_name=client_encryption_key_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, @@ -705,14 +835,19 @@ async def _update_sql_database_throughput_initial( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + 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["azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("azure-AsyncOperation") + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") ) - response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) @@ -722,17 +857,19 @@ async def _update_sql_database_throughput_initial( return deserialized # type: ignore @overload - async def begin_update_sql_database_throughput( + async def begin_create_update_client_encryption_key( # pylint: disable=name-too-long self, resource_group_name: str, account_name: str, database_name: str, - update_throughput_parameters: _models.ThroughputSettingsUpdateParameters, + client_encryption_key_name: str, + create_update_client_encryption_key_parameters: _models.ClientEncryptionKeyCreateUpdateParameters, *, content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller[_models.ThroughputSettingsGetResults]: - """Update RUs per second of an Azure Cosmos DB SQL database. + ) -> AsyncLROPoller[_models.ClientEncryptionKeyGetResults]: + """Create or update a ClientEncryptionKey. This API is meant to be invoked via tools such as the + Azure Powershell (instead of directly). :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -741,32 +878,36 @@ async def begin_update_sql_database_throughput( :type account_name: str :param database_name: Cosmos DB database name. Required. :type database_name: str - :param update_throughput_parameters: The parameters to provide for the RUs per second of the - current SQL database. Required. - :type update_throughput_parameters: - ~azure.mgmt.cosmosdb.models.ThroughputSettingsUpdateParameters + :param client_encryption_key_name: Cosmos DB ClientEncryptionKey name. Required. + :type client_encryption_key_name: str + :param create_update_client_encryption_key_parameters: The parameters to provide for the client + encryption key. Required. + :type create_update_client_encryption_key_parameters: + ~azure.mgmt.cosmosdb.models.ClientEncryptionKeyCreateUpdateParameters :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 ThroughputSettingsGetResults or the + :return: An instance of AsyncLROPoller that returns either ClientEncryptionKeyGetResults or the result of cls(response) :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.ThroughputSettingsGetResults] + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.ClientEncryptionKeyGetResults] :raises ~azure.core.exceptions.HttpResponseError: """ @overload - async def begin_update_sql_database_throughput( + async def begin_create_update_client_encryption_key( # pylint: disable=name-too-long self, resource_group_name: str, account_name: str, database_name: str, - update_throughput_parameters: IO[bytes], + client_encryption_key_name: str, + create_update_client_encryption_key_parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller[_models.ThroughputSettingsGetResults]: - """Update RUs per second of an Azure Cosmos DB SQL database. + ) -> AsyncLROPoller[_models.ClientEncryptionKeyGetResults]: + """Create or update a ClientEncryptionKey. This API is meant to be invoked via tools such as the + Azure Powershell (instead of directly). :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -775,29 +916,35 @@ async def begin_update_sql_database_throughput( :type account_name: str :param database_name: Cosmos DB database name. Required. :type database_name: str - :param update_throughput_parameters: The parameters to provide for the RUs per second of the - current SQL database. Required. - :type update_throughput_parameters: IO[bytes] + :param client_encryption_key_name: Cosmos DB ClientEncryptionKey name. Required. + :type client_encryption_key_name: str + :param create_update_client_encryption_key_parameters: The parameters to provide for the client + encryption key. Required. + :type create_update_client_encryption_key_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 ThroughputSettingsGetResults or the + :return: An instance of AsyncLROPoller that returns either ClientEncryptionKeyGetResults or the result of cls(response) :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.ThroughputSettingsGetResults] + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.ClientEncryptionKeyGetResults] :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace_async - async def begin_update_sql_database_throughput( + async def begin_create_update_client_encryption_key( # pylint: disable=name-too-long self, resource_group_name: str, account_name: str, database_name: str, - update_throughput_parameters: Union[_models.ThroughputSettingsUpdateParameters, IO[bytes]], + client_encryption_key_name: str, + create_update_client_encryption_key_parameters: Union[ + _models.ClientEncryptionKeyCreateUpdateParameters, IO[bytes] + ], **kwargs: Any - ) -> AsyncLROPoller[_models.ThroughputSettingsGetResults]: - """Update RUs per second of an Azure Cosmos DB SQL database. + ) -> AsyncLROPoller[_models.ClientEncryptionKeyGetResults]: + """Create or update a ClientEncryptionKey. This API is meant to be invoked via tools such as the + Azure Powershell (instead of directly). :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -806,15 +953,17 @@ async def begin_update_sql_database_throughput( :type account_name: str :param database_name: Cosmos DB database name. Required. :type database_name: str - :param update_throughput_parameters: The parameters to provide for the RUs per second of the - current SQL database. Is either a ThroughputSettingsUpdateParameters type or a IO[bytes] type. + :param client_encryption_key_name: Cosmos DB ClientEncryptionKey name. Required. + :type client_encryption_key_name: str + :param create_update_client_encryption_key_parameters: The parameters to provide for the client + encryption key. Is either a ClientEncryptionKeyCreateUpdateParameters type or a IO[bytes] type. Required. - :type update_throughput_parameters: - ~azure.mgmt.cosmosdb.models.ThroughputSettingsUpdateParameters or IO[bytes] - :return: An instance of AsyncLROPoller that returns either ThroughputSettingsGetResults or the + :type create_update_client_encryption_key_parameters: + ~azure.mgmt.cosmosdb.models.ClientEncryptionKeyCreateUpdateParameters or IO[bytes] + :return: An instance of AsyncLROPoller that returns either ClientEncryptionKeyGetResults or the result of cls(response) :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.ThroughputSettingsGetResults] + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.ClientEncryptionKeyGetResults] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -822,16 +971,17 @@ async def begin_update_sql_database_throughput( 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.ThroughputSettingsGetResults] = kwargs.pop("cls", None) + cls: ClsType[_models.ClientEncryptionKeyGetResults] = 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_sql_database_throughput_initial( + raw_result = await self._create_update_client_encryption_key_initial( resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, - update_throughput_parameters=update_throughput_parameters, + client_encryption_key_name=client_encryption_key_name, + create_update_client_encryption_key_parameters=create_update_client_encryption_key_parameters, api_version=api_version, content_type=content_type, cls=lambda x, y, z: x, @@ -843,673 +993,35 @@ async def begin_update_sql_database_throughput( kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ThroughputSettingsGetResults", pipeline_response.http_response) + deserialized = self._deserialize("ClientEncryptionKeyGetResults", 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, **kwargs)) + 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.ThroughputSettingsGetResults].from_continuation_token( + return AsyncLROPoller[_models.ClientEncryptionKeyGetResults].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller[_models.ThroughputSettingsGetResults]( + return AsyncLROPoller[_models.ClientEncryptionKeyGetResults]( self._client, raw_result, get_long_running_output, polling_method # type: ignore ) - async def _migrate_sql_database_to_autoscale_initial( # pylint: disable=name-too-long + @distributed_trace + def list_sql_containers( self, resource_group_name: str, account_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_migrate_sql_database_to_autoscale_request( - resource_group_name=resource_group_name, - account_name=account_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 [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) - raise HttpResponseError(response=response, 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")) - - 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_migrate_sql_database_to_autoscale( - self, resource_group_name: str, account_name: str, database_name: str, **kwargs: Any - ) -> AsyncLROPoller[_models.ThroughputSettingsGetResults]: - """Migrate an Azure Cosmos DB SQL database from manual throughput to autoscale. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param account_name: Cosmos DB database account name. Required. - :type account_name: str - :param database_name: Cosmos DB database name. Required. - :type database_name: str - :return: An instance of AsyncLROPoller that returns either ThroughputSettingsGetResults or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.ThroughputSettingsGetResults] - :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.ThroughputSettingsGetResults] = 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_sql_database_to_autoscale_initial( - resource_group_name=resource_group_name, - account_name=account_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): - deserialized = self._deserialize("ThroughputSettingsGetResults", 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, **kwargs)) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[_models.ThroughputSettingsGetResults].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.ThroughputSettingsGetResults]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _migrate_sql_database_to_manual_throughput_initial( # pylint: disable=name-too-long - self, resource_group_name: str, account_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_migrate_sql_database_to_manual_throughput_request( - resource_group_name=resource_group_name, - account_name=account_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 [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) - raise HttpResponseError(response=response, 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")) - - 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_migrate_sql_database_to_manual_throughput( # pylint: disable=name-too-long - self, resource_group_name: str, account_name: str, database_name: str, **kwargs: Any - ) -> AsyncLROPoller[_models.ThroughputSettingsGetResults]: - """Migrate an Azure Cosmos DB SQL database from autoscale to manual throughput. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param account_name: Cosmos DB database account name. Required. - :type account_name: str - :param database_name: Cosmos DB database name. Required. - :type database_name: str - :return: An instance of AsyncLROPoller that returns either ThroughputSettingsGetResults or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.ThroughputSettingsGetResults] - :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.ThroughputSettingsGetResults] = 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_sql_database_to_manual_throughput_initial( - resource_group_name=resource_group_name, - account_name=account_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): - deserialized = self._deserialize("ThroughputSettingsGetResults", 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, **kwargs)) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[_models.ThroughputSettingsGetResults].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.ThroughputSettingsGetResults]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - @distributed_trace - def list_client_encryption_keys( - self, resource_group_name: str, account_name: str, database_name: str, **kwargs: Any - ) -> AsyncItemPaged["_models.ClientEncryptionKeyGetResults"]: - """Lists the ClientEncryptionKeys under an existing Azure Cosmos DB SQL database. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param account_name: Cosmos DB database account name. Required. - :type account_name: str - :param database_name: Cosmos DB database name. Required. - :type database_name: str - :return: An iterator like instance of either ClientEncryptionKeyGetResults or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.ClientEncryptionKeyGetResults] - :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.ClientEncryptionKeysListResult] = 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_client_encryption_keys_request( - resource_group_name=resource_group_name, - account_name=account_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) - - 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("ClientEncryptionKeysListResult", 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace_async - async def get_client_encryption_key( - self, - resource_group_name: str, - account_name: str, - database_name: str, - client_encryption_key_name: str, - **kwargs: Any - ) -> _models.ClientEncryptionKeyGetResults: - """Gets the ClientEncryptionKey under an existing Azure Cosmos DB SQL database. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param account_name: Cosmos DB database account name. Required. - :type account_name: str - :param database_name: Cosmos DB database name. Required. - :type database_name: str - :param client_encryption_key_name: Cosmos DB ClientEncryptionKey name. Required. - :type client_encryption_key_name: str - :return: ClientEncryptionKeyGetResults or the result of cls(response) - :rtype: ~azure.mgmt.cosmosdb.models.ClientEncryptionKeyGetResults - :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.ClientEncryptionKeyGetResults] = kwargs.pop("cls", None) - - _request = build_get_client_encryption_key_request( - resource_group_name=resource_group_name, - account_name=account_name, - database_name=database_name, - client_encryption_key_name=client_encryption_key_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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("ClientEncryptionKeyGetResults", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - async def _create_update_client_encryption_key_initial( # pylint: disable=name-too-long - self, - resource_group_name: str, - account_name: str, - database_name: str, - client_encryption_key_name: str, - create_update_client_encryption_key_parameters: Union[ - _models.ClientEncryptionKeyCreateUpdateParameters, 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(create_update_client_encryption_key_parameters, (IOBase, bytes)): - _content = create_update_client_encryption_key_parameters - else: - _json = self._serialize.body( - create_update_client_encryption_key_parameters, "ClientEncryptionKeyCreateUpdateParameters" - ) - - _request = build_create_update_client_encryption_key_request( - resource_group_name=resource_group_name, - account_name=account_name, - database_name=database_name, - client_encryption_key_name=client_encryption_key_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) - raise HttpResponseError(response=response, 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")) - - 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_update_client_encryption_key( # pylint: disable=name-too-long - self, - resource_group_name: str, - account_name: str, - database_name: str, - client_encryption_key_name: str, - create_update_client_encryption_key_parameters: _models.ClientEncryptionKeyCreateUpdateParameters, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.ClientEncryptionKeyGetResults]: - """Create or update a ClientEncryptionKey. This API is meant to be invoked via tools such as the - Azure Powershell (instead of directly). - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param account_name: Cosmos DB database account name. Required. - :type account_name: str - :param database_name: Cosmos DB database name. Required. - :type database_name: str - :param client_encryption_key_name: Cosmos DB ClientEncryptionKey name. Required. - :type client_encryption_key_name: str - :param create_update_client_encryption_key_parameters: The parameters to provide for the client - encryption key. Required. - :type create_update_client_encryption_key_parameters: - ~azure.mgmt.cosmosdb.models.ClientEncryptionKeyCreateUpdateParameters - :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 ClientEncryptionKeyGetResults or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.ClientEncryptionKeyGetResults] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_create_update_client_encryption_key( # pylint: disable=name-too-long - self, - resource_group_name: str, - account_name: str, - database_name: str, - client_encryption_key_name: str, - create_update_client_encryption_key_parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.ClientEncryptionKeyGetResults]: - """Create or update a ClientEncryptionKey. This API is meant to be invoked via tools such as the - Azure Powershell (instead of directly). - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param account_name: Cosmos DB database account name. Required. - :type account_name: str - :param database_name: Cosmos DB database name. Required. - :type database_name: str - :param client_encryption_key_name: Cosmos DB ClientEncryptionKey name. Required. - :type client_encryption_key_name: str - :param create_update_client_encryption_key_parameters: The parameters to provide for the client - encryption key. Required. - :type create_update_client_encryption_key_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 ClientEncryptionKeyGetResults or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.ClientEncryptionKeyGetResults] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_create_update_client_encryption_key( # pylint: disable=name-too-long - self, - resource_group_name: str, - account_name: str, - database_name: str, - client_encryption_key_name: str, - create_update_client_encryption_key_parameters: Union[ - _models.ClientEncryptionKeyCreateUpdateParameters, IO[bytes] - ], - **kwargs: Any - ) -> AsyncLROPoller[_models.ClientEncryptionKeyGetResults]: - """Create or update a ClientEncryptionKey. This API is meant to be invoked via tools such as the - Azure Powershell (instead of directly). - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param account_name: Cosmos DB database account name. Required. - :type account_name: str - :param database_name: Cosmos DB database name. Required. - :type database_name: str - :param client_encryption_key_name: Cosmos DB ClientEncryptionKey name. Required. - :type client_encryption_key_name: str - :param create_update_client_encryption_key_parameters: The parameters to provide for the client - encryption key. Is either a ClientEncryptionKeyCreateUpdateParameters type or a IO[bytes] type. - Required. - :type create_update_client_encryption_key_parameters: - ~azure.mgmt.cosmosdb.models.ClientEncryptionKeyCreateUpdateParameters or IO[bytes] - :return: An instance of AsyncLROPoller that returns either ClientEncryptionKeyGetResults or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.ClientEncryptionKeyGetResults] - :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.ClientEncryptionKeyGetResults] = 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_update_client_encryption_key_initial( - resource_group_name=resource_group_name, - account_name=account_name, - database_name=database_name, - client_encryption_key_name=client_encryption_key_name, - create_update_client_encryption_key_parameters=create_update_client_encryption_key_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("ClientEncryptionKeyGetResults", 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, **kwargs)) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[_models.ClientEncryptionKeyGetResults].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.ClientEncryptionKeyGetResults]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - @distributed_trace - def list_sql_containers( - self, resource_group_name: str, account_name: str, database_name: str, **kwargs: Any - ) -> AsyncItemPaged["_models.SqlContainerGetResults"]: - """Lists the SQL container under an existing Azure Cosmos DB database account. + ) -> AsyncItemPaged["_models.SqlContainerGetResults"]: + """Lists the SQL container under an existing Azure Cosmos DB database account. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -1574,7 +1086,7 @@ async def extract_data(pipeline_response): list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore - return None, AsyncList(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): _request = prepare_request(next_link) @@ -1587,7 +1099,11 @@ 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response @@ -1647,7 +1163,11 @@ async def get_sql_container( if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("SqlContainerGetResults", pipeline_response.http_response) @@ -1717,14 +1237,19 @@ async def _create_update_sql_container_initial( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + 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["azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("azure-AsyncOperation") + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") ) - response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) @@ -1867,7 +1392,9 @@ def get_long_running_output(pipeline_response): return deserialized if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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: @@ -1926,14 +1453,18 @@ async def _delete_sql_container_initial( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + 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["azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("azure-AsyncOperation") + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") ) - response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) @@ -1989,7 +1520,9 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- return cls(pipeline_response, None, {}) # type: ignore if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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: @@ -2003,11 +1536,12 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- ) return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - async def _sql_database_partition_merge_initial( + async def _list_sql_container_partition_merge_initial( # pylint: disable=name-too-long self, resource_group_name: str, account_name: str, database_name: str, + container_name: str, merge_parameters: Union[_models.MergeParameters, IO[bytes]], **kwargs: Any ) -> AsyncIterator[bytes]: @@ -2034,10 +1568,11 @@ async def _sql_database_partition_merge_initial( else: _json = self._serialize.body(merge_parameters, "MergeParameters") - _request = build_sql_database_partition_merge_request( + _request = build_list_sql_container_partition_merge_request( resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, + container_name=container_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, @@ -2066,10 +1601,10 @@ async def _sql_database_partition_merge_initial( response_headers = {} if response.status_code == 202: - response_headers["azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("azure-AsyncOperation") + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") ) - response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) @@ -2079,17 +1614,18 @@ async def _sql_database_partition_merge_initial( return deserialized # type: ignore @overload - async def begin_sql_database_partition_merge( + async def begin_list_sql_container_partition_merge( self, resource_group_name: str, account_name: str, database_name: str, + container_name: str, merge_parameters: _models.MergeParameters, *, content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[_models.PhysicalPartitionStorageInfoCollection]: - """Merges the partitions of a SQL database. + """Merges the partitions of a SQL Container. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -2098,6 +1634,8 @@ async def begin_sql_database_partition_merge( :type account_name: str :param database_name: Cosmos DB database name. Required. :type database_name: str + :param container_name: Cosmos DB container name. Required. + :type container_name: str :param merge_parameters: The parameters for the merge operation. Required. :type merge_parameters: ~azure.mgmt.cosmosdb.models.MergeParameters :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. @@ -2111,17 +1649,18 @@ async def begin_sql_database_partition_merge( """ @overload - async def begin_sql_database_partition_merge( + async def begin_list_sql_container_partition_merge( self, resource_group_name: str, account_name: str, database_name: str, + container_name: str, merge_parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[_models.PhysicalPartitionStorageInfoCollection]: - """Merges the partitions of a SQL database. + """Merges the partitions of a SQL Container. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -2130,6 +1669,8 @@ async def begin_sql_database_partition_merge( :type account_name: str :param database_name: Cosmos DB database name. Required. :type database_name: str + :param container_name: Cosmos DB container name. Required. + :type container_name: str :param merge_parameters: The parameters for the merge operation. Required. :type merge_parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. @@ -2143,15 +1684,16 @@ async def begin_sql_database_partition_merge( """ @distributed_trace_async - async def begin_sql_database_partition_merge( + async def begin_list_sql_container_partition_merge( self, resource_group_name: str, account_name: str, database_name: str, + container_name: str, merge_parameters: Union[_models.MergeParameters, IO[bytes]], **kwargs: Any ) -> AsyncLROPoller[_models.PhysicalPartitionStorageInfoCollection]: - """Merges the partitions of a SQL database. + """Merges the partitions of a SQL Container. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -2160,6 +1702,8 @@ async def begin_sql_database_partition_merge( :type account_name: str :param database_name: Cosmos DB database name. Required. :type database_name: str + :param container_name: Cosmos DB container name. Required. + :type container_name: str :param merge_parameters: The parameters for the merge operation. Is either a MergeParameters type or a IO[bytes] type. Required. :type merge_parameters: ~azure.mgmt.cosmosdb.models.MergeParameters or IO[bytes] @@ -2179,10 +1723,11 @@ async def begin_sql_database_partition_merge( 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._sql_database_partition_merge_initial( + raw_result = await self._list_sql_container_partition_merge_initial( resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, + container_name=container_name, merge_parameters=merge_parameters, api_version=api_version, content_type=content_type, @@ -2219,13 +1764,13 @@ def get_long_running_output(pipeline_response): self._client, raw_result, get_long_running_output, polling_method # type: ignore ) - async def _list_sql_container_partition_merge_initial( # pylint: disable=name-too-long + async def _retrieve_continuous_backup_information_initial( # pylint: disable=name-too-long self, resource_group_name: str, account_name: str, database_name: str, container_name: str, - merge_parameters: Union[_models.MergeParameters, IO[bytes]], + location: Union[_models.ContinuousBackupRestoreLocation, IO[bytes]], **kwargs: Any ) -> AsyncIterator[bytes]: error_map: MutableMapping = { @@ -2246,12 +1791,12 @@ async def _list_sql_container_partition_merge_initial( # pylint: disable=name-t content_type = content_type or "application/json" _json = None _content = None - if isinstance(merge_parameters, (IOBase, bytes)): - _content = merge_parameters + if isinstance(location, (IOBase, bytes)): + _content = location else: - _json = self._serialize.body(merge_parameters, "MergeParameters") + _json = self._serialize.body(location, "ContinuousBackupRestoreLocation") - _request = build_list_sql_container_partition_merge_request( + _request = build_retrieve_continuous_backup_information_request( resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, @@ -2284,10 +1829,8 @@ async def _list_sql_container_partition_merge_initial( # pylint: disable=name-t 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["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) @@ -2297,18 +1840,18 @@ async def _list_sql_container_partition_merge_initial( # pylint: disable=name-t return deserialized # type: ignore @overload - async def begin_list_sql_container_partition_merge( + async def begin_retrieve_continuous_backup_information( # pylint: disable=name-too-long self, resource_group_name: str, account_name: str, database_name: str, container_name: str, - merge_parameters: _models.MergeParameters, + location: _models.ContinuousBackupRestoreLocation, *, content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller[_models.PhysicalPartitionStorageInfoCollection]: - """Merges the partitions of a SQL Container. + ) -> AsyncLROPoller[_models.BackupInformation]: + """Retrieves continuous backup information for a container resource. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -2319,31 +1862,30 @@ async def begin_list_sql_container_partition_merge( :type database_name: str :param container_name: Cosmos DB container name. Required. :type container_name: str - :param merge_parameters: The parameters for the merge operation. Required. - :type merge_parameters: ~azure.mgmt.cosmosdb.models.MergeParameters + :param location: The name of the continuous backup restore location. Required. + :type location: ~azure.mgmt.cosmosdb.models.ContinuousBackupRestoreLocation :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 - PhysicalPartitionStorageInfoCollection or the result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.PhysicalPartitionStorageInfoCollection] + :return: An instance of AsyncLROPoller that returns either BackupInformation or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.BackupInformation] :raises ~azure.core.exceptions.HttpResponseError: """ @overload - async def begin_list_sql_container_partition_merge( + async def begin_retrieve_continuous_backup_information( # pylint: disable=name-too-long self, resource_group_name: str, account_name: str, database_name: str, container_name: str, - merge_parameters: IO[bytes], + location: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller[_models.PhysicalPartitionStorageInfoCollection]: - """Merges the partitions of a SQL Container. + ) -> AsyncLROPoller[_models.BackupInformation]: + """Retrieves continuous backup information for a container resource. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -2354,29 +1896,28 @@ async def begin_list_sql_container_partition_merge( :type database_name: str :param container_name: Cosmos DB container name. Required. :type container_name: str - :param merge_parameters: The parameters for the merge operation. Required. - :type merge_parameters: IO[bytes] + :param location: The name of the continuous backup restore location. Required. + :type location: 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 - PhysicalPartitionStorageInfoCollection or the result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.PhysicalPartitionStorageInfoCollection] + :return: An instance of AsyncLROPoller that returns either BackupInformation or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.BackupInformation] :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace_async - async def begin_list_sql_container_partition_merge( + async def begin_retrieve_continuous_backup_information( # pylint: disable=name-too-long self, resource_group_name: str, account_name: str, database_name: str, container_name: str, - merge_parameters: Union[_models.MergeParameters, IO[bytes]], + location: Union[_models.ContinuousBackupRestoreLocation, IO[bytes]], **kwargs: Any - ) -> AsyncLROPoller[_models.PhysicalPartitionStorageInfoCollection]: - """Merges the partitions of a SQL Container. + ) -> AsyncLROPoller[_models.BackupInformation]: + """Retrieves continuous backup information for a container resource. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -2387,13 +1928,12 @@ async def begin_list_sql_container_partition_merge( :type database_name: str :param container_name: Cosmos DB container name. Required. :type container_name: str - :param merge_parameters: The parameters for the merge operation. Is either a MergeParameters - type or a IO[bytes] type. Required. - :type merge_parameters: ~azure.mgmt.cosmosdb.models.MergeParameters or IO[bytes] - :return: An instance of AsyncLROPoller that returns either - PhysicalPartitionStorageInfoCollection or the result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.PhysicalPartitionStorageInfoCollection] + :param location: The name of the continuous backup restore location. Is either a + ContinuousBackupRestoreLocation type or a IO[bytes] type. Required. + :type location: ~azure.mgmt.cosmosdb.models.ContinuousBackupRestoreLocation or IO[bytes] + :return: An instance of AsyncLROPoller that returns either BackupInformation or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.BackupInformation] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -2401,17 +1941,17 @@ async def begin_list_sql_container_partition_merge( 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.PhysicalPartitionStorageInfoCollection] = kwargs.pop("cls", None) + cls: ClsType[_models.BackupInformation] = 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._list_sql_container_partition_merge_initial( + raw_result = await self._retrieve_continuous_backup_information_initial( resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, container_name=container_name, - merge_parameters=merge_parameters, + location=location, api_version=api_version, content_type=content_type, cls=lambda x, y, z: x, @@ -2423,7 +1963,7 @@ async def begin_list_sql_container_partition_merge( kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("PhysicalPartitionStorageInfoCollection", pipeline_response.http_response) + deserialized = self._deserialize("BackupInformation", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized @@ -2437,22 +1977,21 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller[_models.PhysicalPartitionStorageInfoCollection].from_continuation_token( + return AsyncLROPoller[_models.BackupInformation].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller[_models.PhysicalPartitionStorageInfoCollection]( + return AsyncLROPoller[_models.BackupInformation]( self._client, raw_result, get_long_running_output, polling_method # type: ignore ) - @distributed_trace_async - async def get_sql_container_throughput( + @distributed_trace + def list_sql_stored_procedures( self, resource_group_name: str, account_name: str, database_name: str, container_name: str, **kwargs: Any - ) -> _models.ThroughputSettingsGetResults: - """Gets the RUs per second of the SQL container under an existing Azure Cosmos DB database - account. + ) -> AsyncItemPaged["_models.SqlStoredProcedureGetResults"]: + """Lists the SQL storedProcedure under an existing Azure Cosmos DB database account. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -2463,8 +2002,107 @@ async def get_sql_container_throughput( :type database_name: str :param container_name: Cosmos DB container name. Required. :type container_name: str - :return: ThroughputSettingsGetResults or the result of cls(response) - :rtype: ~azure.mgmt.cosmosdb.models.ThroughputSettingsGetResults + :return: An iterator like instance of either SqlStoredProcedureGetResults or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.SqlStoredProcedureGetResults] + :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.SqlStoredProcedureListResult] = 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_sql_stored_procedures_request( + resource_group_name=resource_group_name, + account_name=account_name, + database_name=database_name, + container_name=container_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("SqlStoredProcedureListResult", 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace_async + async def get_sql_stored_procedure( + self, + resource_group_name: str, + account_name: str, + database_name: str, + container_name: str, + stored_procedure_name: str, + **kwargs: Any + ) -> _models.SqlStoredProcedureGetResults: + """Gets the SQL storedProcedure under an existing Azure Cosmos DB database account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param database_name: Cosmos DB database name. Required. + :type database_name: str + :param container_name: Cosmos DB container name. Required. + :type container_name: str + :param stored_procedure_name: Cosmos DB storedProcedure name. Required. + :type stored_procedure_name: str + :return: SqlStoredProcedureGetResults or the result of cls(response) + :rtype: ~azure.mgmt.cosmosdb.models.SqlStoredProcedureGetResults :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -2479,13 +2117,14 @@ async def get_sql_container_throughput( _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.ThroughputSettingsGetResults] = kwargs.pop("cls", None) + cls: ClsType[_models.SqlStoredProcedureGetResults] = kwargs.pop("cls", None) - _request = build_get_sql_container_throughput_request( + _request = build_get_sql_stored_procedure_request( resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, container_name=container_name, + stored_procedure_name=stored_procedure_name, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, @@ -2502,22 +2141,29 @@ async def get_sql_container_throughput( if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("ThroughputSettingsGetResults", pipeline_response.http_response) + deserialized = self._deserialize("SqlStoredProcedureGetResults", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - async def _update_sql_container_throughput_initial( + async def _create_update_sql_stored_procedure_initial( # pylint: disable=name-too-long self, resource_group_name: str, account_name: str, database_name: str, container_name: str, - update_throughput_parameters: Union[_models.ThroughputSettingsUpdateParameters, IO[bytes]], + stored_procedure_name: str, + create_update_sql_stored_procedure_parameters: Union[ + _models.SqlStoredProcedureCreateUpdateParameters, IO[bytes] + ], **kwargs: Any ) -> AsyncIterator[bytes]: error_map: MutableMapping = { @@ -2538,16 +2184,19 @@ async def _update_sql_container_throughput_initial( content_type = content_type or "application/json" _json = None _content = None - if isinstance(update_throughput_parameters, (IOBase, bytes)): - _content = update_throughput_parameters + if isinstance(create_update_sql_stored_procedure_parameters, (IOBase, bytes)): + _content = create_update_sql_stored_procedure_parameters else: - _json = self._serialize.body(update_throughput_parameters, "ThroughputSettingsUpdateParameters") + _json = self._serialize.body( + create_update_sql_stored_procedure_parameters, "SqlStoredProcedureCreateUpdateParameters" + ) - _request = build_update_sql_container_throughput_request( + _request = build_create_update_sql_stored_procedure_request( resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, container_name=container_name, + stored_procedure_name=stored_procedure_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, @@ -2572,14 +2221,19 @@ async def _update_sql_container_throughput_initial( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + 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["azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("azure-AsyncOperation") + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") ) - response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) @@ -2589,18 +2243,19 @@ async def _update_sql_container_throughput_initial( return deserialized # type: ignore @overload - async def begin_update_sql_container_throughput( + async def begin_create_update_sql_stored_procedure( self, resource_group_name: str, account_name: str, database_name: str, container_name: str, - update_throughput_parameters: _models.ThroughputSettingsUpdateParameters, + stored_procedure_name: str, + create_update_sql_stored_procedure_parameters: _models.SqlStoredProcedureCreateUpdateParameters, *, content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller[_models.ThroughputSettingsGetResults]: - """Update RUs per second of an Azure Cosmos DB SQL container. + ) -> AsyncLROPoller[_models.SqlStoredProcedureGetResults]: + """Create or update an Azure Cosmos DB SQL storedProcedure. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -2611,33 +2266,36 @@ async def begin_update_sql_container_throughput( :type database_name: str :param container_name: Cosmos DB container name. Required. :type container_name: str - :param update_throughput_parameters: The parameters to provide for the RUs per second of the - current SQL container. Required. - :type update_throughput_parameters: - ~azure.mgmt.cosmosdb.models.ThroughputSettingsUpdateParameters + :param stored_procedure_name: Cosmos DB storedProcedure name. Required. + :type stored_procedure_name: str + :param create_update_sql_stored_procedure_parameters: The parameters to provide for the current + SQL storedProcedure. Required. + :type create_update_sql_stored_procedure_parameters: + ~azure.mgmt.cosmosdb.models.SqlStoredProcedureCreateUpdateParameters :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 ThroughputSettingsGetResults or the + :return: An instance of AsyncLROPoller that returns either SqlStoredProcedureGetResults or the result of cls(response) :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.ThroughputSettingsGetResults] + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.SqlStoredProcedureGetResults] :raises ~azure.core.exceptions.HttpResponseError: """ @overload - async def begin_update_sql_container_throughput( + async def begin_create_update_sql_stored_procedure( self, resource_group_name: str, account_name: str, database_name: str, container_name: str, - update_throughput_parameters: IO[bytes], + stored_procedure_name: str, + create_update_sql_stored_procedure_parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller[_models.ThroughputSettingsGetResults]: - """Update RUs per second of an Azure Cosmos DB SQL container. + ) -> AsyncLROPoller[_models.SqlStoredProcedureGetResults]: + """Create or update an Azure Cosmos DB SQL storedProcedure. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -2648,30 +2306,35 @@ async def begin_update_sql_container_throughput( :type database_name: str :param container_name: Cosmos DB container name. Required. :type container_name: str - :param update_throughput_parameters: The parameters to provide for the RUs per second of the - current SQL container. Required. - :type update_throughput_parameters: IO[bytes] + :param stored_procedure_name: Cosmos DB storedProcedure name. Required. + :type stored_procedure_name: str + :param create_update_sql_stored_procedure_parameters: The parameters to provide for the current + SQL storedProcedure. Required. + :type create_update_sql_stored_procedure_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 ThroughputSettingsGetResults or the + :return: An instance of AsyncLROPoller that returns either SqlStoredProcedureGetResults or the result of cls(response) :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.ThroughputSettingsGetResults] + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.SqlStoredProcedureGetResults] :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace_async - async def begin_update_sql_container_throughput( + async def begin_create_update_sql_stored_procedure( self, resource_group_name: str, account_name: str, database_name: str, container_name: str, - update_throughput_parameters: Union[_models.ThroughputSettingsUpdateParameters, IO[bytes]], + stored_procedure_name: str, + create_update_sql_stored_procedure_parameters: Union[ + _models.SqlStoredProcedureCreateUpdateParameters, IO[bytes] + ], **kwargs: Any - ) -> AsyncLROPoller[_models.ThroughputSettingsGetResults]: - """Update RUs per second of an Azure Cosmos DB SQL container. + ) -> AsyncLROPoller[_models.SqlStoredProcedureGetResults]: + """Create or update an Azure Cosmos DB SQL storedProcedure. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -2680,17 +2343,19 @@ async def begin_update_sql_container_throughput( :type account_name: str :param database_name: Cosmos DB database name. Required. :type database_name: str - :param container_name: Cosmos DB container name. Required. - :type container_name: str - :param update_throughput_parameters: The parameters to provide for the RUs per second of the - current SQL container. Is either a ThroughputSettingsUpdateParameters type or a IO[bytes] type. - Required. - :type update_throughput_parameters: - ~azure.mgmt.cosmosdb.models.ThroughputSettingsUpdateParameters or IO[bytes] - :return: An instance of AsyncLROPoller that returns either ThroughputSettingsGetResults or the + :param container_name: Cosmos DB container name. Required. + :type container_name: str + :param stored_procedure_name: Cosmos DB storedProcedure name. Required. + :type stored_procedure_name: str + :param create_update_sql_stored_procedure_parameters: The parameters to provide for the current + SQL storedProcedure. Is either a SqlStoredProcedureCreateUpdateParameters type or a IO[bytes] + type. Required. + :type create_update_sql_stored_procedure_parameters: + ~azure.mgmt.cosmosdb.models.SqlStoredProcedureCreateUpdateParameters or IO[bytes] + :return: An instance of AsyncLROPoller that returns either SqlStoredProcedureGetResults or the result of cls(response) :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.ThroughputSettingsGetResults] + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.SqlStoredProcedureGetResults] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -2698,17 +2363,18 @@ async def begin_update_sql_container_throughput( 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.ThroughputSettingsGetResults] = kwargs.pop("cls", None) + cls: ClsType[_models.SqlStoredProcedureGetResults] = 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_sql_container_throughput_initial( + raw_result = await self._create_update_sql_stored_procedure_initial( resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, container_name=container_name, - update_throughput_parameters=update_throughput_parameters, + stored_procedure_name=stored_procedure_name, + create_update_sql_stored_procedure_parameters=create_update_sql_stored_procedure_parameters, api_version=api_version, content_type=content_type, cls=lambda x, y, z: x, @@ -2720,30 +2386,38 @@ async def begin_update_sql_container_throughput( kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ThroughputSettingsGetResults", pipeline_response.http_response) + deserialized = self._deserialize("SqlStoredProcedureGetResults", 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, **kwargs)) + 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.ThroughputSettingsGetResults].from_continuation_token( + return AsyncLROPoller[_models.SqlStoredProcedureGetResults].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller[_models.ThroughputSettingsGetResults]( + return AsyncLROPoller[_models.SqlStoredProcedureGetResults]( self._client, raw_result, get_long_running_output, polling_method # type: ignore ) - async def _migrate_sql_container_to_autoscale_initial( # pylint: disable=name-too-long - self, resource_group_name: str, account_name: str, database_name: str, container_name: str, **kwargs: Any + async def _delete_sql_stored_procedure_initial( + self, + resource_group_name: str, + account_name: str, + database_name: str, + container_name: str, + stored_procedure_name: str, + **kwargs: Any ) -> AsyncIterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -2759,11 +2433,12 @@ async def _migrate_sql_container_to_autoscale_initial( # pylint: disable=name-t 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_migrate_sql_container_to_autoscale_request( + _request = build_delete_sql_stored_procedure_request( resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, container_name=container_name, + stored_procedure_name=stored_procedure_name, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, @@ -2779,20 +2454,24 @@ async def _migrate_sql_container_to_autoscale_initial( # pylint: disable=name-t response = pipeline_response.http_response - if response.status_code not in [200, 202]: + 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + 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["azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("azure-AsyncOperation") + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") ) - response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) @@ -2802,10 +2481,16 @@ async def _migrate_sql_container_to_autoscale_initial( # pylint: disable=name-t return deserialized # type: ignore @distributed_trace_async - async def begin_migrate_sql_container_to_autoscale( - self, resource_group_name: str, account_name: str, database_name: str, container_name: str, **kwargs: Any - ) -> AsyncLROPoller[_models.ThroughputSettingsGetResults]: - """Migrate an Azure Cosmos DB SQL container from manual throughput to autoscale. + async def begin_delete_sql_stored_procedure( + self, + resource_group_name: str, + account_name: str, + database_name: str, + container_name: str, + stored_procedure_name: str, + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Deletes an existing Azure Cosmos DB SQL storedProcedure. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -2816,26 +2501,27 @@ async def begin_migrate_sql_container_to_autoscale( :type database_name: str :param container_name: Cosmos DB container name. Required. :type container_name: str - :return: An instance of AsyncLROPoller that returns either ThroughputSettingsGetResults or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.ThroughputSettingsGetResults] + :param stored_procedure_name: Cosmos DB storedProcedure name. Required. + :type stored_procedure_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[_models.ThroughputSettingsGetResults] = kwargs.pop("cls", 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._migrate_sql_container_to_autoscale_initial( + raw_result = await self._delete_sql_stored_procedure_initial( resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, container_name=container_name, + stored_procedure_name=stored_procedure_name, api_version=api_version, cls=lambda x, y, z: x, headers=_headers, @@ -2845,32 +2531,47 @@ async def begin_migrate_sql_container_to_autoscale( await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ThroughputSettingsGetResults", pipeline_response.http_response) + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return cls(pipeline_response, None, {}) # type: ignore if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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.ThroughputSettingsGetResults].from_continuation_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[_models.ThroughputSettingsGetResults]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - async def _migrate_sql_container_to_manual_throughput_initial( # pylint: disable=name-too-long + @distributed_trace_async + async def get_sql_container_throughput( self, resource_group_name: str, account_name: str, database_name: str, container_name: str, **kwargs: Any - ) -> AsyncIterator[bytes]: + ) -> _models.ThroughputSettingsGetResults: + """Gets the RUs per second of the SQL container under an existing Azure Cosmos DB database + account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param database_name: Cosmos DB database name. Required. + :type database_name: str + :param container_name: Cosmos DB container name. Required. + :type container_name: str + :return: ThroughputSettingsGetResults or the result of cls(response) + :rtype: ~azure.mgmt.cosmosdb.models.ThroughputSettingsGetResults + :raises ~azure.core.exceptions.HttpResponseError: + """ error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -2883,15 +2584,84 @@ async def _migrate_sql_container_to_manual_throughput_initial( # pylint: disabl _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.ThroughputSettingsGetResults] = kwargs.pop("cls", None) + + _request = build_get_sql_container_throughput_request( + resource_group_name=resource_group_name, + account_name=account_name, + database_name=database_name, + container_name=container_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("ThroughputSettingsGetResults", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + async def _update_sql_container_throughput_initial( + self, + resource_group_name: str, + account_name: str, + database_name: str, + container_name: str, + update_throughput_parameters: Union[_models.ThroughputSettingsUpdateParameters, 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) - _request = build_migrate_sql_container_to_manual_throughput_request( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(update_throughput_parameters, (IOBase, bytes)): + _content = update_throughput_parameters + else: + _json = self._serialize.body(update_throughput_parameters, "ThroughputSettingsUpdateParameters") + + _request = build_update_sql_container_throughput_request( resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, container_name=container_name, subscription_id=self._config.subscription_id, api_version=api_version, + content_type=content_type, + json=_json, + content=_content, headers=_headers, params=_params, ) @@ -2911,14 +2681,19 @@ async def _migrate_sql_container_to_manual_throughput_initial( # pylint: disabl except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + 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["azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("azure-AsyncOperation") + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") ) - response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) @@ -2927,11 +2702,90 @@ async def _migrate_sql_container_to_manual_throughput_initial( # pylint: disabl return deserialized # type: ignore + @overload + async def begin_update_sql_container_throughput( + self, + resource_group_name: str, + account_name: str, + database_name: str, + container_name: str, + update_throughput_parameters: _models.ThroughputSettingsUpdateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ThroughputSettingsGetResults]: + """Update RUs per second of an Azure Cosmos DB SQL container. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param database_name: Cosmos DB database name. Required. + :type database_name: str + :param container_name: Cosmos DB container name. Required. + :type container_name: str + :param update_throughput_parameters: The parameters to provide for the RUs per second of the + current SQL container. Required. + :type update_throughput_parameters: + ~azure.mgmt.cosmosdb.models.ThroughputSettingsUpdateParameters + :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 ThroughputSettingsGetResults or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.ThroughputSettingsGetResults] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update_sql_container_throughput( + self, + resource_group_name: str, + account_name: str, + database_name: str, + container_name: str, + update_throughput_parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ThroughputSettingsGetResults]: + """Update RUs per second of an Azure Cosmos DB SQL container. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param database_name: Cosmos DB database name. Required. + :type database_name: str + :param container_name: Cosmos DB container name. Required. + :type container_name: str + :param update_throughput_parameters: The parameters to provide for the RUs per second of the + current SQL container. Required. + :type update_throughput_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 ThroughputSettingsGetResults or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.ThroughputSettingsGetResults] + :raises ~azure.core.exceptions.HttpResponseError: + """ + @distributed_trace_async - async def begin_migrate_sql_container_to_manual_throughput( # pylint: disable=name-too-long - self, resource_group_name: str, account_name: str, database_name: str, container_name: str, **kwargs: Any + async def begin_update_sql_container_throughput( + self, + resource_group_name: str, + account_name: str, + database_name: str, + container_name: str, + update_throughput_parameters: Union[_models.ThroughputSettingsUpdateParameters, IO[bytes]], + **kwargs: Any ) -> AsyncLROPoller[_models.ThroughputSettingsGetResults]: - """Migrate an Azure Cosmos DB SQL container from autoscale to manual throughput. + """Update RUs per second of an Azure Cosmos DB SQL container. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -2942,27 +2796,35 @@ async def begin_migrate_sql_container_to_manual_throughput( # pylint: disable=n :type database_name: str :param container_name: Cosmos DB container name. Required. :type container_name: str + :param update_throughput_parameters: The parameters to provide for the RUs per second of the + current SQL container. Is either a ThroughputSettingsUpdateParameters type or a IO[bytes] type. + Required. + :type update_throughput_parameters: + ~azure.mgmt.cosmosdb.models.ThroughputSettingsUpdateParameters or IO[bytes] :return: An instance of AsyncLROPoller that returns either ThroughputSettingsGetResults or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.ThroughputSettingsGetResults] :raises ~azure.core.exceptions.HttpResponseError: """ - _headers = kwargs.pop("headers", {}) 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.ThroughputSettingsGetResults] = 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_sql_container_to_manual_throughput_initial( + raw_result = await self._update_sql_container_throughput_initial( resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, container_name=container_name, + update_throughput_parameters=update_throughput_parameters, api_version=api_version, + content_type=content_type, cls=lambda x, y, z: x, headers=_headers, params=_params, @@ -2978,7 +2840,9 @@ def get_long_running_output(pipeline_response): return deserialized if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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: @@ -2994,13 +2858,8 @@ def get_long_running_output(pipeline_response): self._client, raw_result, get_long_running_output, polling_method # type: ignore ) - async def _sql_database_retrieve_throughput_distribution_initial( # pylint: disable=name-too-long - self, - resource_group_name: str, - account_name: str, - database_name: str, - retrieve_throughput_parameters: Union[_models.RetrieveThroughputParameters, IO[bytes]], - **kwargs: Any + async def _migrate_sql_container_to_autoscale_initial( # pylint: disable=name-too-long + self, resource_group_name: str, account_name: str, database_name: str, container_name: str, **kwargs: Any ) -> AsyncIterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -3010,30 +2869,19 @@ async def _sql_database_retrieve_throughput_distribution_initial( # pylint: dis } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = case_insensitive_dict(kwargs.pop("headers", {}) 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)) - 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(retrieve_throughput_parameters, (IOBase, bytes)): - _content = retrieve_throughput_parameters - else: - _json = self._serialize.body(retrieve_throughput_parameters, "RetrieveThroughputParameters") - - _request = build_sql_database_retrieve_throughput_distribution_request( + _request = build_migrate_sql_container_to_autoscale_request( resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, + container_name=container_name, subscription_id=self._config.subscription_id, api_version=api_version, - content_type=content_type, - json=_json, - content=_content, headers=_headers, params=_params, ) @@ -3057,10 +2905,10 @@ async def _sql_database_retrieve_throughput_distribution_initial( # pylint: dis response_headers = {} if response.status_code == 202: - response_headers["azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("azure-AsyncOperation") + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") ) - response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) @@ -3069,82 +2917,11 @@ async def _sql_database_retrieve_throughput_distribution_initial( # pylint: dis return deserialized # type: ignore - @overload - async def begin_sql_database_retrieve_throughput_distribution( # pylint: disable=name-too-long - self, - resource_group_name: str, - account_name: str, - database_name: str, - retrieve_throughput_parameters: _models.RetrieveThroughputParameters, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.PhysicalPartitionThroughputInfoResult]: - """Retrieve throughput distribution for an Azure Cosmos DB SQL database. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param account_name: Cosmos DB database account name. Required. - :type account_name: str - :param database_name: Cosmos DB database name. Required. - :type database_name: str - :param retrieve_throughput_parameters: The parameters to provide for retrieving throughput - distribution for the current SQL database. Required. - :type retrieve_throughput_parameters: ~azure.mgmt.cosmosdb.models.RetrieveThroughputParameters - :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 - PhysicalPartitionThroughputInfoResult or the result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.PhysicalPartitionThroughputInfoResult] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_sql_database_retrieve_throughput_distribution( # pylint: disable=name-too-long - self, - resource_group_name: str, - account_name: str, - database_name: str, - retrieve_throughput_parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.PhysicalPartitionThroughputInfoResult]: - """Retrieve throughput distribution for an Azure Cosmos DB SQL database. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param account_name: Cosmos DB database account name. Required. - :type account_name: str - :param database_name: Cosmos DB database name. Required. - :type database_name: str - :param retrieve_throughput_parameters: The parameters to provide for retrieving throughput - distribution for the current SQL database. Required. - :type retrieve_throughput_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 - PhysicalPartitionThroughputInfoResult or the result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.PhysicalPartitionThroughputInfoResult] - :raises ~azure.core.exceptions.HttpResponseError: - """ - @distributed_trace_async - async def begin_sql_database_retrieve_throughput_distribution( # pylint: disable=name-too-long - self, - resource_group_name: str, - account_name: str, - database_name: str, - retrieve_throughput_parameters: Union[_models.RetrieveThroughputParameters, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.PhysicalPartitionThroughputInfoResult]: - """Retrieve throughput distribution for an Azure Cosmos DB SQL database. + async def begin_migrate_sql_container_to_autoscale( + self, resource_group_name: str, account_name: str, database_name: str, container_name: str, **kwargs: Any + ) -> AsyncLROPoller[_models.ThroughputSettingsGetResults]: + """Migrate an Azure Cosmos DB SQL container from manual throughput to autoscale. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -3153,34 +2930,29 @@ async def begin_sql_database_retrieve_throughput_distribution( # pylint: disabl :type account_name: str :param database_name: Cosmos DB database name. Required. :type database_name: str - :param retrieve_throughput_parameters: The parameters to provide for retrieving throughput - distribution for the current SQL database. Is either a RetrieveThroughputParameters type or a - IO[bytes] type. Required. - :type retrieve_throughput_parameters: ~azure.mgmt.cosmosdb.models.RetrieveThroughputParameters - or IO[bytes] - :return: An instance of AsyncLROPoller that returns either - PhysicalPartitionThroughputInfoResult or the result of cls(response) + :param container_name: Cosmos DB container name. Required. + :type container_name: str + :return: An instance of AsyncLROPoller that returns either ThroughputSettingsGetResults or the + result of cls(response) :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.PhysicalPartitionThroughputInfoResult] + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.ThroughputSettingsGetResults] :raises ~azure.core.exceptions.HttpResponseError: """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) 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)) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.PhysicalPartitionThroughputInfoResult] = kwargs.pop("cls", None) + cls: ClsType[_models.ThroughputSettingsGetResults] = 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._sql_database_retrieve_throughput_distribution_initial( + raw_result = await self._migrate_sql_container_to_autoscale_initial( resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, - retrieve_throughput_parameters=retrieve_throughput_parameters, + container_name=container_name, api_version=api_version, - content_type=content_type, cls=lambda x, y, z: x, headers=_headers, params=_params, @@ -3190,7 +2962,7 @@ async def begin_sql_database_retrieve_throughput_distribution( # pylint: disabl kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("PhysicalPartitionThroughputInfoResult", pipeline_response.http_response) + deserialized = self._deserialize("ThroughputSettingsGetResults", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized @@ -3204,23 +2976,18 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller[_models.PhysicalPartitionThroughputInfoResult].from_continuation_token( + return AsyncLROPoller[_models.ThroughputSettingsGetResults].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller[_models.PhysicalPartitionThroughputInfoResult]( + return AsyncLROPoller[_models.ThroughputSettingsGetResults]( self._client, raw_result, get_long_running_output, polling_method # type: ignore ) - async def _sql_database_redistribute_throughput_initial( # pylint: disable=name-too-long - self, - resource_group_name: str, - account_name: str, - database_name: str, - redistribute_throughput_parameters: Union[_models.RedistributeThroughputParameters, IO[bytes]], - **kwargs: Any + async def _migrate_sql_container_to_manual_throughput_initial( # pylint: disable=name-too-long + self, resource_group_name: str, account_name: str, database_name: str, container_name: str, **kwargs: Any ) -> AsyncIterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -3230,30 +2997,19 @@ async def _sql_database_redistribute_throughput_initial( # pylint: disable=name } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = case_insensitive_dict(kwargs.pop("headers", {}) 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)) - 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(redistribute_throughput_parameters, (IOBase, bytes)): - _content = redistribute_throughput_parameters - else: - _json = self._serialize.body(redistribute_throughput_parameters, "RedistributeThroughputParameters") - - _request = build_sql_database_redistribute_throughput_request( + _request = build_migrate_sql_container_to_manual_throughput_request( resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, + container_name=container_name, subscription_id=self._config.subscription_id, api_version=api_version, - content_type=content_type, - json=_json, - content=_content, headers=_headers, params=_params, ) @@ -3277,95 +3033,23 @@ async def _sql_database_redistribute_throughput_initial( # pylint: disable=name 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")) - - 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_sql_database_redistribute_throughput( # pylint: disable=name-too-long - self, - resource_group_name: str, - account_name: str, - database_name: str, - redistribute_throughput_parameters: _models.RedistributeThroughputParameters, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.PhysicalPartitionThroughputInfoResult]: - """Redistribute throughput for an Azure Cosmos DB SQL database. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param account_name: Cosmos DB database account name. Required. - :type account_name: str - :param database_name: Cosmos DB database name. Required. - :type database_name: str - :param redistribute_throughput_parameters: The parameters to provide for redistributing - throughput for the current SQL database. Required. - :type redistribute_throughput_parameters: - ~azure.mgmt.cosmosdb.models.RedistributeThroughputParameters - :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 - PhysicalPartitionThroughputInfoResult or the result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.PhysicalPartitionThroughputInfoResult] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_sql_database_redistribute_throughput( # pylint: disable=name-too-long - self, - resource_group_name: str, - account_name: str, - database_name: str, - redistribute_throughput_parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.PhysicalPartitionThroughputInfoResult]: - """Redistribute throughput for an Azure Cosmos DB SQL database. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param account_name: Cosmos DB database account name. Required. - :type account_name: str - :param database_name: Cosmos DB database name. Required. - :type database_name: str - :param redistribute_throughput_parameters: The parameters to provide for redistributing - throughput for the current SQL database. Required. - :type redistribute_throughput_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 - PhysicalPartitionThroughputInfoResult or the result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.PhysicalPartitionThroughputInfoResult] - :raises ~azure.core.exceptions.HttpResponseError: - """ + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + 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_sql_database_redistribute_throughput( # pylint: disable=name-too-long - self, - resource_group_name: str, - account_name: str, - database_name: str, - redistribute_throughput_parameters: Union[_models.RedistributeThroughputParameters, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.PhysicalPartitionThroughputInfoResult]: - """Redistribute throughput for an Azure Cosmos DB SQL database. + async def begin_migrate_sql_container_to_manual_throughput( # pylint: disable=name-too-long + self, resource_group_name: str, account_name: str, database_name: str, container_name: str, **kwargs: Any + ) -> AsyncLROPoller[_models.ThroughputSettingsGetResults]: + """Migrate an Azure Cosmos DB SQL container from autoscale to manual throughput. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -3374,34 +3058,29 @@ async def begin_sql_database_redistribute_throughput( # pylint: disable=name-to :type account_name: str :param database_name: Cosmos DB database name. Required. :type database_name: str - :param redistribute_throughput_parameters: The parameters to provide for redistributing - throughput for the current SQL database. Is either a RedistributeThroughputParameters type or a - IO[bytes] type. Required. - :type redistribute_throughput_parameters: - ~azure.mgmt.cosmosdb.models.RedistributeThroughputParameters or IO[bytes] - :return: An instance of AsyncLROPoller that returns either - PhysicalPartitionThroughputInfoResult or the result of cls(response) + :param container_name: Cosmos DB container name. Required. + :type container_name: str + :return: An instance of AsyncLROPoller that returns either ThroughputSettingsGetResults or the + result of cls(response) :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.PhysicalPartitionThroughputInfoResult] + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.ThroughputSettingsGetResults] :raises ~azure.core.exceptions.HttpResponseError: """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) 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)) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.PhysicalPartitionThroughputInfoResult] = kwargs.pop("cls", None) + cls: ClsType[_models.ThroughputSettingsGetResults] = 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._sql_database_redistribute_throughput_initial( + raw_result = await self._migrate_sql_container_to_manual_throughput_initial( resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, - redistribute_throughput_parameters=redistribute_throughput_parameters, + container_name=container_name, api_version=api_version, - content_type=content_type, cls=lambda x, y, z: x, headers=_headers, params=_params, @@ -3411,7 +3090,7 @@ async def begin_sql_database_redistribute_throughput( # pylint: disable=name-to kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("PhysicalPartitionThroughputInfoResult", pipeline_response.http_response) + deserialized = self._deserialize("ThroughputSettingsGetResults", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized @@ -3425,23 +3104,23 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller[_models.PhysicalPartitionThroughputInfoResult].from_continuation_token( + return AsyncLROPoller[_models.ThroughputSettingsGetResults].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller[_models.PhysicalPartitionThroughputInfoResult]( + return AsyncLROPoller[_models.ThroughputSettingsGetResults]( self._client, raw_result, get_long_running_output, polling_method # type: ignore ) - async def _sql_container_retrieve_throughput_distribution_initial( # pylint: disable=name-too-long + async def _sql_container_redistribute_throughput_initial( # pylint: disable=name-too-long self, resource_group_name: str, account_name: str, database_name: str, container_name: str, - retrieve_throughput_parameters: Union[_models.RetrieveThroughputParameters, IO[bytes]], + redistribute_throughput_parameters: Union[_models.RedistributeThroughputParameters, IO[bytes]], **kwargs: Any ) -> AsyncIterator[bytes]: error_map: MutableMapping = { @@ -3462,12 +3141,12 @@ async def _sql_container_retrieve_throughput_distribution_initial( # pylint: di content_type = content_type or "application/json" _json = None _content = None - if isinstance(retrieve_throughput_parameters, (IOBase, bytes)): - _content = retrieve_throughput_parameters + if isinstance(redistribute_throughput_parameters, (IOBase, bytes)): + _content = redistribute_throughput_parameters else: - _json = self._serialize.body(retrieve_throughput_parameters, "RetrieveThroughputParameters") + _json = self._serialize.body(redistribute_throughput_parameters, "RedistributeThroughputParameters") - _request = build_sql_container_retrieve_throughput_distribution_request( + _request = build_sql_container_redistribute_throughput_request( resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, @@ -3500,10 +3179,10 @@ async def _sql_container_retrieve_throughput_distribution_initial( # pylint: di response_headers = {} if response.status_code == 202: - response_headers["azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("azure-AsyncOperation") + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") ) - response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) @@ -3513,18 +3192,18 @@ async def _sql_container_retrieve_throughput_distribution_initial( # pylint: di return deserialized # type: ignore @overload - async def begin_sql_container_retrieve_throughput_distribution( # pylint: disable=name-too-long + async def begin_sql_container_redistribute_throughput( # pylint: disable=name-too-long self, resource_group_name: str, account_name: str, database_name: str, container_name: str, - retrieve_throughput_parameters: _models.RetrieveThroughputParameters, + redistribute_throughput_parameters: _models.RedistributeThroughputParameters, *, content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[_models.PhysicalPartitionThroughputInfoResult]: - """Retrieve throughput distribution for an Azure Cosmos DB SQL container. + """Redistribute throughput for an Azure Cosmos DB SQL container. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -3535,9 +3214,10 @@ async def begin_sql_container_retrieve_throughput_distribution( # pylint: disab :type database_name: str :param container_name: Cosmos DB container name. Required. :type container_name: str - :param retrieve_throughput_parameters: The parameters to provide for retrieving throughput - distribution for the current SQL container. Required. - :type retrieve_throughput_parameters: ~azure.mgmt.cosmosdb.models.RetrieveThroughputParameters + :param redistribute_throughput_parameters: The parameters to provide for redistributing + throughput for the current SQL container. Required. + :type redistribute_throughput_parameters: + ~azure.mgmt.cosmosdb.models.RedistributeThroughputParameters :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str @@ -3549,18 +3229,18 @@ async def begin_sql_container_retrieve_throughput_distribution( # pylint: disab """ @overload - async def begin_sql_container_retrieve_throughput_distribution( # pylint: disable=name-too-long + async def begin_sql_container_redistribute_throughput( # pylint: disable=name-too-long self, resource_group_name: str, account_name: str, database_name: str, container_name: str, - retrieve_throughput_parameters: IO[bytes], + redistribute_throughput_parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[_models.PhysicalPartitionThroughputInfoResult]: - """Retrieve throughput distribution for an Azure Cosmos DB SQL container. + """Redistribute throughput for an Azure Cosmos DB SQL container. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -3571,9 +3251,9 @@ async def begin_sql_container_retrieve_throughput_distribution( # pylint: disab :type database_name: str :param container_name: Cosmos DB container name. Required. :type container_name: str - :param retrieve_throughput_parameters: The parameters to provide for retrieving throughput - distribution for the current SQL container. Required. - :type retrieve_throughput_parameters: IO[bytes] + :param redistribute_throughput_parameters: The parameters to provide for redistributing + throughput for the current SQL container. Required. + :type redistribute_throughput_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 @@ -3585,16 +3265,16 @@ async def begin_sql_container_retrieve_throughput_distribution( # pylint: disab """ @distributed_trace_async - async def begin_sql_container_retrieve_throughput_distribution( # pylint: disable=name-too-long + async def begin_sql_container_redistribute_throughput( # pylint: disable=name-too-long self, resource_group_name: str, account_name: str, database_name: str, container_name: str, - retrieve_throughput_parameters: Union[_models.RetrieveThroughputParameters, IO[bytes]], + redistribute_throughput_parameters: Union[_models.RedistributeThroughputParameters, IO[bytes]], **kwargs: Any ) -> AsyncLROPoller[_models.PhysicalPartitionThroughputInfoResult]: - """Retrieve throughput distribution for an Azure Cosmos DB SQL container. + """Redistribute throughput for an Azure Cosmos DB SQL container. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -3605,11 +3285,11 @@ async def begin_sql_container_retrieve_throughput_distribution( # pylint: disab :type database_name: str :param container_name: Cosmos DB container name. Required. :type container_name: str - :param retrieve_throughput_parameters: The parameters to provide for retrieving throughput - distribution for the current SQL container. Is either a RetrieveThroughputParameters type or a - IO[bytes] type. Required. - :type retrieve_throughput_parameters: ~azure.mgmt.cosmosdb.models.RetrieveThroughputParameters - or IO[bytes] + :param redistribute_throughput_parameters: The parameters to provide for redistributing + throughput for the current SQL container. Is either a RedistributeThroughputParameters type or + a IO[bytes] type. Required. + :type redistribute_throughput_parameters: + ~azure.mgmt.cosmosdb.models.RedistributeThroughputParameters or IO[bytes] :return: An instance of AsyncLROPoller that returns either PhysicalPartitionThroughputInfoResult or the result of cls(response) :rtype: @@ -3626,12 +3306,12 @@ async def begin_sql_container_retrieve_throughput_distribution( # pylint: disab 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._sql_container_retrieve_throughput_distribution_initial( + raw_result = await self._sql_container_redistribute_throughput_initial( resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, container_name=container_name, - retrieve_throughput_parameters=retrieve_throughput_parameters, + redistribute_throughput_parameters=redistribute_throughput_parameters, api_version=api_version, content_type=content_type, cls=lambda x, y, z: x, @@ -3667,13 +3347,13 @@ def get_long_running_output(pipeline_response): self._client, raw_result, get_long_running_output, polling_method # type: ignore ) - async def _sql_container_redistribute_throughput_initial( # pylint: disable=name-too-long + async def _sql_container_retrieve_throughput_distribution_initial( # pylint: disable=name-too-long self, resource_group_name: str, account_name: str, database_name: str, container_name: str, - redistribute_throughput_parameters: Union[_models.RedistributeThroughputParameters, IO[bytes]], + retrieve_throughput_parameters: Union[_models.RetrieveThroughputParameters, IO[bytes]], **kwargs: Any ) -> AsyncIterator[bytes]: error_map: MutableMapping = { @@ -3694,12 +3374,12 @@ async def _sql_container_redistribute_throughput_initial( # pylint: disable=nam content_type = content_type or "application/json" _json = None _content = None - if isinstance(redistribute_throughput_parameters, (IOBase, bytes)): - _content = redistribute_throughput_parameters + if isinstance(retrieve_throughput_parameters, (IOBase, bytes)): + _content = retrieve_throughput_parameters else: - _json = self._serialize.body(redistribute_throughput_parameters, "RedistributeThroughputParameters") + _json = self._serialize.body(retrieve_throughput_parameters, "RetrieveThroughputParameters") - _request = build_sql_container_redistribute_throughput_request( + _request = build_sql_container_retrieve_throughput_distribution_request( resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, @@ -3732,10 +3412,10 @@ async def _sql_container_redistribute_throughput_initial( # pylint: disable=nam response_headers = {} if response.status_code == 202: - response_headers["azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("azure-AsyncOperation") + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") ) - response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) @@ -3745,18 +3425,18 @@ async def _sql_container_redistribute_throughput_initial( # pylint: disable=nam return deserialized # type: ignore @overload - async def begin_sql_container_redistribute_throughput( # pylint: disable=name-too-long + async def begin_sql_container_retrieve_throughput_distribution( # pylint: disable=name-too-long self, resource_group_name: str, account_name: str, database_name: str, container_name: str, - redistribute_throughput_parameters: _models.RedistributeThroughputParameters, + retrieve_throughput_parameters: _models.RetrieveThroughputParameters, *, content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[_models.PhysicalPartitionThroughputInfoResult]: - """Redistribute throughput for an Azure Cosmos DB SQL container. + """Retrieve throughput distribution for an Azure Cosmos DB SQL container. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -3767,10 +3447,9 @@ async def begin_sql_container_redistribute_throughput( # pylint: disable=name-t :type database_name: str :param container_name: Cosmos DB container name. Required. :type container_name: str - :param redistribute_throughput_parameters: The parameters to provide for redistributing - throughput for the current SQL container. Required. - :type redistribute_throughput_parameters: - ~azure.mgmt.cosmosdb.models.RedistributeThroughputParameters + :param retrieve_throughput_parameters: The parameters to provide for retrieving throughput + distribution for the current SQL container. Required. + :type retrieve_throughput_parameters: ~azure.mgmt.cosmosdb.models.RetrieveThroughputParameters :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str @@ -3782,18 +3461,18 @@ async def begin_sql_container_redistribute_throughput( # pylint: disable=name-t """ @overload - async def begin_sql_container_redistribute_throughput( # pylint: disable=name-too-long + async def begin_sql_container_retrieve_throughput_distribution( # pylint: disable=name-too-long self, resource_group_name: str, account_name: str, database_name: str, container_name: str, - redistribute_throughput_parameters: IO[bytes], + retrieve_throughput_parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[_models.PhysicalPartitionThroughputInfoResult]: - """Redistribute throughput for an Azure Cosmos DB SQL container. + """Retrieve throughput distribution for an Azure Cosmos DB SQL container. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -3804,9 +3483,9 @@ async def begin_sql_container_redistribute_throughput( # pylint: disable=name-t :type database_name: str :param container_name: Cosmos DB container name. Required. :type container_name: str - :param redistribute_throughput_parameters: The parameters to provide for redistributing - throughput for the current SQL container. Required. - :type redistribute_throughput_parameters: IO[bytes] + :param retrieve_throughput_parameters: The parameters to provide for retrieving throughput + distribution for the current SQL container. Required. + :type retrieve_throughput_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 @@ -3818,16 +3497,16 @@ async def begin_sql_container_redistribute_throughput( # pylint: disable=name-t """ @distributed_trace_async - async def begin_sql_container_redistribute_throughput( # pylint: disable=name-too-long + async def begin_sql_container_retrieve_throughput_distribution( # pylint: disable=name-too-long self, resource_group_name: str, account_name: str, database_name: str, container_name: str, - redistribute_throughput_parameters: Union[_models.RedistributeThroughputParameters, IO[bytes]], + retrieve_throughput_parameters: Union[_models.RetrieveThroughputParameters, IO[bytes]], **kwargs: Any ) -> AsyncLROPoller[_models.PhysicalPartitionThroughputInfoResult]: - """Redistribute throughput for an Azure Cosmos DB SQL container. + """Retrieve throughput distribution for an Azure Cosmos DB SQL container. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -3838,11 +3517,11 @@ async def begin_sql_container_redistribute_throughput( # pylint: disable=name-t :type database_name: str :param container_name: Cosmos DB container name. Required. :type container_name: str - :param redistribute_throughput_parameters: The parameters to provide for redistributing - throughput for the current SQL container. Is either a RedistributeThroughputParameters type or - a IO[bytes] type. Required. - :type redistribute_throughput_parameters: - ~azure.mgmt.cosmosdb.models.RedistributeThroughputParameters or IO[bytes] + :param retrieve_throughput_parameters: The parameters to provide for retrieving throughput + distribution for the current SQL container. Is either a RetrieveThroughputParameters type or a + IO[bytes] type. Required. + :type retrieve_throughput_parameters: ~azure.mgmt.cosmosdb.models.RetrieveThroughputParameters + or IO[bytes] :return: An instance of AsyncLROPoller that returns either PhysicalPartitionThroughputInfoResult or the result of cls(response) :rtype: @@ -3859,12 +3538,12 @@ async def begin_sql_container_redistribute_throughput( # pylint: disable=name-t 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._sql_container_redistribute_throughput_initial( + raw_result = await self._sql_container_retrieve_throughput_distribution_initial( resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, container_name=container_name, - redistribute_throughput_parameters=redistribute_throughput_parameters, + retrieve_throughput_parameters=retrieve_throughput_parameters, api_version=api_version, content_type=content_type, cls=lambda x, y, z: x, @@ -3901,10 +3580,10 @@ def get_long_running_output(pipeline_response): ) @distributed_trace - def list_sql_stored_procedures( + def list_sql_triggers( self, resource_group_name: str, account_name: str, database_name: str, container_name: str, **kwargs: Any - ) -> AsyncItemPaged["_models.SqlStoredProcedureGetResults"]: - """Lists the SQL storedProcedure under an existing Azure Cosmos DB database account. + ) -> AsyncItemPaged["_models.SqlTriggerGetResults"]: + """Lists the SQL trigger under an existing Azure Cosmos DB database account. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -3915,17 +3594,17 @@ def list_sql_stored_procedures( :type database_name: str :param container_name: Cosmos DB container name. Required. :type container_name: str - :return: An iterator like instance of either SqlStoredProcedureGetResults or the result of + :return: An iterator like instance of either SqlTriggerGetResults or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.SqlStoredProcedureGetResults] + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.SqlTriggerGetResults] :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.SqlStoredProcedureListResult] = kwargs.pop("cls", None) + cls: ClsType[_models.SqlTriggerListResult] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -3938,7 +3617,7 @@ def list_sql_stored_procedures( def prepare_request(next_link=None): if not next_link: - _request = build_list_sql_stored_procedures_request( + _request = build_list_sql_triggers_request( resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, @@ -3968,11 +3647,11 @@ def prepare_request(next_link=None): return _request async def extract_data(pipeline_response): - deserialized = self._deserialize("SqlStoredProcedureListResult", pipeline_response) + deserialized = self._deserialize("SqlTriggerListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore - return None, AsyncList(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): _request = prepare_request(next_link) @@ -3985,23 +3664,27 @@ 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + 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_sql_stored_procedure( + async def get_sql_trigger( self, resource_group_name: str, account_name: str, database_name: str, container_name: str, - stored_procedure_name: str, + trigger_name: str, **kwargs: Any - ) -> _models.SqlStoredProcedureGetResults: - """Gets the SQL storedProcedure under an existing Azure Cosmos DB database account. + ) -> _models.SqlTriggerGetResults: + """Gets the SQL trigger under an existing Azure Cosmos DB database account. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -4012,10 +3695,10 @@ async def get_sql_stored_procedure( :type database_name: str :param container_name: Cosmos DB container name. Required. :type container_name: str - :param stored_procedure_name: Cosmos DB storedProcedure name. Required. - :type stored_procedure_name: str - :return: SqlStoredProcedureGetResults or the result of cls(response) - :rtype: ~azure.mgmt.cosmosdb.models.SqlStoredProcedureGetResults + :param trigger_name: Cosmos DB trigger name. Required. + :type trigger_name: str + :return: SqlTriggerGetResults or the result of cls(response) + :rtype: ~azure.mgmt.cosmosdb.models.SqlTriggerGetResults :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -4030,14 +3713,14 @@ async def get_sql_stored_procedure( _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.SqlStoredProcedureGetResults] = kwargs.pop("cls", None) + cls: ClsType[_models.SqlTriggerGetResults] = kwargs.pop("cls", None) - _request = build_get_sql_stored_procedure_request( + _request = build_get_sql_trigger_request( resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, container_name=container_name, - stored_procedure_name=stored_procedure_name, + trigger_name=trigger_name, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, @@ -4054,25 +3737,27 @@ async def get_sql_stored_procedure( if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("SqlStoredProcedureGetResults", pipeline_response.http_response) + deserialized = self._deserialize("SqlTriggerGetResults", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - async def _create_update_sql_stored_procedure_initial( # pylint: disable=name-too-long + async def _create_update_sql_trigger_initial( self, resource_group_name: str, account_name: str, database_name: str, container_name: str, - stored_procedure_name: str, - create_update_sql_stored_procedure_parameters: Union[ - _models.SqlStoredProcedureCreateUpdateParameters, IO[bytes] - ], + trigger_name: str, + create_update_sql_trigger_parameters: Union[_models.SqlTriggerCreateUpdateParameters, IO[bytes]], **kwargs: Any ) -> AsyncIterator[bytes]: error_map: MutableMapping = { @@ -4093,19 +3778,17 @@ async def _create_update_sql_stored_procedure_initial( # pylint: disable=name-t content_type = content_type or "application/json" _json = None _content = None - if isinstance(create_update_sql_stored_procedure_parameters, (IOBase, bytes)): - _content = create_update_sql_stored_procedure_parameters + if isinstance(create_update_sql_trigger_parameters, (IOBase, bytes)): + _content = create_update_sql_trigger_parameters else: - _json = self._serialize.body( - create_update_sql_stored_procedure_parameters, "SqlStoredProcedureCreateUpdateParameters" - ) + _json = self._serialize.body(create_update_sql_trigger_parameters, "SqlTriggerCreateUpdateParameters") - _request = build_create_update_sql_stored_procedure_request( + _request = build_create_update_sql_trigger_request( resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, container_name=container_name, - stored_procedure_name=stored_procedure_name, + trigger_name=trigger_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, @@ -4130,14 +3813,19 @@ async def _create_update_sql_stored_procedure_initial( # pylint: disable=name-t except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + 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["azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("azure-AsyncOperation") + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") ) - response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) @@ -4147,19 +3835,19 @@ async def _create_update_sql_stored_procedure_initial( # pylint: disable=name-t return deserialized # type: ignore @overload - async def begin_create_update_sql_stored_procedure( + async def begin_create_update_sql_trigger( self, resource_group_name: str, account_name: str, database_name: str, container_name: str, - stored_procedure_name: str, - create_update_sql_stored_procedure_parameters: _models.SqlStoredProcedureCreateUpdateParameters, + trigger_name: str, + create_update_sql_trigger_parameters: _models.SqlTriggerCreateUpdateParameters, *, content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller[_models.SqlStoredProcedureGetResults]: - """Create or update an Azure Cosmos DB SQL storedProcedure. + ) -> AsyncLROPoller[_models.SqlTriggerGetResults]: + """Create or update an Azure Cosmos DB SQL trigger. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -4170,36 +3858,35 @@ async def begin_create_update_sql_stored_procedure( :type database_name: str :param container_name: Cosmos DB container name. Required. :type container_name: str - :param stored_procedure_name: Cosmos DB storedProcedure name. Required. - :type stored_procedure_name: str - :param create_update_sql_stored_procedure_parameters: The parameters to provide for the current - SQL storedProcedure. Required. - :type create_update_sql_stored_procedure_parameters: - ~azure.mgmt.cosmosdb.models.SqlStoredProcedureCreateUpdateParameters + :param trigger_name: Cosmos DB trigger name. Required. + :type trigger_name: str + :param create_update_sql_trigger_parameters: The parameters to provide for the current SQL + trigger. Required. + :type create_update_sql_trigger_parameters: + ~azure.mgmt.cosmosdb.models.SqlTriggerCreateUpdateParameters :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 SqlStoredProcedureGetResults or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.SqlStoredProcedureGetResults] + :return: An instance of AsyncLROPoller that returns either SqlTriggerGetResults or the result + of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.SqlTriggerGetResults] :raises ~azure.core.exceptions.HttpResponseError: """ @overload - async def begin_create_update_sql_stored_procedure( + async def begin_create_update_sql_trigger( self, resource_group_name: str, account_name: str, database_name: str, container_name: str, - stored_procedure_name: str, - create_update_sql_stored_procedure_parameters: IO[bytes], + trigger_name: str, + create_update_sql_trigger_parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller[_models.SqlStoredProcedureGetResults]: - """Create or update an Azure Cosmos DB SQL storedProcedure. + ) -> AsyncLROPoller[_models.SqlTriggerGetResults]: + """Create or update an Azure Cosmos DB SQL trigger. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -4210,35 +3897,32 @@ async def begin_create_update_sql_stored_procedure( :type database_name: str :param container_name: Cosmos DB container name. Required. :type container_name: str - :param stored_procedure_name: Cosmos DB storedProcedure name. Required. - :type stored_procedure_name: str - :param create_update_sql_stored_procedure_parameters: The parameters to provide for the current - SQL storedProcedure. Required. - :type create_update_sql_stored_procedure_parameters: IO[bytes] + :param trigger_name: Cosmos DB trigger name. Required. + :type trigger_name: str + :param create_update_sql_trigger_parameters: The parameters to provide for the current SQL + trigger. Required. + :type create_update_sql_trigger_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 SqlStoredProcedureGetResults or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.SqlStoredProcedureGetResults] + :return: An instance of AsyncLROPoller that returns either SqlTriggerGetResults or the result + of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.SqlTriggerGetResults] :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace_async - async def begin_create_update_sql_stored_procedure( + async def begin_create_update_sql_trigger( self, resource_group_name: str, account_name: str, database_name: str, container_name: str, - stored_procedure_name: str, - create_update_sql_stored_procedure_parameters: Union[ - _models.SqlStoredProcedureCreateUpdateParameters, IO[bytes] - ], + trigger_name: str, + create_update_sql_trigger_parameters: Union[_models.SqlTriggerCreateUpdateParameters, IO[bytes]], **kwargs: Any - ) -> AsyncLROPoller[_models.SqlStoredProcedureGetResults]: - """Create or update an Azure Cosmos DB SQL storedProcedure. + ) -> AsyncLROPoller[_models.SqlTriggerGetResults]: + """Create or update an Azure Cosmos DB SQL trigger. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -4249,17 +3933,15 @@ async def begin_create_update_sql_stored_procedure( :type database_name: str :param container_name: Cosmos DB container name. Required. :type container_name: str - :param stored_procedure_name: Cosmos DB storedProcedure name. Required. - :type stored_procedure_name: str - :param create_update_sql_stored_procedure_parameters: The parameters to provide for the current - SQL storedProcedure. Is either a SqlStoredProcedureCreateUpdateParameters type or a IO[bytes] - type. Required. - :type create_update_sql_stored_procedure_parameters: - ~azure.mgmt.cosmosdb.models.SqlStoredProcedureCreateUpdateParameters or IO[bytes] - :return: An instance of AsyncLROPoller that returns either SqlStoredProcedureGetResults or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.SqlStoredProcedureGetResults] + :param trigger_name: Cosmos DB trigger name. Required. + :type trigger_name: str + :param create_update_sql_trigger_parameters: The parameters to provide for the current SQL + trigger. Is either a SqlTriggerCreateUpdateParameters type or a IO[bytes] type. Required. + :type create_update_sql_trigger_parameters: + ~azure.mgmt.cosmosdb.models.SqlTriggerCreateUpdateParameters or IO[bytes] + :return: An instance of AsyncLROPoller that returns either SqlTriggerGetResults or the result + of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.SqlTriggerGetResults] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -4267,18 +3949,18 @@ async def begin_create_update_sql_stored_procedure( 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.SqlStoredProcedureGetResults] = kwargs.pop("cls", None) + cls: ClsType[_models.SqlTriggerGetResults] = 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_update_sql_stored_procedure_initial( + raw_result = await self._create_update_sql_trigger_initial( resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, container_name=container_name, - stored_procedure_name=stored_procedure_name, - create_update_sql_stored_procedure_parameters=create_update_sql_stored_procedure_parameters, + trigger_name=trigger_name, + create_update_sql_trigger_parameters=create_update_sql_trigger_parameters, api_version=api_version, content_type=content_type, cls=lambda x, y, z: x, @@ -4290,35 +3972,37 @@ async def begin_create_update_sql_stored_procedure( kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("SqlStoredProcedureGetResults", pipeline_response.http_response) + deserialized = self._deserialize("SqlTriggerGetResults", 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, **kwargs)) + 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.SqlStoredProcedureGetResults].from_continuation_token( + return AsyncLROPoller[_models.SqlTriggerGetResults].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller[_models.SqlStoredProcedureGetResults]( + return AsyncLROPoller[_models.SqlTriggerGetResults]( self._client, raw_result, get_long_running_output, polling_method # type: ignore ) - async def _delete_sql_stored_procedure_initial( + async def _delete_sql_trigger_initial( self, resource_group_name: str, account_name: str, database_name: str, container_name: str, - stored_procedure_name: str, + trigger_name: str, **kwargs: Any ) -> AsyncIterator[bytes]: error_map: MutableMapping = { @@ -4335,12 +4019,12 @@ async def _delete_sql_stored_procedure_initial( 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_sql_stored_procedure_request( + _request = build_delete_sql_trigger_request( resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, container_name=container_name, - stored_procedure_name=stored_procedure_name, + trigger_name=trigger_name, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, @@ -4362,14 +4046,18 @@ async def _delete_sql_stored_procedure_initial( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + 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["azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("azure-AsyncOperation") + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") ) - response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) @@ -4379,16 +4067,16 @@ async def _delete_sql_stored_procedure_initial( return deserialized # type: ignore @distributed_trace_async - async def begin_delete_sql_stored_procedure( + async def begin_delete_sql_trigger( self, resource_group_name: str, account_name: str, database_name: str, container_name: str, - stored_procedure_name: str, + trigger_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: - """Deletes an existing Azure Cosmos DB SQL storedProcedure. + """Deletes an existing Azure Cosmos DB SQL trigger. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -4399,8 +4087,8 @@ async def begin_delete_sql_stored_procedure( :type database_name: str :param container_name: Cosmos DB container name. Required. :type container_name: str - :param stored_procedure_name: Cosmos DB storedProcedure name. Required. - :type stored_procedure_name: str + :param trigger_name: Cosmos DB trigger name. Required. + :type trigger_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: @@ -4414,12 +4102,12 @@ async def begin_delete_sql_stored_procedure( 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_sql_stored_procedure_initial( + raw_result = await self._delete_sql_trigger_initial( resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, container_name=container_name, - stored_procedure_name=stored_procedure_name, + trigger_name=trigger_name, api_version=api_version, cls=lambda x, y, z: x, headers=_headers, @@ -4434,7 +4122,9 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- return cls(pipeline_response, None, {}) # type: ignore if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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: @@ -4520,7 +4210,7 @@ async def extract_data(pipeline_response): list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore - return None, AsyncList(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): _request = prepare_request(next_link) @@ -4533,7 +4223,11 @@ 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response @@ -4602,7 +4296,11 @@ async def get_sql_user_defined_function( if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("SqlUserDefinedFunctionGetResults", pipeline_response.http_response) @@ -4678,14 +4376,19 @@ async def _create_update_sql_user_defined_function_initial( # pylint: disable=n except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + 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["azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("azure-AsyncOperation") + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") ) - response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) @@ -4844,7 +4547,9 @@ def get_long_running_output(pipeline_response): return deserialized if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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: @@ -4904,7 +4609,158 @@ async def _delete_sql_user_defined_function_initial( # pylint: disable=name-too response = pipeline_response.http_response - if response.status_code not in [202, 204]: + 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["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + 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_sql_user_defined_function( + self, + resource_group_name: str, + account_name: str, + database_name: str, + container_name: str, + user_defined_function_name: str, + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Deletes an existing Azure Cosmos DB SQL userDefinedFunction. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param database_name: Cosmos DB database name. Required. + :type database_name: str + :param container_name: Cosmos DB container name. Required. + :type container_name: str + :param user_defined_function_name: Cosmos DB userDefinedFunction name. Required. + :type user_defined_function_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_sql_user_defined_function_initial( + resource_group_name=resource_group_name, + account_name=account_name, + database_name=database_name, + container_name=container_name, + user_defined_function_name=user_defined_function_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 _sql_database_partition_merge_initial( + self, + resource_group_name: str, + account_name: str, + database_name: str, + merge_parameters: Union[_models.MergeParameters, 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(merge_parameters, (IOBase, bytes)): + _content = merge_parameters + else: + _json = self._serialize.body(merge_parameters, "MergeParameters") + + _request = build_sql_database_partition_merge_request( + resource_group_name=resource_group_name, + account_name=account_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): @@ -4914,10 +4770,11 @@ async def _delete_sql_user_defined_function_initial( # pylint: disable=name-too response_headers = {} if response.status_code == 202: - response_headers["azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("azure-AsyncOperation") + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") ) - response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) @@ -4926,17 +4783,80 @@ async def _delete_sql_user_defined_function_initial( # pylint: disable=name-too return deserialized # type: ignore + @overload + async def begin_sql_database_partition_merge( + self, + resource_group_name: str, + account_name: str, + database_name: str, + merge_parameters: _models.MergeParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.PhysicalPartitionStorageInfoCollection]: + """Merges the partitions of a SQL database. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param database_name: Cosmos DB database name. Required. + :type database_name: str + :param merge_parameters: The parameters for the merge operation. Required. + :type merge_parameters: ~azure.mgmt.cosmosdb.models.MergeParameters + :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 + PhysicalPartitionStorageInfoCollection or the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.PhysicalPartitionStorageInfoCollection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_sql_database_partition_merge( + self, + resource_group_name: str, + account_name: str, + database_name: str, + merge_parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.PhysicalPartitionStorageInfoCollection]: + """Merges the partitions of a SQL database. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param database_name: Cosmos DB database name. Required. + :type database_name: str + :param merge_parameters: The parameters for the merge operation. Required. + :type merge_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 + PhysicalPartitionStorageInfoCollection or the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.PhysicalPartitionStorageInfoCollection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + @distributed_trace_async - async def begin_delete_sql_user_defined_function( + async def begin_sql_database_partition_merge( self, resource_group_name: str, account_name: str, database_name: str, - container_name: str, - user_defined_function_name: str, + merge_parameters: Union[_models.MergeParameters, IO[bytes]], **kwargs: Any - ) -> AsyncLROPoller[None]: - """Deletes an existing Azure Cosmos DB SQL userDefinedFunction. + ) -> AsyncLROPoller[_models.PhysicalPartitionStorageInfoCollection]: + """Merges the partitions of a SQL database. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -4945,30 +4865,32 @@ async def begin_delete_sql_user_defined_function( :type account_name: str :param database_name: Cosmos DB database name. Required. :type database_name: str - :param container_name: Cosmos DB container name. Required. - :type container_name: str - :param user_defined_function_name: Cosmos DB userDefinedFunction name. Required. - :type user_defined_function_name: str - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] + :param merge_parameters: The parameters for the merge operation. Is either a MergeParameters + type or a IO[bytes] type. Required. + :type merge_parameters: ~azure.mgmt.cosmosdb.models.MergeParameters or IO[bytes] + :return: An instance of AsyncLROPoller that returns either + PhysicalPartitionStorageInfoCollection or the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.PhysicalPartitionStorageInfoCollection] :raises ~azure.core.exceptions.HttpResponseError: """ - _headers = kwargs.pop("headers", {}) 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)) - cls: ClsType[None] = kwargs.pop("cls", None) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.PhysicalPartitionStorageInfoCollection] = 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_sql_user_defined_function_initial( + raw_result = await self._sql_database_partition_merge_initial( resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, - container_name=container_name, - user_defined_function_name=user_defined_function_name, + merge_parameters=merge_parameters, api_version=api_version, + content_type=content_type, cls=lambda x, y, z: x, headers=_headers, params=_params, @@ -4977,127 +4899,37 @@ async def begin_delete_sql_user_defined_function( 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 + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("PhysicalPartitionStorageInfoCollection", pipeline_response.http_response) if cls: - return cls(pipeline_response, None, {}) # type: ignore + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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( + return AsyncLROPoller[_models.PhysicalPartitionStorageInfoCollection].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_sql_triggers( - self, resource_group_name: str, account_name: str, database_name: str, container_name: str, **kwargs: Any - ) -> AsyncItemPaged["_models.SqlTriggerGetResults"]: - """Lists the SQL trigger under an existing Azure Cosmos DB database account. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param account_name: Cosmos DB database account name. Required. - :type account_name: str - :param database_name: Cosmos DB database name. Required. - :type database_name: str - :param container_name: Cosmos DB container name. Required. - :type container_name: str - :return: An iterator like instance of either SqlTriggerGetResults or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.SqlTriggerGetResults] - :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.SqlTriggerListResult] = 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_sql_triggers_request( - resource_group_name=resource_group_name, - account_name=account_name, - database_name=database_name, - container_name=container_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("SqlTriggerListResult", 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) + return AsyncLROPoller[_models.PhysicalPartitionStorageInfoCollection]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) @distributed_trace_async - async def get_sql_trigger( - self, - resource_group_name: str, - account_name: str, - database_name: str, - container_name: str, - trigger_name: str, - **kwargs: Any - ) -> _models.SqlTriggerGetResults: - """Gets the SQL trigger under an existing Azure Cosmos DB database account. + async def get_sql_database_throughput( + self, resource_group_name: str, account_name: str, database_name: str, **kwargs: Any + ) -> _models.ThroughputSettingsGetResults: + """Gets the RUs per second of the SQL database under an existing Azure Cosmos DB database account + with the provided name. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -5106,12 +4938,8 @@ async def get_sql_trigger( :type account_name: str :param database_name: Cosmos DB database name. Required. :type database_name: str - :param container_name: Cosmos DB container name. Required. - :type container_name: str - :param trigger_name: Cosmos DB trigger name. Required. - :type trigger_name: str - :return: SqlTriggerGetResults or the result of cls(response) - :rtype: ~azure.mgmt.cosmosdb.models.SqlTriggerGetResults + :return: ThroughputSettingsGetResults or the result of cls(response) + :rtype: ~azure.mgmt.cosmosdb.models.ThroughputSettingsGetResults :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -5126,14 +4954,12 @@ async def get_sql_trigger( _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.SqlTriggerGetResults] = kwargs.pop("cls", None) + cls: ClsType[_models.ThroughputSettingsGetResults] = kwargs.pop("cls", None) - _request = build_get_sql_trigger_request( + _request = build_get_sql_database_throughput_request( resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, - container_name=container_name, - trigger_name=trigger_name, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, @@ -5150,23 +4976,25 @@ async def get_sql_trigger( if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("SqlTriggerGetResults", pipeline_response.http_response) + deserialized = self._deserialize("ThroughputSettingsGetResults", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - async def _create_update_sql_trigger_initial( + async def _update_sql_database_throughput_initial( self, resource_group_name: str, account_name: str, database_name: str, - container_name: str, - trigger_name: str, - create_update_sql_trigger_parameters: Union[_models.SqlTriggerCreateUpdateParameters, IO[bytes]], + update_throughput_parameters: Union[_models.ThroughputSettingsUpdateParameters, IO[bytes]], **kwargs: Any ) -> AsyncIterator[bytes]: error_map: MutableMapping = { @@ -5187,17 +5015,15 @@ async def _create_update_sql_trigger_initial( content_type = content_type or "application/json" _json = None _content = None - if isinstance(create_update_sql_trigger_parameters, (IOBase, bytes)): - _content = create_update_sql_trigger_parameters + if isinstance(update_throughput_parameters, (IOBase, bytes)): + _content = update_throughput_parameters else: - _json = self._serialize.body(create_update_sql_trigger_parameters, "SqlTriggerCreateUpdateParameters") + _json = self._serialize.body(update_throughput_parameters, "ThroughputSettingsUpdateParameters") - _request = build_create_update_sql_trigger_request( + _request = build_update_sql_database_throughput_request( resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, - container_name=container_name, - trigger_name=trigger_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, @@ -5222,14 +5048,19 @@ async def _create_update_sql_trigger_initial( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + 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["azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("azure-AsyncOperation") + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") ) - response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) @@ -5239,19 +5070,17 @@ async def _create_update_sql_trigger_initial( return deserialized # type: ignore @overload - async def begin_create_update_sql_trigger( + async def begin_update_sql_database_throughput( self, resource_group_name: str, account_name: str, database_name: str, - container_name: str, - trigger_name: str, - create_update_sql_trigger_parameters: _models.SqlTriggerCreateUpdateParameters, + update_throughput_parameters: _models.ThroughputSettingsUpdateParameters, *, content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller[_models.SqlTriggerGetResults]: - """Create or update an Azure Cosmos DB SQL trigger. + ) -> AsyncLROPoller[_models.ThroughputSettingsGetResults]: + """Update RUs per second of an Azure Cosmos DB SQL database. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -5260,37 +5089,32 @@ async def begin_create_update_sql_trigger( :type account_name: str :param database_name: Cosmos DB database name. Required. :type database_name: str - :param container_name: Cosmos DB container name. Required. - :type container_name: str - :param trigger_name: Cosmos DB trigger name. Required. - :type trigger_name: str - :param create_update_sql_trigger_parameters: The parameters to provide for the current SQL - trigger. Required. - :type create_update_sql_trigger_parameters: - ~azure.mgmt.cosmosdb.models.SqlTriggerCreateUpdateParameters + :param update_throughput_parameters: The parameters to provide for the RUs per second of the + current SQL database. Required. + :type update_throughput_parameters: + ~azure.mgmt.cosmosdb.models.ThroughputSettingsUpdateParameters :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 SqlTriggerGetResults or the result - of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.SqlTriggerGetResults] + :return: An instance of AsyncLROPoller that returns either ThroughputSettingsGetResults or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.ThroughputSettingsGetResults] :raises ~azure.core.exceptions.HttpResponseError: """ @overload - async def begin_create_update_sql_trigger( + async def begin_update_sql_database_throughput( self, resource_group_name: str, account_name: str, database_name: str, - container_name: str, - trigger_name: str, - create_update_sql_trigger_parameters: IO[bytes], + update_throughput_parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller[_models.SqlTriggerGetResults]: - """Create or update an Azure Cosmos DB SQL trigger. + ) -> AsyncLROPoller[_models.ThroughputSettingsGetResults]: + """Update RUs per second of an Azure Cosmos DB SQL database. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -5299,34 +5123,29 @@ async def begin_create_update_sql_trigger( :type account_name: str :param database_name: Cosmos DB database name. Required. :type database_name: str - :param container_name: Cosmos DB container name. Required. - :type container_name: str - :param trigger_name: Cosmos DB trigger name. Required. - :type trigger_name: str - :param create_update_sql_trigger_parameters: The parameters to provide for the current SQL - trigger. Required. - :type create_update_sql_trigger_parameters: IO[bytes] + :param update_throughput_parameters: The parameters to provide for the RUs per second of the + current SQL database. Required. + :type update_throughput_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 SqlTriggerGetResults or the result - of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.SqlTriggerGetResults] + :return: An instance of AsyncLROPoller that returns either ThroughputSettingsGetResults or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.ThroughputSettingsGetResults] :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace_async - async def begin_create_update_sql_trigger( + async def begin_update_sql_database_throughput( self, resource_group_name: str, account_name: str, database_name: str, - container_name: str, - trigger_name: str, - create_update_sql_trigger_parameters: Union[_models.SqlTriggerCreateUpdateParameters, IO[bytes]], + update_throughput_parameters: Union[_models.ThroughputSettingsUpdateParameters, IO[bytes]], **kwargs: Any - ) -> AsyncLROPoller[_models.SqlTriggerGetResults]: - """Create or update an Azure Cosmos DB SQL trigger. + ) -> AsyncLROPoller[_models.ThroughputSettingsGetResults]: + """Update RUs per second of an Azure Cosmos DB SQL database. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -5335,17 +5154,15 @@ async def begin_create_update_sql_trigger( :type account_name: str :param database_name: Cosmos DB database name. Required. :type database_name: str - :param container_name: Cosmos DB container name. Required. - :type container_name: str - :param trigger_name: Cosmos DB trigger name. Required. - :type trigger_name: str - :param create_update_sql_trigger_parameters: The parameters to provide for the current SQL - trigger. Is either a SqlTriggerCreateUpdateParameters type or a IO[bytes] type. Required. - :type create_update_sql_trigger_parameters: - ~azure.mgmt.cosmosdb.models.SqlTriggerCreateUpdateParameters or IO[bytes] - :return: An instance of AsyncLROPoller that returns either SqlTriggerGetResults or the result - of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.SqlTriggerGetResults] + :param update_throughput_parameters: The parameters to provide for the RUs per second of the + current SQL database. Is either a ThroughputSettingsUpdateParameters type or a IO[bytes] type. + Required. + :type update_throughput_parameters: + ~azure.mgmt.cosmosdb.models.ThroughputSettingsUpdateParameters or IO[bytes] + :return: An instance of AsyncLROPoller that returns either ThroughputSettingsGetResults or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.ThroughputSettingsGetResults] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -5353,18 +5170,16 @@ async def begin_create_update_sql_trigger( 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.SqlTriggerGetResults] = kwargs.pop("cls", None) + cls: ClsType[_models.ThroughputSettingsGetResults] = 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_update_sql_trigger_initial( + raw_result = await self._update_sql_database_throughput_initial( resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, - container_name=container_name, - trigger_name=trigger_name, - create_update_sql_trigger_parameters=create_update_sql_trigger_parameters, + update_throughput_parameters=update_throughput_parameters, api_version=api_version, content_type=content_type, cls=lambda x, y, z: x, @@ -5376,36 +5191,32 @@ async def begin_create_update_sql_trigger( kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("SqlTriggerGetResults", pipeline_response.http_response) + deserialized = self._deserialize("ThroughputSettingsGetResults", 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, **kwargs)) + 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.SqlTriggerGetResults].from_continuation_token( + return AsyncLROPoller[_models.ThroughputSettingsGetResults].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller[_models.SqlTriggerGetResults]( + return AsyncLROPoller[_models.ThroughputSettingsGetResults]( self._client, raw_result, get_long_running_output, polling_method # type: ignore ) - async def _delete_sql_trigger_initial( - self, - resource_group_name: str, - account_name: str, - database_name: str, - container_name: str, - trigger_name: str, - **kwargs: Any + async def _migrate_sql_database_to_autoscale_initial( # pylint: disable=name-too-long + self, resource_group_name: str, account_name: str, database_name: str, **kwargs: Any ) -> AsyncIterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -5421,12 +5232,10 @@ async def _delete_sql_trigger_initial( 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_sql_trigger_request( + _request = build_migrate_sql_database_to_autoscale_request( resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, - container_name=container_name, - trigger_name=trigger_name, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, @@ -5442,7 +5251,7 @@ async def _delete_sql_trigger_initial( response = pipeline_response.http_response - if response.status_code not in [202, 204]: + if response.status_code not in [200, 202]: try: await response.read() # Load the body in memory and close the socket except (StreamConsumedError, StreamClosedError): @@ -5452,10 +5261,11 @@ async def _delete_sql_trigger_initial( response_headers = {} if response.status_code == 202: - response_headers["azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("azure-AsyncOperation") + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") ) - response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) @@ -5465,16 +5275,135 @@ async def _delete_sql_trigger_initial( return deserialized # type: ignore @distributed_trace_async - async def begin_delete_sql_trigger( - self, - resource_group_name: str, - account_name: str, - database_name: str, - container_name: str, - trigger_name: str, - **kwargs: Any - ) -> AsyncLROPoller[None]: - """Deletes an existing Azure Cosmos DB SQL trigger. + async def begin_migrate_sql_database_to_autoscale( + self, resource_group_name: str, account_name: str, database_name: str, **kwargs: Any + ) -> AsyncLROPoller[_models.ThroughputSettingsGetResults]: + """Migrate an Azure Cosmos DB SQL database from manual throughput to autoscale. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param database_name: Cosmos DB database name. Required. + :type database_name: str + :return: An instance of AsyncLROPoller that returns either ThroughputSettingsGetResults or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.ThroughputSettingsGetResults] + :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.ThroughputSettingsGetResults] = 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_sql_database_to_autoscale_initial( + resource_group_name=resource_group_name, + account_name=account_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): + deserialized = self._deserialize("ThroughputSettingsGetResults", 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": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.ThroughputSettingsGetResults].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.ThroughputSettingsGetResults]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + async def _migrate_sql_database_to_manual_throughput_initial( # pylint: disable=name-too-long + self, resource_group_name: str, account_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_migrate_sql_database_to_manual_throughput_request( + resource_group_name=resource_group_name, + account_name=account_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 [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) + raise HttpResponseError(response=response, 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.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_migrate_sql_database_to_manual_throughput( # pylint: disable=name-too-long + self, resource_group_name: str, account_name: str, database_name: str, **kwargs: Any + ) -> AsyncLROPoller[_models.ThroughputSettingsGetResults]: + """Migrate an Azure Cosmos DB SQL database from autoscale to manual throughput. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -5483,29 +5412,25 @@ async def begin_delete_sql_trigger( :type account_name: str :param database_name: Cosmos DB database name. Required. :type database_name: str - :param container_name: Cosmos DB container name. Required. - :type container_name: str - :param trigger_name: Cosmos DB trigger name. Required. - :type trigger_name: str - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] + :return: An instance of AsyncLROPoller that returns either ThroughputSettingsGetResults or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.ThroughputSettingsGetResults] :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) + cls: ClsType[_models.ThroughputSettingsGetResults] = 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_sql_trigger_initial( + raw_result = await self._migrate_sql_database_to_manual_throughput_initial( resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, - container_name=container_name, - trigger_name=trigger_name, api_version=api_version, cls=lambda x, y, z: x, headers=_headers, @@ -5515,91 +5440,37 @@ async def begin_delete_sql_trigger( 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 + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("ThroughputSettingsGetResults", pipeline_response.http_response) if cls: - return cls(pipeline_response, None, {}) # type: ignore + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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( + return AsyncLROPoller[_models.ThroughputSettingsGetResults].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_sql_role_definition( - self, role_definition_id: str, resource_group_name: str, account_name: str, **kwargs: Any - ) -> _models.SqlRoleDefinitionGetResults: - """Retrieves the properties of an existing Azure Cosmos DB SQL Role Definition with the given Id. - - :param role_definition_id: The GUID for the Role Definition. Required. - :type role_definition_id: str - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param account_name: Cosmos DB database account name. Required. - :type account_name: str - :return: SqlRoleDefinitionGetResults or the result of cls(response) - :rtype: ~azure.mgmt.cosmosdb.models.SqlRoleDefinitionGetResults - :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.SqlRoleDefinitionGetResults] = kwargs.pop("cls", None) - - _request = build_get_sql_role_definition_request( - role_definition_id=role_definition_id, - resource_group_name=resource_group_name, - account_name=account_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 + return AsyncLROPoller[_models.ThroughputSettingsGetResults]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore ) - 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("SqlRoleDefinitionGetResults", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - async def _create_update_sql_role_definition_initial( # pylint: disable=name-too-long + async def _sql_database_redistribute_throughput_initial( # pylint: disable=name-too-long self, - role_definition_id: str, resource_group_name: str, account_name: str, - create_update_sql_role_definition_parameters: Union[_models.SqlRoleDefinitionCreateUpdateParameters, IO[bytes]], + database_name: str, + redistribute_throughput_parameters: Union[_models.RedistributeThroughputParameters, IO[bytes]], **kwargs: Any ) -> AsyncIterator[bytes]: error_map: MutableMapping = { @@ -5620,17 +5491,15 @@ async def _create_update_sql_role_definition_initial( # pylint: disable=name-to content_type = content_type or "application/json" _json = None _content = None - if isinstance(create_update_sql_role_definition_parameters, (IOBase, bytes)): - _content = create_update_sql_role_definition_parameters + if isinstance(redistribute_throughput_parameters, (IOBase, bytes)): + _content = redistribute_throughput_parameters else: - _json = self._serialize.body( - create_update_sql_role_definition_parameters, "SqlRoleDefinitionCreateUpdateParameters" - ) + _json = self._serialize.body(redistribute_throughput_parameters, "RedistributeThroughputParameters") - _request = build_create_update_sql_role_definition_request( - role_definition_id=role_definition_id, + _request = build_sql_database_redistribute_throughput_request( resource_group_name=resource_group_name, account_name=account_name, + database_name=database_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, @@ -5657,107 +5526,115 @@ async def _create_update_sql_role_definition_initial( # pylint: disable=name-to map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, 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.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @overload - async def begin_create_update_sql_role_definition( + async def begin_sql_database_redistribute_throughput( # pylint: disable=name-too-long self, - role_definition_id: str, resource_group_name: str, account_name: str, - create_update_sql_role_definition_parameters: _models.SqlRoleDefinitionCreateUpdateParameters, + database_name: str, + redistribute_throughput_parameters: _models.RedistributeThroughputParameters, *, content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller[_models.SqlRoleDefinitionGetResults]: - """Creates or updates an Azure Cosmos DB SQL Role Definition. + ) -> AsyncLROPoller[_models.PhysicalPartitionThroughputInfoResult]: + """Redistribute throughput for an Azure Cosmos DB SQL database. - :param role_definition_id: The GUID for the Role Definition. Required. - :type role_definition_id: str :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param create_update_sql_role_definition_parameters: The properties required to create or - update a Role Definition. Required. - :type create_update_sql_role_definition_parameters: - ~azure.mgmt.cosmosdb.models.SqlRoleDefinitionCreateUpdateParameters + :param database_name: Cosmos DB database name. Required. + :type database_name: str + :param redistribute_throughput_parameters: The parameters to provide for redistributing + throughput for the current SQL database. Required. + :type redistribute_throughput_parameters: + ~azure.mgmt.cosmosdb.models.RedistributeThroughputParameters :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 SqlRoleDefinitionGetResults or the - result of cls(response) + :return: An instance of AsyncLROPoller that returns either + PhysicalPartitionThroughputInfoResult or the result of cls(response) :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.SqlRoleDefinitionGetResults] + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.PhysicalPartitionThroughputInfoResult] :raises ~azure.core.exceptions.HttpResponseError: """ @overload - async def begin_create_update_sql_role_definition( + async def begin_sql_database_redistribute_throughput( # pylint: disable=name-too-long self, - role_definition_id: str, resource_group_name: str, account_name: str, - create_update_sql_role_definition_parameters: IO[bytes], + database_name: str, + redistribute_throughput_parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller[_models.SqlRoleDefinitionGetResults]: - """Creates or updates an Azure Cosmos DB SQL Role Definition. + ) -> AsyncLROPoller[_models.PhysicalPartitionThroughputInfoResult]: + """Redistribute throughput for an Azure Cosmos DB SQL database. - :param role_definition_id: The GUID for the Role Definition. Required. - :type role_definition_id: str :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param create_update_sql_role_definition_parameters: The properties required to create or - update a Role Definition. Required. - :type create_update_sql_role_definition_parameters: IO[bytes] + :param database_name: Cosmos DB database name. Required. + :type database_name: str + :param redistribute_throughput_parameters: The parameters to provide for redistributing + throughput for the current SQL database. Required. + :type redistribute_throughput_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 SqlRoleDefinitionGetResults or the - result of cls(response) + :return: An instance of AsyncLROPoller that returns either + PhysicalPartitionThroughputInfoResult or the result of cls(response) :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.SqlRoleDefinitionGetResults] + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.PhysicalPartitionThroughputInfoResult] :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace_async - async def begin_create_update_sql_role_definition( + async def begin_sql_database_redistribute_throughput( # pylint: disable=name-too-long self, - role_definition_id: str, resource_group_name: str, account_name: str, - create_update_sql_role_definition_parameters: Union[_models.SqlRoleDefinitionCreateUpdateParameters, IO[bytes]], + database_name: str, + redistribute_throughput_parameters: Union[_models.RedistributeThroughputParameters, IO[bytes]], **kwargs: Any - ) -> AsyncLROPoller[_models.SqlRoleDefinitionGetResults]: - """Creates or updates an Azure Cosmos DB SQL Role Definition. + ) -> AsyncLROPoller[_models.PhysicalPartitionThroughputInfoResult]: + """Redistribute throughput for an Azure Cosmos DB SQL database. - :param role_definition_id: The GUID for the Role Definition. Required. - :type role_definition_id: str :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param create_update_sql_role_definition_parameters: The properties required to create or - update a Role Definition. Is either a SqlRoleDefinitionCreateUpdateParameters type or a + :param database_name: Cosmos DB database name. Required. + :type database_name: str + :param redistribute_throughput_parameters: The parameters to provide for redistributing + throughput for the current SQL database. Is either a RedistributeThroughputParameters type or a IO[bytes] type. Required. - :type create_update_sql_role_definition_parameters: - ~azure.mgmt.cosmosdb.models.SqlRoleDefinitionCreateUpdateParameters or IO[bytes] - :return: An instance of AsyncLROPoller that returns either SqlRoleDefinitionGetResults or the - result of cls(response) + :type redistribute_throughput_parameters: + ~azure.mgmt.cosmosdb.models.RedistributeThroughputParameters or IO[bytes] + :return: An instance of AsyncLROPoller that returns either + PhysicalPartitionThroughputInfoResult or the result of cls(response) :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.SqlRoleDefinitionGetResults] + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.PhysicalPartitionThroughputInfoResult] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -5765,16 +5642,16 @@ async def begin_create_update_sql_role_definition( 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.SqlRoleDefinitionGetResults] = kwargs.pop("cls", None) + cls: ClsType[_models.PhysicalPartitionThroughputInfoResult] = 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_update_sql_role_definition_initial( - role_definition_id=role_definition_id, + raw_result = await self._sql_database_redistribute_throughput_initial( resource_group_name=resource_group_name, account_name=account_name, - create_update_sql_role_definition_parameters=create_update_sql_role_definition_parameters, + database_name=database_name, + redistribute_throughput_parameters=redistribute_throughput_parameters, api_version=api_version, content_type=content_type, cls=lambda x, y, z: x, @@ -5786,30 +5663,37 @@ async def begin_create_update_sql_role_definition( kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("SqlRoleDefinitionGetResults", pipeline_response.http_response) + deserialized = self._deserialize("PhysicalPartitionThroughputInfoResult", 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, **kwargs)) + 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.SqlRoleDefinitionGetResults].from_continuation_token( + return AsyncLROPoller[_models.PhysicalPartitionThroughputInfoResult].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller[_models.SqlRoleDefinitionGetResults]( + return AsyncLROPoller[_models.PhysicalPartitionThroughputInfoResult]( self._client, raw_result, get_long_running_output, polling_method # type: ignore ) - async def _delete_sql_role_definition_initial( - self, role_definition_id: str, resource_group_name: str, account_name: str, **kwargs: Any + async def _sql_database_retrieve_throughput_distribution_initial( # pylint: disable=name-too-long + self, + resource_group_name: str, + account_name: str, + database_name: str, + retrieve_throughput_parameters: Union[_models.RetrieveThroughputParameters, IO[bytes]], + **kwargs: Any ) -> AsyncIterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -5819,18 +5703,30 @@ async def _delete_sql_role_definition_initial( } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) 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) - _request = build_delete_sql_role_definition_request( - role_definition_id=role_definition_id, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(retrieve_throughput_parameters, (IOBase, bytes)): + _content = retrieve_throughput_parameters + else: + _json = self._serialize.body(retrieve_throughput_parameters, "RetrieveThroughputParameters") + + _request = build_sql_database_retrieve_throughput_distribution_request( resource_group_name=resource_group_name, account_name=account_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, ) @@ -5844,7 +5740,7 @@ async def _delete_sql_role_definition_initial( response = pipeline_response.http_response - if response.status_code not in [200, 202, 204]: + if response.status_code not in [200, 202]: try: await response.read() # Load the body in memory and close the socket except (StreamConsumedError, StreamClosedError): @@ -5852,44 +5748,133 @@ async def _delete_sql_role_definition_initial( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + 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.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_sql_database_retrieve_throughput_distribution( # pylint: disable=name-too-long + self, + resource_group_name: str, + account_name: str, + database_name: str, + retrieve_throughput_parameters: _models.RetrieveThroughputParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.PhysicalPartitionThroughputInfoResult]: + """Retrieve throughput distribution for an Azure Cosmos DB SQL database. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param database_name: Cosmos DB database name. Required. + :type database_name: str + :param retrieve_throughput_parameters: The parameters to provide for retrieving throughput + distribution for the current SQL database. Required. + :type retrieve_throughput_parameters: ~azure.mgmt.cosmosdb.models.RetrieveThroughputParameters + :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 + PhysicalPartitionThroughputInfoResult or the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.PhysicalPartitionThroughputInfoResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + @overload + async def begin_sql_database_retrieve_throughput_distribution( # pylint: disable=name-too-long + self, + resource_group_name: str, + account_name: str, + database_name: str, + retrieve_throughput_parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.PhysicalPartitionThroughputInfoResult]: + """Retrieve throughput distribution for an Azure Cosmos DB SQL database. - return deserialized # type: ignore + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param database_name: Cosmos DB database name. Required. + :type database_name: str + :param retrieve_throughput_parameters: The parameters to provide for retrieving throughput + distribution for the current SQL database. Required. + :type retrieve_throughput_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 + PhysicalPartitionThroughputInfoResult or the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.PhysicalPartitionThroughputInfoResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async - async def begin_delete_sql_role_definition( - self, role_definition_id: str, resource_group_name: str, account_name: str, **kwargs: Any - ) -> AsyncLROPoller[None]: - """Deletes an existing Azure Cosmos DB SQL Role Definition. + async def begin_sql_database_retrieve_throughput_distribution( # pylint: disable=name-too-long + self, + resource_group_name: str, + account_name: str, + database_name: str, + retrieve_throughput_parameters: Union[_models.RetrieveThroughputParameters, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.PhysicalPartitionThroughputInfoResult]: + """Retrieve throughput distribution for an Azure Cosmos DB SQL database. - :param role_definition_id: The GUID for the Role Definition. Required. - :type role_definition_id: str :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param account_name: Cosmos DB database account name. Required. :type account_name: str - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] + :param database_name: Cosmos DB database name. Required. + :type database_name: str + :param retrieve_throughput_parameters: The parameters to provide for retrieving throughput + distribution for the current SQL database. Is either a RetrieveThroughputParameters type or a + IO[bytes] type. Required. + :type retrieve_throughput_parameters: ~azure.mgmt.cosmosdb.models.RetrieveThroughputParameters + or IO[bytes] + :return: An instance of AsyncLROPoller that returns either + PhysicalPartitionThroughputInfoResult or the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.PhysicalPartitionThroughputInfoResult] :raises ~azure.core.exceptions.HttpResponseError: """ - _headers = kwargs.pop("headers", {}) 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)) - cls: ClsType[None] = kwargs.pop("cls", None) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.PhysicalPartitionThroughputInfoResult] = 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_sql_role_definition_initial( - role_definition_id=role_definition_id, + raw_result = await self._sql_database_retrieve_throughput_distribution_initial( resource_group_name=resource_group_name, account_name=account_name, + database_name=database_name, + retrieve_throughput_parameters=retrieve_throughput_parameters, api_version=api_version, + content_type=content_type, cls=lambda x, y, z: x, headers=_headers, params=_params, @@ -5898,47 +5883,53 @@ async def begin_delete_sql_role_definition( 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 + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("PhysicalPartitionThroughputInfoResult", pipeline_response.http_response) if cls: - return cls(pipeline_response, None, {}) # type: ignore + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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( + return AsyncLROPoller[_models.PhysicalPartitionThroughputInfoResult].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 + return AsyncLROPoller[_models.PhysicalPartitionThroughputInfoResult]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) @distributed_trace - def list_sql_role_definitions( + def list_sql_role_assignments( self, resource_group_name: str, account_name: str, **kwargs: Any - ) -> AsyncItemPaged["_models.SqlRoleDefinitionGetResults"]: - """Retrieves the list of all Azure Cosmos DB SQL Role Definitions. + ) -> AsyncItemPaged["_models.SqlRoleAssignmentGetResults"]: + """Retrieves the list of all Azure Cosmos DB SQL Role Assignments. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param account_name: Cosmos DB database account name. Required. :type account_name: str - :return: An iterator like instance of either SqlRoleDefinitionGetResults or the result of + :return: An iterator like instance of either SqlRoleAssignmentGetResults or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.SqlRoleDefinitionGetResults] + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.SqlRoleAssignmentGetResults] :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.SqlRoleDefinitionListResult] = kwargs.pop("cls", None) + cls: ClsType[_models.SqlRoleAssignmentListResult] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -5951,7 +5942,7 @@ def list_sql_role_definitions( def prepare_request(next_link=None): if not next_link: - _request = build_list_sql_role_definitions_request( + _request = build_list_sql_role_assignments_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -5979,11 +5970,11 @@ def prepare_request(next_link=None): return _request async def extract_data(pipeline_response): - deserialized = self._deserialize("SqlRoleDefinitionListResult", pipeline_response) + deserialized = self._deserialize("SqlRoleAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore - return None, AsyncList(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): _request = prepare_request(next_link) @@ -6004,17 +5995,17 @@ async def get_next(next_link=None): @distributed_trace_async async def get_sql_role_assignment( - self, role_assignment_id: str, resource_group_name: str, account_name: str, **kwargs: Any + self, resource_group_name: str, account_name: str, role_assignment_id: str, **kwargs: Any ) -> _models.SqlRoleAssignmentGetResults: """Retrieves the properties of an existing Azure Cosmos DB SQL Role Assignment with the given Id. - :param role_assignment_id: The GUID for the Role Assignment. Required. - :type role_assignment_id: str :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param account_name: Cosmos DB database account name. Required. :type account_name: str + :param role_assignment_id: The GUID for the Role Assignment. Required. + :type role_assignment_id: str :return: SqlRoleAssignmentGetResults or the result of cls(response) :rtype: ~azure.mgmt.cosmosdb.models.SqlRoleAssignmentGetResults :raises ~azure.core.exceptions.HttpResponseError: @@ -6034,9 +6025,9 @@ async def get_sql_role_assignment( cls: ClsType[_models.SqlRoleAssignmentGetResults] = kwargs.pop("cls", None) _request = build_get_sql_role_assignment_request( - role_assignment_id=role_assignment_id, resource_group_name=resource_group_name, account_name=account_name, + role_assignment_id=role_assignment_id, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, @@ -6064,9 +6055,9 @@ async def get_sql_role_assignment( async def _create_update_sql_role_assignment_initial( # pylint: disable=name-too-long self, - role_assignment_id: str, resource_group_name: str, account_name: str, + role_assignment_id: str, create_update_sql_role_assignment_parameters: Union[_models.SqlRoleAssignmentCreateUpdateParameters, IO[bytes]], **kwargs: Any ) -> AsyncIterator[bytes]: @@ -6096,9 +6087,9 @@ async def _create_update_sql_role_assignment_initial( # pylint: disable=name-to ) _request = build_create_update_sql_role_assignment_request( - role_assignment_id=role_assignment_id, resource_group_name=resource_group_name, account_name=account_name, + role_assignment_id=role_assignment_id, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, @@ -6125,19 +6116,24 @@ async def _create_update_sql_role_assignment_initial( # pylint: disable=name-to map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @overload async def begin_create_update_sql_role_assignment( self, - role_assignment_id: str, resource_group_name: str, account_name: str, + role_assignment_id: str, create_update_sql_role_assignment_parameters: _models.SqlRoleAssignmentCreateUpdateParameters, *, content_type: str = "application/json", @@ -6145,13 +6141,13 @@ async def begin_create_update_sql_role_assignment( ) -> AsyncLROPoller[_models.SqlRoleAssignmentGetResults]: """Creates or updates an Azure Cosmos DB SQL Role Assignment. - :param role_assignment_id: The GUID for the Role Assignment. Required. - :type role_assignment_id: str :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param account_name: Cosmos DB database account name. Required. :type account_name: str + :param role_assignment_id: The GUID for the Role Assignment. Required. + :type role_assignment_id: str :param create_update_sql_role_assignment_parameters: The properties required to create or update a Role Assignment. Required. :type create_update_sql_role_assignment_parameters: @@ -6169,9 +6165,9 @@ async def begin_create_update_sql_role_assignment( @overload async def begin_create_update_sql_role_assignment( self, - role_assignment_id: str, resource_group_name: str, account_name: str, + role_assignment_id: str, create_update_sql_role_assignment_parameters: IO[bytes], *, content_type: str = "application/json", @@ -6179,13 +6175,13 @@ async def begin_create_update_sql_role_assignment( ) -> AsyncLROPoller[_models.SqlRoleAssignmentGetResults]: """Creates or updates an Azure Cosmos DB SQL Role Assignment. - :param role_assignment_id: The GUID for the Role Assignment. Required. - :type role_assignment_id: str :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param account_name: Cosmos DB database account name. Required. :type account_name: str + :param role_assignment_id: The GUID for the Role Assignment. Required. + :type role_assignment_id: str :param create_update_sql_role_assignment_parameters: The properties required to create or update a Role Assignment. Required. :type create_update_sql_role_assignment_parameters: IO[bytes] @@ -6202,21 +6198,21 @@ async def begin_create_update_sql_role_assignment( @distributed_trace_async async def begin_create_update_sql_role_assignment( self, - role_assignment_id: str, resource_group_name: str, account_name: str, + role_assignment_id: str, create_update_sql_role_assignment_parameters: Union[_models.SqlRoleAssignmentCreateUpdateParameters, IO[bytes]], **kwargs: Any ) -> AsyncLROPoller[_models.SqlRoleAssignmentGetResults]: """Creates or updates an Azure Cosmos DB SQL Role Assignment. - :param role_assignment_id: The GUID for the Role Assignment. Required. - :type role_assignment_id: str :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param account_name: Cosmos DB database account name. Required. :type account_name: str + :param role_assignment_id: The GUID for the Role Assignment. Required. + :type role_assignment_id: str :param create_update_sql_role_assignment_parameters: The properties required to create or update a Role Assignment. Is either a SqlRoleAssignmentCreateUpdateParameters type or a IO[bytes] type. Required. @@ -6239,9 +6235,9 @@ async def begin_create_update_sql_role_assignment( cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._create_update_sql_role_assignment_initial( - role_assignment_id=role_assignment_id, resource_group_name=resource_group_name, account_name=account_name, + role_assignment_id=role_assignment_id, create_update_sql_role_assignment_parameters=create_update_sql_role_assignment_parameters, api_version=api_version, content_type=content_type, @@ -6260,7 +6256,9 @@ def get_long_running_output(pipeline_response): return deserialized if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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: @@ -6277,7 +6275,7 @@ def get_long_running_output(pipeline_response): ) async def _delete_sql_role_assignment_initial( - self, role_assignment_id: str, resource_group_name: str, account_name: str, **kwargs: Any + self, resource_group_name: str, account_name: str, role_assignment_id: str, **kwargs: Any ) -> AsyncIterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -6294,9 +6292,9 @@ async def _delete_sql_role_assignment_initial( cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) _request = build_delete_sql_role_assignment_request( - role_assignment_id=role_assignment_id, resource_group_name=resource_group_name, account_name=account_name, + role_assignment_id=role_assignment_id, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, @@ -6320,26 +6318,31 @@ async def _delete_sql_role_assignment_initial( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @distributed_trace_async async def begin_delete_sql_role_assignment( - self, role_assignment_id: str, resource_group_name: str, account_name: str, **kwargs: Any + self, resource_group_name: str, account_name: str, role_assignment_id: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Deletes an existing Azure Cosmos DB SQL Role Assignment. - :param role_assignment_id: The GUID for the Role Assignment. Required. - :type role_assignment_id: str :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param account_name: Cosmos DB database account name. Required. :type account_name: str + :param role_assignment_id: The GUID for the Role Assignment. Required. + :type role_assignment_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: @@ -6354,9 +6357,9 @@ async def begin_delete_sql_role_assignment( cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._delete_sql_role_assignment_initial( - role_assignment_id=role_assignment_id, resource_group_name=resource_group_name, account_name=account_name, + role_assignment_id=role_assignment_id, api_version=api_version, cls=lambda x, y, z: x, headers=_headers, @@ -6371,7 +6374,9 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- return cls(pipeline_response, None, {}) # type: ignore if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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: @@ -6386,27 +6391,27 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore @distributed_trace - def list_sql_role_assignments( + def list_sql_role_definitions( self, resource_group_name: str, account_name: str, **kwargs: Any - ) -> AsyncItemPaged["_models.SqlRoleAssignmentGetResults"]: - """Retrieves the list of all Azure Cosmos DB SQL Role Assignments. + ) -> AsyncItemPaged["_models.SqlRoleDefinitionGetResults"]: + """Retrieves the list of all Azure Cosmos DB SQL Role Definitions. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param account_name: Cosmos DB database account name. Required. :type account_name: str - :return: An iterator like instance of either SqlRoleAssignmentGetResults or the result of + :return: An iterator like instance of either SqlRoleDefinitionGetResults or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.SqlRoleAssignmentGetResults] + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.SqlRoleDefinitionGetResults] :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.SqlRoleAssignmentListResult] = kwargs.pop("cls", None) + cls: ClsType[_models.SqlRoleDefinitionListResult] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -6419,7 +6424,7 @@ def list_sql_role_assignments( def prepare_request(next_link=None): if not next_link: - _request = build_list_sql_role_assignments_request( + _request = build_list_sql_role_definitions_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -6447,11 +6452,11 @@ def prepare_request(next_link=None): return _request async def extract_data(pipeline_response): - deserialized = self._deserialize("SqlRoleAssignmentListResult", pipeline_response) + deserialized = self._deserialize("SqlRoleDefinitionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore - return None, AsyncList(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): _request = prepare_request(next_link) @@ -6462,21 +6467,80 @@ async def get_next(next_link=None): ) 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace_async + async def get_sql_role_definition( + self, resource_group_name: str, account_name: str, role_definition_id: str, **kwargs: Any + ) -> _models.SqlRoleDefinitionGetResults: + """Retrieves the properties of an existing Azure Cosmos DB SQL Role Definition with the given Id. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param role_definition_id: The GUID for the Role Definition. Required. + :type role_definition_id: str + :return: SqlRoleDefinitionGetResults or the result of cls(response) + :rtype: ~azure.mgmt.cosmosdb.models.SqlRoleDefinitionGetResults + :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.SqlRoleDefinitionGetResults] = kwargs.pop("cls", None) + + _request = build_get_sql_role_definition_request( + resource_group_name=resource_group_name, + account_name=account_name, + role_definition_id=role_definition_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - return pipeline_response + deserialized = self._deserialize("SqlRoleDefinitionGetResults", pipeline_response.http_response) - return AsyncItemPaged(get_next, extract_data) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore - async def _retrieve_continuous_backup_information_initial( # pylint: disable=name-too-long + return deserialized # type: ignore + + async def _create_update_sql_role_definition_initial( # pylint: disable=name-too-long self, resource_group_name: str, account_name: str, - database_name: str, - container_name: str, - location: Union[_models.ContinuousBackupRestoreLocation, IO[bytes]], + role_definition_id: str, + create_update_sql_role_definition_parameters: Union[_models.SqlRoleDefinitionCreateUpdateParameters, IO[bytes]], **kwargs: Any ) -> AsyncIterator[bytes]: error_map: MutableMapping = { @@ -6497,16 +6561,17 @@ async def _retrieve_continuous_backup_information_initial( # pylint: disable=na content_type = content_type or "application/json" _json = None _content = None - if isinstance(location, (IOBase, bytes)): - _content = location + if isinstance(create_update_sql_role_definition_parameters, (IOBase, bytes)): + _content = create_update_sql_role_definition_parameters else: - _json = self._serialize.body(location, "ContinuousBackupRestoreLocation") + _json = self._serialize.body( + create_update_sql_role_definition_parameters, "SqlRoleDefinitionCreateUpdateParameters" + ) - _request = build_retrieve_continuous_backup_information_request( + _request = build_create_update_sql_role_definition_request( resource_group_name=resource_group_name, account_name=account_name, - database_name=database_name, - container_name=container_name, + role_definition_id=role_definition_id, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, @@ -6533,108 +6598,112 @@ async def _retrieve_continuous_backup_information_initial( # pylint: disable=na map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @overload - async def begin_retrieve_continuous_backup_information( # pylint: disable=name-too-long + async def begin_create_update_sql_role_definition( self, resource_group_name: str, account_name: str, - database_name: str, - container_name: str, - location: _models.ContinuousBackupRestoreLocation, + role_definition_id: str, + create_update_sql_role_definition_parameters: _models.SqlRoleDefinitionCreateUpdateParameters, *, content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller[_models.BackupInformation]: - """Retrieves continuous backup information for a container resource. + ) -> AsyncLROPoller[_models.SqlRoleDefinitionGetResults]: + """Creates or updates an Azure Cosmos DB SQL Role Definition. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param database_name: Cosmos DB database name. Required. - :type database_name: str - :param container_name: Cosmos DB container name. Required. - :type container_name: str - :param location: The name of the continuous backup restore location. Required. - :type location: ~azure.mgmt.cosmosdb.models.ContinuousBackupRestoreLocation + :param role_definition_id: The GUID for the Role Definition. Required. + :type role_definition_id: str + :param create_update_sql_role_definition_parameters: The properties required to create or + update a Role Definition. Required. + :type create_update_sql_role_definition_parameters: + ~azure.mgmt.cosmosdb.models.SqlRoleDefinitionCreateUpdateParameters :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 BackupInformation or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.BackupInformation] + :return: An instance of AsyncLROPoller that returns either SqlRoleDefinitionGetResults or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.SqlRoleDefinitionGetResults] :raises ~azure.core.exceptions.HttpResponseError: """ @overload - async def begin_retrieve_continuous_backup_information( # pylint: disable=name-too-long + async def begin_create_update_sql_role_definition( self, resource_group_name: str, account_name: str, - database_name: str, - container_name: str, - location: IO[bytes], + role_definition_id: str, + create_update_sql_role_definition_parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller[_models.BackupInformation]: - """Retrieves continuous backup information for a container resource. + ) -> AsyncLROPoller[_models.SqlRoleDefinitionGetResults]: + """Creates or updates an Azure Cosmos DB SQL Role Definition. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param database_name: Cosmos DB database name. Required. - :type database_name: str - :param container_name: Cosmos DB container name. Required. - :type container_name: str - :param location: The name of the continuous backup restore location. Required. - :type location: IO[bytes] + :param role_definition_id: The GUID for the Role Definition. Required. + :type role_definition_id: str + :param create_update_sql_role_definition_parameters: The properties required to create or + update a Role Definition. Required. + :type create_update_sql_role_definition_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 BackupInformation or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.BackupInformation] + :return: An instance of AsyncLROPoller that returns either SqlRoleDefinitionGetResults or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.SqlRoleDefinitionGetResults] :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace_async - async def begin_retrieve_continuous_backup_information( # pylint: disable=name-too-long + async def begin_create_update_sql_role_definition( self, resource_group_name: str, account_name: str, - database_name: str, - container_name: str, - location: Union[_models.ContinuousBackupRestoreLocation, IO[bytes]], + role_definition_id: str, + create_update_sql_role_definition_parameters: Union[_models.SqlRoleDefinitionCreateUpdateParameters, IO[bytes]], **kwargs: Any - ) -> AsyncLROPoller[_models.BackupInformation]: - """Retrieves continuous backup information for a container resource. + ) -> AsyncLROPoller[_models.SqlRoleDefinitionGetResults]: + """Creates or updates an Azure Cosmos DB SQL Role Definition. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param database_name: Cosmos DB database name. Required. - :type database_name: str - :param container_name: Cosmos DB container name. Required. - :type container_name: str - :param location: The name of the continuous backup restore location. Is either a - ContinuousBackupRestoreLocation type or a IO[bytes] type. Required. - :type location: ~azure.mgmt.cosmosdb.models.ContinuousBackupRestoreLocation or IO[bytes] - :return: An instance of AsyncLROPoller that returns either BackupInformation or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.BackupInformation] + :param role_definition_id: The GUID for the Role Definition. Required. + :type role_definition_id: str + :param create_update_sql_role_definition_parameters: The properties required to create or + update a Role Definition. Is either a SqlRoleDefinitionCreateUpdateParameters type or a + IO[bytes] type. Required. + :type create_update_sql_role_definition_parameters: + ~azure.mgmt.cosmosdb.models.SqlRoleDefinitionCreateUpdateParameters or IO[bytes] + :return: An instance of AsyncLROPoller that returns either SqlRoleDefinitionGetResults or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.SqlRoleDefinitionGetResults] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -6642,17 +6711,16 @@ async def begin_retrieve_continuous_backup_information( # pylint: disable=name- 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.BackupInformation] = kwargs.pop("cls", None) + cls: ClsType[_models.SqlRoleDefinitionGetResults] = 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._retrieve_continuous_backup_information_initial( + raw_result = await self._create_update_sql_role_definition_initial( resource_group_name=resource_group_name, account_name=account_name, - database_name=database_name, - container_name=container_name, - location=location, + role_definition_id=role_definition_id, + create_update_sql_role_definition_parameters=create_update_sql_role_definition_parameters, api_version=api_version, content_type=content_type, cls=lambda x, y, z: x, @@ -6664,7 +6732,7 @@ async def begin_retrieve_continuous_backup_information( # pylint: disable=name- kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("BackupInformation", pipeline_response.http_response) + deserialized = self._deserialize("SqlRoleDefinitionGetResults", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized @@ -6678,12 +6746,128 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller[_models.BackupInformation].from_continuation_token( + return AsyncLROPoller[_models.SqlRoleDefinitionGetResults].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller[_models.BackupInformation]( + return AsyncLROPoller[_models.SqlRoleDefinitionGetResults]( self._client, raw_result, get_long_running_output, polling_method # type: ignore ) + + async def _delete_sql_role_definition_initial( + self, resource_group_name: str, account_name: str, role_definition_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_sql_role_definition_request( + resource_group_name=resource_group_name, + account_name=account_name, + role_definition_id=role_definition_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 [200, 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + 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_sql_role_definition( + self, resource_group_name: str, account_name: str, role_definition_id: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Deletes an existing Azure Cosmos DB SQL Role Definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param role_definition_id: The GUID for the Role Definition. Required. + :type role_definition_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_sql_role_definition_initial( + resource_group_name=resource_group_name, + account_name=account_name, + role_definition_id=role_definition_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 diff --git a/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/aio/operations/_table_resources_operations.py b/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/aio/operations/_table_resources_operations.py index f1346525866..05584ee8432 100644 --- a/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/aio/operations/_table_resources_operations.py +++ b/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/aio/operations/_table_resources_operations.py @@ -80,25 +80,27 @@ def __init__(self, *args, **kwargs) -> None: self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def list_tables( + def list_table_role_assignments( self, resource_group_name: str, account_name: str, **kwargs: Any - ) -> AsyncItemPaged["_models.TableGetResults"]: - """Lists the Tables under an existing Azure Cosmos DB database account. + ) -> AsyncItemPaged["_models.TableRoleAssignmentResource"]: + """Retrieves the list of all Azure Cosmos DB Table Role Assignments. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param account_name: Cosmos DB database account name. Required. :type account_name: str - :return: An iterator like instance of either TableGetResults or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.TableGetResults] + :return: An iterator like instance of either TableRoleAssignmentResource or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.TableRoleAssignmentResource] :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.TableListResult] = kwargs.pop("cls", None) + cls: ClsType[_models.TableRoleAssignmentListResult] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -111,7 +113,7 @@ def list_tables( def prepare_request(next_link=None): if not next_link: - _request = build_list_tables_request( + _request = build_list_table_role_assignments_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -139,11 +141,11 @@ def prepare_request(next_link=None): return _request async def extract_data(pipeline_response): - deserialized = self._deserialize("TableListResult", pipeline_response) + deserialized = self._deserialize("TableRoleAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore - return None, AsyncList(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): _request = prepare_request(next_link) @@ -156,27 +158,32 @@ 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + 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_table( - self, resource_group_name: str, account_name: str, table_name: str, **kwargs: Any - ) -> _models.TableGetResults: - """Gets the Tables under an existing Azure Cosmos DB database account with the provided name. + async def get_table_role_assignment( + self, resource_group_name: str, account_name: str, role_assignment_id: str, **kwargs: Any + ) -> _models.TableRoleAssignmentResource: + """Retrieves the properties of an existing Azure Cosmos DB Table Role Assignment with the given + Id. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param table_name: Cosmos DB table name. Required. - :type table_name: str - :return: TableGetResults or the result of cls(response) - :rtype: ~azure.mgmt.cosmosdb.models.TableGetResults + :param role_assignment_id: The GUID for the Role Assignment. Required. + :type role_assignment_id: str + :return: TableRoleAssignmentResource or the result of cls(response) + :rtype: ~azure.mgmt.cosmosdb.models.TableRoleAssignmentResource :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -191,12 +198,12 @@ async def get_table( _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.TableGetResults] = kwargs.pop("cls", None) + cls: ClsType[_models.TableRoleAssignmentResource] = kwargs.pop("cls", None) - _request = build_get_table_request( + _request = build_get_table_role_assignment_request( resource_group_name=resource_group_name, account_name=account_name, - table_name=table_name, + role_assignment_id=role_assignment_id, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, @@ -213,21 +220,25 @@ async def get_table( if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("TableGetResults", pipeline_response.http_response) + deserialized = self._deserialize("TableRoleAssignmentResource", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - async def _create_update_table_initial( + async def _create_update_table_role_assignment_initial( # pylint: disable=name-too-long self, resource_group_name: str, account_name: str, - table_name: str, - create_update_table_parameters: Union[_models.TableCreateUpdateParameters, IO[bytes]], + role_assignment_id: str, + create_update_table_role_assignment_parameters: Union[_models.TableRoleAssignmentResource, IO[bytes]], **kwargs: Any ) -> AsyncIterator[bytes]: error_map: MutableMapping = { @@ -248,15 +259,15 @@ async def _create_update_table_initial( content_type = content_type or "application/json" _json = None _content = None - if isinstance(create_update_table_parameters, (IOBase, bytes)): - _content = create_update_table_parameters + if isinstance(create_update_table_role_assignment_parameters, (IOBase, bytes)): + _content = create_update_table_role_assignment_parameters else: - _json = self._serialize.body(create_update_table_parameters, "TableCreateUpdateParameters") + _json = self._serialize.body(create_update_table_role_assignment_parameters, "TableRoleAssignmentResource") - _request = build_create_update_table_request( + _request = build_create_update_table_role_assignment_request( resource_group_name=resource_group_name, account_name=account_name, - table_name=table_name, + role_assignment_id=role_assignment_id, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, @@ -281,14 +292,19 @@ async def _create_update_table_initial( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + 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["azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("azure-AsyncOperation") + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") ) - response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) @@ -298,94 +314,99 @@ async def _create_update_table_initial( return deserialized # type: ignore @overload - async def begin_create_update_table( + async def begin_create_update_table_role_assignment( # pylint: disable=name-too-long self, resource_group_name: str, account_name: str, - table_name: str, - create_update_table_parameters: _models.TableCreateUpdateParameters, + role_assignment_id: str, + create_update_table_role_assignment_parameters: _models.TableRoleAssignmentResource, *, content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller[_models.TableGetResults]: - """Create or update an Azure Cosmos DB Table. + ) -> AsyncLROPoller[_models.TableRoleAssignmentResource]: + """Creates or updates an Azure Cosmos DB Table Role Assignment. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param table_name: Cosmos DB table name. Required. - :type table_name: str - :param create_update_table_parameters: The parameters to provide for the current Table. - Required. - :type create_update_table_parameters: ~azure.mgmt.cosmosdb.models.TableCreateUpdateParameters + :param role_assignment_id: The GUID for the Role Assignment. Required. + :type role_assignment_id: str + :param create_update_table_role_assignment_parameters: The properties required to create or + update a Role Assignment. Required. + :type create_update_table_role_assignment_parameters: + ~azure.mgmt.cosmosdb.models.TableRoleAssignmentResource :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 TableGetResults or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.TableGetResults] + :return: An instance of AsyncLROPoller that returns either TableRoleAssignmentResource or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.TableRoleAssignmentResource] :raises ~azure.core.exceptions.HttpResponseError: """ @overload - async def begin_create_update_table( + async def begin_create_update_table_role_assignment( # pylint: disable=name-too-long self, resource_group_name: str, account_name: str, - table_name: str, - create_update_table_parameters: IO[bytes], + role_assignment_id: str, + create_update_table_role_assignment_parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller[_models.TableGetResults]: - """Create or update an Azure Cosmos DB Table. + ) -> AsyncLROPoller[_models.TableRoleAssignmentResource]: + """Creates or updates an Azure Cosmos DB Table Role Assignment. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param table_name: Cosmos DB table name. Required. - :type table_name: str - :param create_update_table_parameters: The parameters to provide for the current Table. - Required. - :type create_update_table_parameters: IO[bytes] + :param role_assignment_id: The GUID for the Role Assignment. Required. + :type role_assignment_id: str + :param create_update_table_role_assignment_parameters: The properties required to create or + update a Role Assignment. Required. + :type create_update_table_role_assignment_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 TableGetResults or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.TableGetResults] + :return: An instance of AsyncLROPoller that returns either TableRoleAssignmentResource or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.TableRoleAssignmentResource] :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace_async - async def begin_create_update_table( + async def begin_create_update_table_role_assignment( # pylint: disable=name-too-long self, resource_group_name: str, account_name: str, - table_name: str, - create_update_table_parameters: Union[_models.TableCreateUpdateParameters, IO[bytes]], + role_assignment_id: str, + create_update_table_role_assignment_parameters: Union[_models.TableRoleAssignmentResource, IO[bytes]], **kwargs: Any - ) -> AsyncLROPoller[_models.TableGetResults]: - """Create or update an Azure Cosmos DB Table. + ) -> AsyncLROPoller[_models.TableRoleAssignmentResource]: + """Creates or updates an Azure Cosmos DB Table Role Assignment. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param table_name: Cosmos DB table name. Required. - :type table_name: str - :param create_update_table_parameters: The parameters to provide for the current Table. Is - either a TableCreateUpdateParameters type or a IO[bytes] type. Required. - :type create_update_table_parameters: ~azure.mgmt.cosmosdb.models.TableCreateUpdateParameters - or IO[bytes] - :return: An instance of AsyncLROPoller that returns either TableGetResults or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.TableGetResults] + :param role_assignment_id: The GUID for the Role Assignment. Required. + :type role_assignment_id: str + :param create_update_table_role_assignment_parameters: The properties required to create or + update a Role Assignment. Is either a TableRoleAssignmentResource type or a IO[bytes] type. + Required. + :type create_update_table_role_assignment_parameters: + ~azure.mgmt.cosmosdb.models.TableRoleAssignmentResource or IO[bytes] + :return: An instance of AsyncLROPoller that returns either TableRoleAssignmentResource or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.TableRoleAssignmentResource] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -393,16 +414,16 @@ async def begin_create_update_table( 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.TableGetResults] = kwargs.pop("cls", None) + cls: ClsType[_models.TableRoleAssignmentResource] = 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_update_table_initial( + raw_result = await self._create_update_table_role_assignment_initial( resource_group_name=resource_group_name, account_name=account_name, - table_name=table_name, - create_update_table_parameters=create_update_table_parameters, + role_assignment_id=role_assignment_id, + create_update_table_role_assignment_parameters=create_update_table_role_assignment_parameters, api_version=api_version, content_type=content_type, cls=lambda x, y, z: x, @@ -414,30 +435,32 @@ async def begin_create_update_table( kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("TableGetResults", pipeline_response.http_response) + deserialized = self._deserialize("TableRoleAssignmentResource", 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, **kwargs)) + 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.TableGetResults].from_continuation_token( + return AsyncLROPoller[_models.TableRoleAssignmentResource].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller[_models.TableGetResults]( + return AsyncLROPoller[_models.TableRoleAssignmentResource]( self._client, raw_result, get_long_running_output, polling_method # type: ignore ) - async def _delete_table_initial( - self, resource_group_name: str, account_name: str, table_name: str, **kwargs: Any + async def _delete_table_role_assignment_initial( + self, resource_group_name: str, account_name: str, role_assignment_id: str, **kwargs: Any ) -> AsyncIterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -453,10 +476,10 @@ async def _delete_table_initial( 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_table_request( + _request = build_delete_table_role_assignment_request( resource_group_name=resource_group_name, account_name=account_name, - table_name=table_name, + role_assignment_id=role_assignment_id, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, @@ -472,20 +495,24 @@ async def _delete_table_initial( response = pipeline_response.http_response - if response.status_code not in [202, 204]: + if response.status_code not in [200, 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + 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["azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("azure-AsyncOperation") + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") ) - response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) @@ -495,18 +522,18 @@ async def _delete_table_initial( return deserialized # type: ignore @distributed_trace_async - async def begin_delete_table( - self, resource_group_name: str, account_name: str, table_name: str, **kwargs: Any + async def begin_delete_table_role_assignment( + self, resource_group_name: str, account_name: str, role_assignment_id: str, **kwargs: Any ) -> AsyncLROPoller[None]: - """Deletes an existing Azure Cosmos DB Table. + """Deletes an existing Azure Cosmos DB Table Role Assignment. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param table_name: Cosmos DB table name. Required. - :type table_name: str + :param role_assignment_id: The GUID for the Role Assignment. Required. + :type role_assignment_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: @@ -520,10 +547,10 @@ async def begin_delete_table( 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_table_initial( + raw_result = await self._delete_table_role_assignment_initial( resource_group_name=resource_group_name, account_name=account_name, - table_name=table_name, + role_assignment_id=role_assignment_id, api_version=api_version, cls=lambda x, y, z: x, headers=_headers, @@ -538,7 +565,9 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- return cls(pipeline_response, None, {}) # type: ignore if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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: @@ -552,24 +581,29 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- ) return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - @distributed_trace_async - async def get_table_throughput( - self, resource_group_name: str, account_name: str, table_name: str, **kwargs: Any - ) -> _models.ThroughputSettingsGetResults: - """Gets the RUs per second of the Table under an existing Azure Cosmos DB database account with - the provided name. + @distributed_trace + def list_table_role_definitions( + self, resource_group_name: str, account_name: str, **kwargs: Any + ) -> AsyncItemPaged["_models.TableRoleDefinitionResource"]: + """Retrieves the list of all Azure Cosmos DB Table Role Definitions. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param table_name: Cosmos DB table name. Required. - :type table_name: str - :return: ThroughputSettingsGetResults or the result of cls(response) - :rtype: ~azure.mgmt.cosmosdb.models.ThroughputSettingsGetResults + :return: An iterator like instance of either TableRoleDefinitionResource or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.TableRoleDefinitionResource] :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.TableRoleDefinitionListResult] = kwargs.pop("cls", None) + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -578,17 +612,101 @@ async def get_table_throughput( } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + def prepare_request(next_link=None): + if not next_link: - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.ThroughputSettingsGetResults] = kwargs.pop("cls", None) + _request = build_list_table_role_definitions_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) - _request = build_get_table_throughput_request( - resource_group_name=resource_group_name, - account_name=account_name, - table_name=table_name, - subscription_id=self._config.subscription_id, + 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("TableRoleDefinitionListResult", 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_table_role_definition( + self, resource_group_name: str, account_name: str, role_definition_id: str, **kwargs: Any + ) -> _models.TableRoleDefinitionResource: + """Retrieves the properties of an existing Azure Cosmos DB Table Role Definition with the given + Id. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param role_definition_id: The GUID for the Role Definition. Required. + :type role_definition_id: str + :return: TableRoleDefinitionResource or the result of cls(response) + :rtype: ~azure.mgmt.cosmosdb.models.TableRoleDefinitionResource + :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.TableRoleDefinitionResource] = kwargs.pop("cls", None) + + _request = build_get_table_role_definition_request( + resource_group_name=resource_group_name, + account_name=account_name, + role_definition_id=role_definition_id, + subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, params=_params, @@ -604,21 +722,25 @@ async def get_table_throughput( if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("ThroughputSettingsGetResults", pipeline_response.http_response) + deserialized = self._deserialize("TableRoleDefinitionResource", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - async def _update_table_throughput_initial( + async def _create_update_table_role_definition_initial( # pylint: disable=name-too-long self, resource_group_name: str, account_name: str, - table_name: str, - update_throughput_parameters: Union[_models.ThroughputSettingsUpdateParameters, IO[bytes]], + role_definition_id: str, + create_update_table_role_definition_parameters: Union[_models.TableRoleDefinitionResource, IO[bytes]], **kwargs: Any ) -> AsyncIterator[bytes]: error_map: MutableMapping = { @@ -639,15 +761,15 @@ async def _update_table_throughput_initial( content_type = content_type or "application/json" _json = None _content = None - if isinstance(update_throughput_parameters, (IOBase, bytes)): - _content = update_throughput_parameters + if isinstance(create_update_table_role_definition_parameters, (IOBase, bytes)): + _content = create_update_table_role_definition_parameters else: - _json = self._serialize.body(update_throughput_parameters, "ThroughputSettingsUpdateParameters") + _json = self._serialize.body(create_update_table_role_definition_parameters, "TableRoleDefinitionResource") - _request = build_update_table_throughput_request( + _request = build_create_update_table_role_definition_request( resource_group_name=resource_group_name, account_name=account_name, - table_name=table_name, + role_definition_id=role_definition_id, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, @@ -672,14 +794,18 @@ async def _update_table_throughput_initial( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + 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["azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("azure-AsyncOperation") + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") ) - response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) @@ -689,99 +815,99 @@ async def _update_table_throughput_initial( return deserialized # type: ignore @overload - async def begin_update_table_throughput( + async def begin_create_update_table_role_definition( # pylint: disable=name-too-long self, resource_group_name: str, account_name: str, - table_name: str, - update_throughput_parameters: _models.ThroughputSettingsUpdateParameters, + role_definition_id: str, + create_update_table_role_definition_parameters: _models.TableRoleDefinitionResource, *, content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller[_models.ThroughputSettingsGetResults]: - """Update RUs per second of an Azure Cosmos DB Table. + ) -> AsyncLROPoller[_models.TableRoleDefinitionResource]: + """Creates or updates an Azure Cosmos DB Table Role Definition. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param table_name: Cosmos DB table name. Required. - :type table_name: str - :param update_throughput_parameters: The parameters to provide for the RUs per second of the - current Table. Required. - :type update_throughput_parameters: - ~azure.mgmt.cosmosdb.models.ThroughputSettingsUpdateParameters + :param role_definition_id: The GUID for the Role Definition. Required. + :type role_definition_id: str + :param create_update_table_role_definition_parameters: The properties required to create or + update a Role Definition. Required. + :type create_update_table_role_definition_parameters: + ~azure.mgmt.cosmosdb.models.TableRoleDefinitionResource :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 ThroughputSettingsGetResults or the + :return: An instance of AsyncLROPoller that returns either TableRoleDefinitionResource or the result of cls(response) :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.ThroughputSettingsGetResults] + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.TableRoleDefinitionResource] :raises ~azure.core.exceptions.HttpResponseError: """ @overload - async def begin_update_table_throughput( + async def begin_create_update_table_role_definition( # pylint: disable=name-too-long self, resource_group_name: str, account_name: str, - table_name: str, - update_throughput_parameters: IO[bytes], + role_definition_id: str, + create_update_table_role_definition_parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller[_models.ThroughputSettingsGetResults]: - """Update RUs per second of an Azure Cosmos DB Table. + ) -> AsyncLROPoller[_models.TableRoleDefinitionResource]: + """Creates or updates an Azure Cosmos DB Table Role Definition. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param table_name: Cosmos DB table name. Required. - :type table_name: str - :param update_throughput_parameters: The parameters to provide for the RUs per second of the - current Table. Required. - :type update_throughput_parameters: IO[bytes] + :param role_definition_id: The GUID for the Role Definition. Required. + :type role_definition_id: str + :param create_update_table_role_definition_parameters: The properties required to create or + update a Role Definition. Required. + :type create_update_table_role_definition_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 ThroughputSettingsGetResults or the + :return: An instance of AsyncLROPoller that returns either TableRoleDefinitionResource or the result of cls(response) :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.ThroughputSettingsGetResults] + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.TableRoleDefinitionResource] :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace_async - async def begin_update_table_throughput( + async def begin_create_update_table_role_definition( # pylint: disable=name-too-long self, resource_group_name: str, account_name: str, - table_name: str, - update_throughput_parameters: Union[_models.ThroughputSettingsUpdateParameters, IO[bytes]], + role_definition_id: str, + create_update_table_role_definition_parameters: Union[_models.TableRoleDefinitionResource, IO[bytes]], **kwargs: Any - ) -> AsyncLROPoller[_models.ThroughputSettingsGetResults]: - """Update RUs per second of an Azure Cosmos DB Table. + ) -> AsyncLROPoller[_models.TableRoleDefinitionResource]: + """Creates or updates an Azure Cosmos DB Table Role Definition. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param table_name: Cosmos DB table name. Required. - :type table_name: str - :param update_throughput_parameters: The parameters to provide for the RUs per second of the - current Table. Is either a ThroughputSettingsUpdateParameters type or a IO[bytes] type. + :param role_definition_id: The GUID for the Role Definition. Required. + :type role_definition_id: str + :param create_update_table_role_definition_parameters: The properties required to create or + update a Role Definition. Is either a TableRoleDefinitionResource type or a IO[bytes] type. Required. - :type update_throughput_parameters: - ~azure.mgmt.cosmosdb.models.ThroughputSettingsUpdateParameters or IO[bytes] - :return: An instance of AsyncLROPoller that returns either ThroughputSettingsGetResults or the + :type create_update_table_role_definition_parameters: + ~azure.mgmt.cosmosdb.models.TableRoleDefinitionResource or IO[bytes] + :return: An instance of AsyncLROPoller that returns either TableRoleDefinitionResource or the result of cls(response) :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.ThroughputSettingsGetResults] + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.TableRoleDefinitionResource] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -789,16 +915,16 @@ async def begin_update_table_throughput( 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.ThroughputSettingsGetResults] = kwargs.pop("cls", None) + cls: ClsType[_models.TableRoleDefinitionResource] = 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_table_throughput_initial( + raw_result = await self._create_update_table_role_definition_initial( resource_group_name=resource_group_name, account_name=account_name, - table_name=table_name, - update_throughput_parameters=update_throughput_parameters, + role_definition_id=role_definition_id, + create_update_table_role_definition_parameters=create_update_table_role_definition_parameters, api_version=api_version, content_type=content_type, cls=lambda x, y, z: x, @@ -810,30 +936,32 @@ async def begin_update_table_throughput( kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ThroughputSettingsGetResults", pipeline_response.http_response) + deserialized = self._deserialize("TableRoleDefinitionResource", 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, **kwargs)) + 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.ThroughputSettingsGetResults].from_continuation_token( + return AsyncLROPoller[_models.TableRoleDefinitionResource].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller[_models.ThroughputSettingsGetResults]( + return AsyncLROPoller[_models.TableRoleDefinitionResource]( self._client, raw_result, get_long_running_output, polling_method # type: ignore ) - async def _migrate_table_to_autoscale_initial( - self, resource_group_name: str, account_name: str, table_name: str, **kwargs: Any + async def _delete_table_role_definition_initial( + self, resource_group_name: str, account_name: str, role_definition_id: str, **kwargs: Any ) -> AsyncIterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -849,10 +977,10 @@ async def _migrate_table_to_autoscale_initial( 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_migrate_table_to_autoscale_request( + _request = build_delete_table_role_definition_request( resource_group_name=resource_group_name, account_name=account_name, - table_name=table_name, + role_definition_id=role_definition_id, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, @@ -868,20 +996,24 @@ async def _migrate_table_to_autoscale_initial( response = pipeline_response.http_response - if response.status_code not in [200, 202]: + if response.status_code not in [200, 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + 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["azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("azure-AsyncOperation") + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") ) - response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) @@ -891,37 +1023,35 @@ async def _migrate_table_to_autoscale_initial( return deserialized # type: ignore @distributed_trace_async - async def begin_migrate_table_to_autoscale( - self, resource_group_name: str, account_name: str, table_name: str, **kwargs: Any - ) -> AsyncLROPoller[_models.ThroughputSettingsGetResults]: - """Migrate an Azure Cosmos DB Table from manual throughput to autoscale. + async def begin_delete_table_role_definition( + self, resource_group_name: str, account_name: str, role_definition_id: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Deletes an existing Azure Cosmos DB Table Role Definition. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param table_name: Cosmos DB table name. Required. - :type table_name: str - :return: An instance of AsyncLROPoller that returns either ThroughputSettingsGetResults or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.ThroughputSettingsGetResults] + :param role_definition_id: The GUID for the Role Definition. Required. + :type role_definition_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[_models.ThroughputSettingsGetResults] = kwargs.pop("cls", 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._migrate_table_to_autoscale_initial( + raw_result = await self._delete_table_role_definition_initial( resource_group_name=resource_group_name, account_name=account_name, - table_name=table_name, + role_definition_id=role_definition_id, api_version=api_version, cls=lambda x, y, z: x, headers=_headers, @@ -931,32 +1061,48 @@ async def begin_migrate_table_to_autoscale( await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ThroughputSettingsGetResults", pipeline_response.http_response) + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return cls(pipeline_response, None, {}) # type: ignore if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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.ThroughputSettingsGetResults].from_continuation_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[_models.ThroughputSettingsGetResults]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + def list_tables( + self, resource_group_name: str, account_name: str, **kwargs: Any + ) -> AsyncItemPaged["_models.TableGetResults"]: + """Lists the Tables under an existing Azure Cosmos DB database account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :return: An iterator like instance of either TableGetResults or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.TableGetResults] + :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.TableListResult] = kwargs.pop("cls", None) - async def _migrate_table_to_manual_throughput_initial( # pylint: disable=name-too-long - self, resource_group_name: str, account_name: str, table_name: str, **kwargs: Any - ) -> AsyncIterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -965,58 +1111,69 @@ async def _migrate_table_to_manual_throughput_initial( # pylint: disable=name-t } 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) + def prepare_request(next_link=None): + if not next_link: - _request = build_migrate_table_to_manual_throughput_request( - resource_group_name=resource_group_name, - account_name=account_name, - table_name=table_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) + _request = build_list_tables_request( + resource_group_name=resource_group_name, + account_name=account_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 - ) + 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 - response = pipeline_response.http_response + async def extract_data(pipeline_response): + deserialized = self._deserialize("TableListResult", 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) - 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + async def get_next(next_link=None): + _request = prepare_request(next_link) - response_headers = {} - if response.status_code == 202: - response_headers["azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("azure-AsyncOperation") + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs ) - response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response = pipeline_response.http_response - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + 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) - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore + return pipeline_response - return deserialized # type: ignore + return AsyncItemPaged(get_next, extract_data) @distributed_trace_async - async def begin_migrate_table_to_manual_throughput( + async def get_table( self, resource_group_name: str, account_name: str, table_name: str, **kwargs: Any - ) -> AsyncLROPoller[_models.ThroughputSettingsGetResults]: - """Migrate an Azure Cosmos DB Table from autoscale to manual throughput. + ) -> _models.TableGetResults: + """Gets the Tables under an existing Azure Cosmos DB database account with the provided name. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -1025,63 +1182,63 @@ async def begin_migrate_table_to_manual_throughput( :type account_name: str :param table_name: Cosmos DB table name. Required. :type table_name: str - :return: An instance of AsyncLROPoller that returns either ThroughputSettingsGetResults or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.ThroughputSettingsGetResults] + :return: TableGetResults or the result of cls(response) + :rtype: ~azure.mgmt.cosmosdb.models.TableGetResults :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.ThroughputSettingsGetResults] = 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_table_to_manual_throughput_initial( - resource_group_name=resource_group_name, - account_name=account_name, - table_name=table_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) + cls: ClsType[_models.TableGetResults] = kwargs.pop("cls", None) - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ThroughputSettingsGetResults", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + _request = build_get_table_request( + resource_group_name=resource_group_name, + account_name=account_name, + table_name=table_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) - if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[_models.ThroughputSettingsGetResults].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.ThroughputSettingsGetResults]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs ) - async def _retrieve_continuous_backup_information_initial( # pylint: disable=name-too-long + 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("TableGetResults", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + async def _create_update_table_initial( self, resource_group_name: str, account_name: str, table_name: str, - location: Union[_models.ContinuousBackupRestoreLocation, IO[bytes]], + create_update_table_parameters: Union[_models.TableCreateUpdateParameters, IO[bytes]], **kwargs: Any ) -> AsyncIterator[bytes]: error_map: MutableMapping = { @@ -1102,12 +1259,12 @@ async def _retrieve_continuous_backup_information_initial( # pylint: disable=na content_type = content_type or "application/json" _json = None _content = None - if isinstance(location, (IOBase, bytes)): - _content = location + if isinstance(create_update_table_parameters, (IOBase, bytes)): + _content = create_update_table_parameters else: - _json = self._serialize.body(location, "ContinuousBackupRestoreLocation") + _json = self._serialize.body(create_update_table_parameters, "TableCreateUpdateParameters") - _request = build_retrieve_continuous_backup_information_request( + _request = build_create_update_table_request( resource_group_name=resource_group_name, account_name=account_name, table_name=table_name, @@ -1135,27 +1292,39 @@ async def _retrieve_continuous_backup_information_initial( # pylint: disable=na except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + 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["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.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @overload - async def begin_retrieve_continuous_backup_information( # pylint: disable=name-too-long + async def begin_create_update_table( self, resource_group_name: str, account_name: str, table_name: str, - location: _models.ContinuousBackupRestoreLocation, + create_update_table_parameters: _models.TableCreateUpdateParameters, *, content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller[_models.BackupInformation]: - """Retrieves continuous backup information for a table. + ) -> AsyncLROPoller[_models.TableGetResults]: + """Create or update an Azure Cosmos DB Table. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -1164,29 +1333,30 @@ async def begin_retrieve_continuous_backup_information( # pylint: disable=name- :type account_name: str :param table_name: Cosmos DB table name. Required. :type table_name: str - :param location: The name of the continuous backup restore location. Required. - :type location: ~azure.mgmt.cosmosdb.models.ContinuousBackupRestoreLocation + :param create_update_table_parameters: The parameters to provide for the current Table. + Required. + :type create_update_table_parameters: ~azure.mgmt.cosmosdb.models.TableCreateUpdateParameters :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 BackupInformation or the result of + :return: An instance of AsyncLROPoller that returns either TableGetResults or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.BackupInformation] + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.TableGetResults] :raises ~azure.core.exceptions.HttpResponseError: """ @overload - async def begin_retrieve_continuous_backup_information( # pylint: disable=name-too-long + async def begin_create_update_table( self, resource_group_name: str, account_name: str, table_name: str, - location: IO[bytes], + create_update_table_parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller[_models.BackupInformation]: - """Retrieves continuous backup information for a table. + ) -> AsyncLROPoller[_models.TableGetResults]: + """Create or update an Azure Cosmos DB Table. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -1195,27 +1365,28 @@ async def begin_retrieve_continuous_backup_information( # pylint: disable=name- :type account_name: str :param table_name: Cosmos DB table name. Required. :type table_name: str - :param location: The name of the continuous backup restore location. Required. - :type location: IO[bytes] + :param create_update_table_parameters: The parameters to provide for the current Table. + Required. + :type create_update_table_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 BackupInformation or the result of + :return: An instance of AsyncLROPoller that returns either TableGetResults or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.BackupInformation] + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.TableGetResults] :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace_async - async def begin_retrieve_continuous_backup_information( # pylint: disable=name-too-long + async def begin_create_update_table( self, resource_group_name: str, account_name: str, table_name: str, - location: Union[_models.ContinuousBackupRestoreLocation, IO[bytes]], + create_update_table_parameters: Union[_models.TableCreateUpdateParameters, IO[bytes]], **kwargs: Any - ) -> AsyncLROPoller[_models.BackupInformation]: - """Retrieves continuous backup information for a table. + ) -> AsyncLROPoller[_models.TableGetResults]: + """Create or update an Azure Cosmos DB Table. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -1224,12 +1395,13 @@ async def begin_retrieve_continuous_backup_information( # pylint: disable=name- :type account_name: str :param table_name: Cosmos DB table name. Required. :type table_name: str - :param location: The name of the continuous backup restore location. Is either a - ContinuousBackupRestoreLocation type or a IO[bytes] type. Required. - :type location: ~azure.mgmt.cosmosdb.models.ContinuousBackupRestoreLocation or IO[bytes] - :return: An instance of AsyncLROPoller that returns either BackupInformation or the result of + :param create_update_table_parameters: The parameters to provide for the current Table. Is + either a TableCreateUpdateParameters type or a IO[bytes] type. Required. + :type create_update_table_parameters: ~azure.mgmt.cosmosdb.models.TableCreateUpdateParameters + or IO[bytes] + :return: An instance of AsyncLROPoller that returns either TableGetResults or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.BackupInformation] + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.TableGetResults] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -1237,16 +1409,16 @@ async def begin_retrieve_continuous_backup_information( # pylint: disable=name- 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.BackupInformation] = kwargs.pop("cls", None) + cls: ClsType[_models.TableGetResults] = 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._retrieve_continuous_backup_information_initial( + raw_result = await self._create_update_table_initial( resource_group_name=resource_group_name, account_name=account_name, table_name=table_name, - location=location, + create_update_table_parameters=create_update_table_parameters, api_version=api_version, content_type=content_type, cls=lambda x, y, z: x, @@ -1258,7 +1430,7 @@ async def begin_retrieve_continuous_backup_information( # pylint: disable=name- kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("BackupInformation", pipeline_response.http_response) + deserialized = self._deserialize("TableGetResults", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized @@ -1272,88 +1444,18 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller[_models.BackupInformation].from_continuation_token( + return AsyncLROPoller[_models.TableGetResults].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller[_models.BackupInformation]( + return AsyncLROPoller[_models.TableGetResults]( self._client, raw_result, get_long_running_output, polling_method # type: ignore ) - @distributed_trace_async - async def get_table_role_definition( - self, resource_group_name: str, account_name: str, role_definition_id: str, **kwargs: Any - ) -> _models.TableRoleDefinitionResource: - """Retrieves the properties of an existing Azure Cosmos DB Table Role Definition with the given - Id. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param account_name: Cosmos DB database account name. Required. - :type account_name: str - :param role_definition_id: The GUID for the Role Definition. Required. - :type role_definition_id: str - :return: TableRoleDefinitionResource or the result of cls(response) - :rtype: ~azure.mgmt.cosmosdb.models.TableRoleDefinitionResource - :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.TableRoleDefinitionResource] = kwargs.pop("cls", None) - - _request = build_get_table_role_definition_request( - resource_group_name=resource_group_name, - account_name=account_name, - role_definition_id=role_definition_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("TableRoleDefinitionResource", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - async def _create_update_table_role_definition_initial( # pylint: disable=name-too-long - self, - resource_group_name: str, - account_name: str, - role_definition_id: str, - create_update_table_role_definition_parameters: Union[_models.TableRoleDefinitionResource, IO[bytes]], - **kwargs: Any + async def _delete_table_initial( + self, resource_group_name: str, account_name: str, table_name: str, **kwargs: Any ) -> AsyncIterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -1363,30 +1465,18 @@ async def _create_update_table_role_definition_initial( # pylint: disable=name- } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = case_insensitive_dict(kwargs.pop("headers", {}) 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)) - 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(create_update_table_role_definition_parameters, (IOBase, bytes)): - _content = create_update_table_role_definition_parameters - else: - _json = self._serialize.body(create_update_table_role_definition_parameters, "TableRoleDefinitionResource") - - _request = build_create_update_table_role_definition_request( + _request = build_delete_table_request( resource_group_name=resource_group_name, account_name=account_name, - role_definition_id=role_definition_id, + table_name=table_name, subscription_id=self._config.subscription_id, api_version=api_version, - content_type=content_type, - json=_json, - content=_content, headers=_headers, params=_params, ) @@ -1400,7 +1490,7 @@ async def _create_update_table_role_definition_initial( # pylint: disable=name- response = pipeline_response.http_response - if response.status_code not in [200, 202]: + if response.status_code not in [202, 204]: try: await response.read() # Load the body in memory and close the socket except (StreamConsumedError, StreamClosedError): @@ -1414,10 +1504,10 @@ async def _create_update_table_role_definition_initial( # pylint: disable=name- response_headers = {} if response.status_code == 202: - response_headers["azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("azure-AsyncOperation") + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") ) - response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) @@ -1426,119 +1516,37 @@ async def _create_update_table_role_definition_initial( # pylint: disable=name- return deserialized # type: ignore - @overload - async def begin_create_update_table_role_definition( # pylint: disable=name-too-long - self, - resource_group_name: str, - account_name: str, - role_definition_id: str, - create_update_table_role_definition_parameters: _models.TableRoleDefinitionResource, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.TableRoleDefinitionResource]: - """Creates or updates an Azure Cosmos DB Table Role Definition. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param account_name: Cosmos DB database account name. Required. - :type account_name: str - :param role_definition_id: The GUID for the Role Definition. Required. - :type role_definition_id: str - :param create_update_table_role_definition_parameters: The properties required to create or - update a Role Definition. Required. - :type create_update_table_role_definition_parameters: - ~azure.mgmt.cosmosdb.models.TableRoleDefinitionResource - :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 TableRoleDefinitionResource or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.TableRoleDefinitionResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_create_update_table_role_definition( # pylint: disable=name-too-long - self, - resource_group_name: str, - account_name: str, - role_definition_id: str, - create_update_table_role_definition_parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.TableRoleDefinitionResource]: - """Creates or updates an Azure Cosmos DB Table Role Definition. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param account_name: Cosmos DB database account name. Required. - :type account_name: str - :param role_definition_id: The GUID for the Role Definition. Required. - :type role_definition_id: str - :param create_update_table_role_definition_parameters: The properties required to create or - update a Role Definition. Required. - :type create_update_table_role_definition_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 TableRoleDefinitionResource or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.TableRoleDefinitionResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - @distributed_trace_async - async def begin_create_update_table_role_definition( # pylint: disable=name-too-long - self, - resource_group_name: str, - account_name: str, - role_definition_id: str, - create_update_table_role_definition_parameters: Union[_models.TableRoleDefinitionResource, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.TableRoleDefinitionResource]: - """Creates or updates an Azure Cosmos DB Table Role Definition. + async def begin_delete_table( + self, resource_group_name: str, account_name: str, table_name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Deletes an existing Azure Cosmos DB Table. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param role_definition_id: The GUID for the Role Definition. Required. - :type role_definition_id: str - :param create_update_table_role_definition_parameters: The properties required to create or - update a Role Definition. Is either a TableRoleDefinitionResource type or a IO[bytes] type. - Required. - :type create_update_table_role_definition_parameters: - ~azure.mgmt.cosmosdb.models.TableRoleDefinitionResource or IO[bytes] - :return: An instance of AsyncLROPoller that returns either TableRoleDefinitionResource or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.TableRoleDefinitionResource] + :param table_name: Cosmos DB table name. Required. + :type table_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 = case_insensitive_dict(kwargs.pop("headers", {}) 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)) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.TableRoleDefinitionResource] = kwargs.pop("cls", 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._create_update_table_role_definition_initial( + raw_result = await self._delete_table_initial( resource_group_name=resource_group_name, account_name=account_name, - role_definition_id=role_definition_id, - create_update_table_role_definition_parameters=create_update_table_role_definition_parameters, + table_name=table_name, api_version=api_version, - content_type=content_type, cls=lambda x, y, z: x, headers=_headers, params=_params, @@ -1547,31 +1555,34 @@ async def begin_create_update_table_role_definition( # pylint: disable=name-too await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("TableRoleDefinitionResource", pipeline_response.http_response) + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return cls(pipeline_response, None, {}) # type: ignore if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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.TableRoleDefinitionResource].from_continuation_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[_models.TableRoleDefinitionResource]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - async def _delete_table_role_definition_initial( - self, resource_group_name: str, account_name: str, role_definition_id: str, **kwargs: Any + async def _retrieve_continuous_backup_information_initial( # pylint: disable=name-too-long + self, + resource_group_name: str, + account_name: str, + table_name: str, + location: Union[_models.ContinuousBackupRestoreLocation, IO[bytes]], + **kwargs: Any ) -> AsyncIterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -1581,18 +1592,30 @@ async def _delete_table_role_definition_initial( } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) 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) - _request = build_delete_table_role_definition_request( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(location, (IOBase, bytes)): + _content = location + else: + _json = self._serialize.body(location, "ContinuousBackupRestoreLocation") + + _request = build_retrieve_continuous_backup_information_request( resource_group_name=resource_group_name, account_name=account_name, - role_definition_id=role_definition_id, + table_name=table_name, subscription_id=self._config.subscription_id, api_version=api_version, + content_type=content_type, + json=_json, + content=_content, headers=_headers, params=_params, ) @@ -1606,24 +1629,18 @@ async def _delete_table_role_definition_initial( response = pipeline_response.http_response - if response.status_code not in [200, 202, 204]: + 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) + raise HttpResponseError(response=response, 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["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) @@ -1632,37 +1649,111 @@ async def _delete_table_role_definition_initial( return deserialized # type: ignore + @overload + async def begin_retrieve_continuous_backup_information( # pylint: disable=name-too-long + self, + resource_group_name: str, + account_name: str, + table_name: str, + location: _models.ContinuousBackupRestoreLocation, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.BackupInformation]: + """Retrieves continuous backup information for a table. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param table_name: Cosmos DB table name. Required. + :type table_name: str + :param location: The name of the continuous backup restore location. Required. + :type location: ~azure.mgmt.cosmosdb.models.ContinuousBackupRestoreLocation + :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 BackupInformation or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.BackupInformation] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_retrieve_continuous_backup_information( # pylint: disable=name-too-long + self, + resource_group_name: str, + account_name: str, + table_name: str, + location: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.BackupInformation]: + """Retrieves continuous backup information for a table. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param table_name: Cosmos DB table name. Required. + :type table_name: str + :param location: The name of the continuous backup restore location. Required. + :type location: 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 BackupInformation or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.BackupInformation] + :raises ~azure.core.exceptions.HttpResponseError: + """ + @distributed_trace_async - async def begin_delete_table_role_definition( - self, resource_group_name: str, account_name: str, role_definition_id: str, **kwargs: Any - ) -> AsyncLROPoller[None]: - """Deletes an existing Azure Cosmos DB Table Role Definition. + async def begin_retrieve_continuous_backup_information( # pylint: disable=name-too-long + self, + resource_group_name: str, + account_name: str, + table_name: str, + location: Union[_models.ContinuousBackupRestoreLocation, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.BackupInformation]: + """Retrieves continuous backup information for a table. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param role_definition_id: The GUID for the Role Definition. Required. - :type role_definition_id: str - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] + :param table_name: Cosmos DB table name. Required. + :type table_name: str + :param location: The name of the continuous backup restore location. Is either a + ContinuousBackupRestoreLocation type or a IO[bytes] type. Required. + :type location: ~azure.mgmt.cosmosdb.models.ContinuousBackupRestoreLocation or IO[bytes] + :return: An instance of AsyncLROPoller that returns either BackupInformation or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.BackupInformation] :raises ~azure.core.exceptions.HttpResponseError: """ - _headers = kwargs.pop("headers", {}) 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)) - cls: ClsType[None] = kwargs.pop("cls", None) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.BackupInformation] = 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_table_role_definition_initial( + raw_result = await self._retrieve_continuous_backup_information_initial( resource_group_name=resource_group_name, account_name=account_name, - role_definition_id=role_definition_id, + table_name=table_name, + location=location, api_version=api_version, + content_type=content_type, cls=lambda x, y, z: x, headers=_headers, params=_params, @@ -1671,130 +1762,47 @@ async def begin_delete_table_role_definition( 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 + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("BackupInformation", pipeline_response.http_response) if cls: - return cls(pipeline_response, None, {}) # type: ignore + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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( + return AsyncLROPoller[_models.BackupInformation].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_table_role_definitions( - self, resource_group_name: str, account_name: str, **kwargs: Any - ) -> AsyncItemPaged["_models.TableRoleDefinitionResource"]: - """Retrieves the list of all Azure Cosmos DB Table Role Definitions. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param account_name: Cosmos DB database account name. Required. - :type account_name: str - :return: An iterator like instance of either TableRoleDefinitionResource or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.TableRoleDefinitionResource] - :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.TableRoleDefinitionListResult] = 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_table_role_definitions_request( - resource_group_name=resource_group_name, - account_name=account_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("TableRoleDefinitionListResult", 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) + return AsyncLROPoller[_models.BackupInformation]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) @distributed_trace_async - async def get_table_role_assignment( - self, resource_group_name: str, account_name: str, role_assignment_id: str, **kwargs: Any - ) -> _models.TableRoleAssignmentResource: - """Retrieves the properties of an existing Azure Cosmos DB Table Role Assignment with the given - Id. + async def get_table_throughput( + self, resource_group_name: str, account_name: str, table_name: str, **kwargs: Any + ) -> _models.ThroughputSettingsGetResults: + """Gets the RUs per second of the Table under an existing Azure Cosmos DB database account with + the provided name. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param role_assignment_id: The GUID for the Role Assignment. Required. - :type role_assignment_id: str - :return: TableRoleAssignmentResource or the result of cls(response) - :rtype: ~azure.mgmt.cosmosdb.models.TableRoleAssignmentResource + :param table_name: Cosmos DB table name. Required. + :type table_name: str + :return: ThroughputSettingsGetResults or the result of cls(response) + :rtype: ~azure.mgmt.cosmosdb.models.ThroughputSettingsGetResults :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -1809,12 +1817,12 @@ async def get_table_role_assignment( _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.TableRoleAssignmentResource] = kwargs.pop("cls", None) + cls: ClsType[_models.ThroughputSettingsGetResults] = kwargs.pop("cls", None) - _request = build_get_table_role_assignment_request( + _request = build_get_table_throughput_request( resource_group_name=resource_group_name, account_name=account_name, - role_assignment_id=role_assignment_id, + table_name=table_name, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, @@ -1837,19 +1845,19 @@ async def get_table_role_assignment( ) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("TableRoleAssignmentResource", pipeline_response.http_response) + deserialized = self._deserialize("ThroughputSettingsGetResults", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - async def _create_update_table_role_assignment_initial( # pylint: disable=name-too-long + async def _update_table_throughput_initial( self, resource_group_name: str, account_name: str, - role_assignment_id: str, - create_update_table_role_assignment_parameters: Union[_models.TableRoleAssignmentResource, IO[bytes]], + table_name: str, + update_throughput_parameters: Union[_models.ThroughputSettingsUpdateParameters, IO[bytes]], **kwargs: Any ) -> AsyncIterator[bytes]: error_map: MutableMapping = { @@ -1870,15 +1878,15 @@ async def _create_update_table_role_assignment_initial( # pylint: disable=name- content_type = content_type or "application/json" _json = None _content = None - if isinstance(create_update_table_role_assignment_parameters, (IOBase, bytes)): - _content = create_update_table_role_assignment_parameters + if isinstance(update_throughput_parameters, (IOBase, bytes)): + _content = update_throughput_parameters else: - _json = self._serialize.body(create_update_table_role_assignment_parameters, "TableRoleAssignmentResource") + _json = self._serialize.body(update_throughput_parameters, "ThroughputSettingsUpdateParameters") - _request = build_create_update_table_role_assignment_request( + _request = build_update_table_throughput_request( resource_group_name=resource_group_name, account_name=account_name, - role_assignment_id=role_assignment_id, + table_name=table_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, @@ -1911,10 +1919,11 @@ async def _create_update_table_role_assignment_initial( # pylint: disable=name- response_headers = {} if response.status_code == 202: - response_headers["azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("azure-AsyncOperation") + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") ) - response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) @@ -1924,99 +1933,99 @@ async def _create_update_table_role_assignment_initial( # pylint: disable=name- return deserialized # type: ignore @overload - async def begin_create_update_table_role_assignment( # pylint: disable=name-too-long + async def begin_update_table_throughput( self, resource_group_name: str, account_name: str, - role_assignment_id: str, - create_update_table_role_assignment_parameters: _models.TableRoleAssignmentResource, + table_name: str, + update_throughput_parameters: _models.ThroughputSettingsUpdateParameters, *, content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller[_models.TableRoleAssignmentResource]: - """Creates or updates an Azure Cosmos DB Table Role Assignment. + ) -> AsyncLROPoller[_models.ThroughputSettingsGetResults]: + """Update RUs per second of an Azure Cosmos DB Table. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param role_assignment_id: The GUID for the Role Assignment. Required. - :type role_assignment_id: str - :param create_update_table_role_assignment_parameters: The properties required to create or - update a Role Assignment. Required. - :type create_update_table_role_assignment_parameters: - ~azure.mgmt.cosmosdb.models.TableRoleAssignmentResource + :param table_name: Cosmos DB table name. Required. + :type table_name: str + :param update_throughput_parameters: The parameters to provide for the RUs per second of the + current Table. Required. + :type update_throughput_parameters: + ~azure.mgmt.cosmosdb.models.ThroughputSettingsUpdateParameters :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 TableRoleAssignmentResource or the + :return: An instance of AsyncLROPoller that returns either ThroughputSettingsGetResults or the result of cls(response) :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.TableRoleAssignmentResource] + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.ThroughputSettingsGetResults] :raises ~azure.core.exceptions.HttpResponseError: """ @overload - async def begin_create_update_table_role_assignment( # pylint: disable=name-too-long + async def begin_update_table_throughput( self, resource_group_name: str, account_name: str, - role_assignment_id: str, - create_update_table_role_assignment_parameters: IO[bytes], + table_name: str, + update_throughput_parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller[_models.TableRoleAssignmentResource]: - """Creates or updates an Azure Cosmos DB Table Role Assignment. + ) -> AsyncLROPoller[_models.ThroughputSettingsGetResults]: + """Update RUs per second of an Azure Cosmos DB Table. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param role_assignment_id: The GUID for the Role Assignment. Required. - :type role_assignment_id: str - :param create_update_table_role_assignment_parameters: The properties required to create or - update a Role Assignment. Required. - :type create_update_table_role_assignment_parameters: IO[bytes] + :param table_name: Cosmos DB table name. Required. + :type table_name: str + :param update_throughput_parameters: The parameters to provide for the RUs per second of the + current Table. Required. + :type update_throughput_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 TableRoleAssignmentResource or the + :return: An instance of AsyncLROPoller that returns either ThroughputSettingsGetResults or the result of cls(response) :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.TableRoleAssignmentResource] + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.ThroughputSettingsGetResults] :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace_async - async def begin_create_update_table_role_assignment( # pylint: disable=name-too-long + async def begin_update_table_throughput( self, resource_group_name: str, account_name: str, - role_assignment_id: str, - create_update_table_role_assignment_parameters: Union[_models.TableRoleAssignmentResource, IO[bytes]], + table_name: str, + update_throughput_parameters: Union[_models.ThroughputSettingsUpdateParameters, IO[bytes]], **kwargs: Any - ) -> AsyncLROPoller[_models.TableRoleAssignmentResource]: - """Creates or updates an Azure Cosmos DB Table Role Assignment. + ) -> AsyncLROPoller[_models.ThroughputSettingsGetResults]: + """Update RUs per second of an Azure Cosmos DB Table. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param role_assignment_id: The GUID for the Role Assignment. Required. - :type role_assignment_id: str - :param create_update_table_role_assignment_parameters: The properties required to create or - update a Role Assignment. Is either a TableRoleAssignmentResource type or a IO[bytes] type. + :param table_name: Cosmos DB table name. Required. + :type table_name: str + :param update_throughput_parameters: The parameters to provide for the RUs per second of the + current Table. Is either a ThroughputSettingsUpdateParameters type or a IO[bytes] type. Required. - :type create_update_table_role_assignment_parameters: - ~azure.mgmt.cosmosdb.models.TableRoleAssignmentResource or IO[bytes] - :return: An instance of AsyncLROPoller that returns either TableRoleAssignmentResource or the + :type update_throughput_parameters: + ~azure.mgmt.cosmosdb.models.ThroughputSettingsUpdateParameters or IO[bytes] + :return: An instance of AsyncLROPoller that returns either ThroughputSettingsGetResults or the result of cls(response) :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.TableRoleAssignmentResource] + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.ThroughputSettingsGetResults] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -2024,16 +2033,16 @@ async def begin_create_update_table_role_assignment( # pylint: disable=name-too 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.TableRoleAssignmentResource] = kwargs.pop("cls", None) + cls: ClsType[_models.ThroughputSettingsGetResults] = 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_update_table_role_assignment_initial( + raw_result = await self._update_table_throughput_initial( resource_group_name=resource_group_name, account_name=account_name, - role_assignment_id=role_assignment_id, - create_update_table_role_assignment_parameters=create_update_table_role_assignment_parameters, + table_name=table_name, + update_throughput_parameters=update_throughput_parameters, api_version=api_version, content_type=content_type, cls=lambda x, y, z: x, @@ -2045,30 +2054,32 @@ async def begin_create_update_table_role_assignment( # pylint: disable=name-too kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("TableRoleAssignmentResource", pipeline_response.http_response) + deserialized = self._deserialize("ThroughputSettingsGetResults", 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, **kwargs)) + 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.TableRoleAssignmentResource].from_continuation_token( + return AsyncLROPoller[_models.ThroughputSettingsGetResults].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller[_models.TableRoleAssignmentResource]( + return AsyncLROPoller[_models.ThroughputSettingsGetResults]( self._client, raw_result, get_long_running_output, polling_method # type: ignore ) - async def _delete_table_role_assignment_initial( - self, resource_group_name: str, account_name: str, role_assignment_id: str, **kwargs: Any + async def _migrate_table_to_autoscale_initial( + self, resource_group_name: str, account_name: str, table_name: str, **kwargs: Any ) -> AsyncIterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -2084,10 +2095,10 @@ async def _delete_table_role_assignment_initial( 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_table_role_assignment_request( + _request = build_migrate_table_to_autoscale_request( resource_group_name=resource_group_name, account_name=account_name, - role_assignment_id=role_assignment_id, + table_name=table_name, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, @@ -2103,24 +2114,21 @@ async def _delete_table_role_assignment_initial( response = pipeline_response.http_response - if response.status_code not in [200, 202, 204]: + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) response_headers = {} if response.status_code == 202: - response_headers["azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("azure-AsyncOperation") + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") ) - response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) @@ -2130,35 +2138,37 @@ async def _delete_table_role_assignment_initial( return deserialized # type: ignore @distributed_trace_async - async def begin_delete_table_role_assignment( - self, resource_group_name: str, account_name: str, role_assignment_id: str, **kwargs: Any - ) -> AsyncLROPoller[None]: - """Deletes an existing Azure Cosmos DB Table Role Assignment. + async def begin_migrate_table_to_autoscale( + self, resource_group_name: str, account_name: str, table_name: str, **kwargs: Any + ) -> AsyncLROPoller[_models.ThroughputSettingsGetResults]: + """Migrate an Azure Cosmos DB Table from manual throughput to autoscale. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param role_assignment_id: The GUID for the Role Assignment. Required. - :type role_assignment_id: str - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] + :param table_name: Cosmos DB table name. Required. + :type table_name: str + :return: An instance of AsyncLROPoller that returns either ThroughputSettingsGetResults or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.ThroughputSettingsGetResults] :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) + cls: ClsType[_models.ThroughputSettingsGetResults] = 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_table_role_assignment_initial( + raw_result = await self._migrate_table_to_autoscale_initial( resource_group_name=resource_group_name, account_name=account_name, - role_assignment_id=role_assignment_id, + table_name=table_name, api_version=api_version, cls=lambda x, y, z: x, headers=_headers, @@ -2168,48 +2178,34 @@ async def begin_delete_table_role_assignment( 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 + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("ThroughputSettingsGetResults", pipeline_response.http_response) if cls: - return cls(pipeline_response, None, {}) # type: ignore + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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( + return AsyncLROPoller[_models.ThroughputSettingsGetResults].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_table_role_assignments( - self, resource_group_name: str, account_name: str, **kwargs: Any - ) -> AsyncItemPaged["_models.TableRoleAssignmentResource"]: - """Retrieves the list of all Azure Cosmos DB Table Role Assignments. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param account_name: Cosmos DB database account name. Required. - :type account_name: str - :return: An iterator like instance of either TableRoleAssignmentResource or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.TableRoleAssignmentResource] - :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.TableRoleAssignmentListResult] = kwargs.pop("cls", None) + return AsyncLROPoller[_models.ThroughputSettingsGetResults]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + async def _migrate_table_to_manual_throughput_initial( # pylint: disable=name-too-long + self, resource_group_name: str, account_name: str, table_name: str, **kwargs: Any + ) -> AsyncIterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -2218,60 +2214,116 @@ def list_table_role_assignments( } error_map.update(kwargs.pop("error_map", {}) or {}) - def prepare_request(next_link=None): - if not next_link: + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _request = build_list_table_role_assignments_request( - resource_group_name=resource_group_name, - account_name=account_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - 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 + _request = build_migrate_table_to_manual_throughput_request( + resource_group_name=resource_group_name, + account_name=account_name, + table_name=table_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) - async def extract_data(pipeline_response): - deserialized = self._deserialize("TableRoleAssignmentListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return None, AsyncList(list_of_elem) + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) - async def get_next(next_link=None): - _request = prepare_request(next_link) + response = pipeline_response.http_response - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") ) - response = pipeline_response.http_response + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - 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 = response.stream_download(self._client._pipeline, decompress=_decompress) - return pipeline_response + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore - return AsyncItemPaged(get_next, extract_data) + return deserialized # type: ignore + + @distributed_trace_async + async def begin_migrate_table_to_manual_throughput( + self, resource_group_name: str, account_name: str, table_name: str, **kwargs: Any + ) -> AsyncLROPoller[_models.ThroughputSettingsGetResults]: + """Migrate an Azure Cosmos DB Table from autoscale to manual throughput. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param table_name: Cosmos DB table name. Required. + :type table_name: str + :return: An instance of AsyncLROPoller that returns either ThroughputSettingsGetResults or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.ThroughputSettingsGetResults] + :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.ThroughputSettingsGetResults] = 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_table_to_manual_throughput_initial( + resource_group_name=resource_group_name, + account_name=account_name, + table_name=table_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("ThroughputSettingsGetResults", 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": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.ThroughputSettingsGetResults].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.ThroughputSettingsGetResults]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) diff --git a/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/aio/operations/_throughput_pool_account_operations.py b/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/aio/operations/_throughput_pool_account_operations.py index 8f569f1487e..191a67feb77 100644 --- a/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/aio/operations/_throughput_pool_account_operations.py +++ b/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/aio/operations/_throughput_pool_account_operations.py @@ -191,10 +191,17 @@ async def _create_initial( ) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + response_headers = {} + if response.status_code == 201: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @@ -396,10 +403,10 @@ async def _delete_initial( response_headers = {} if response.status_code == 202: - response_headers["azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("azure-AsyncOperation") + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") ) - response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) @@ -453,7 +460,9 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- return cls(pipeline_response, None, {}) # type: ignore if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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: diff --git a/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/aio/operations/_throughput_pool_operations.py b/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/aio/operations/_throughput_pool_operations.py index fcf51ab2ba0..5edfaf2175f 100644 --- a/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/aio/operations/_throughput_pool_operations.py +++ b/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/aio/operations/_throughput_pool_operations.py @@ -186,10 +186,17 @@ async def _create_or_update_initial( ) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + response_headers = {} + if response.status_code == 201: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @@ -394,10 +401,11 @@ async def _update_initial( response_headers = {} if response.status_code == 202: - response_headers["azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("azure-AsyncOperation") + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") ) - response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) @@ -585,10 +593,10 @@ async def _delete_initial( response_headers = {} if response.status_code == 202: - response_headers["azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("azure-AsyncOperation") + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") ) - response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) @@ -638,7 +646,9 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- return cls(pipeline_response, None, {}) # type: ignore if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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: diff --git a/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/models/__init__.py b/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/models/__init__.py index 3e31fe88f07..dc9adbb12ac 100644 --- a/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/models/__init__.py +++ b/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/models/__init__.py @@ -43,7 +43,6 @@ Capability, Capacity, CapacityModeChangeTransitionState, - CassandraClusterDataCenterNodeItem, CassandraClusterPublicStatus, CassandraClusterPublicStatusDataCentersItem, CassandraError, @@ -93,6 +92,7 @@ CommandOutput, CommandPostBody, CommandPublicResource, + ComponentsM9L909SchemasCassandraclusterpublicstatusPropertiesDatacentersItemsPropertiesNodesItems, CompositePath, ComputedProperty, ConflictResolutionPolicy, @@ -128,7 +128,6 @@ DataTransferJobGetResults, DataTransferJobProperties, DataTransferRegionalServiceResource, - DataTransferServiceResource, DataTransferServiceResourceCreateUpdateProperties, DataTransferServiceResourceProperties, DatabaseAccountConnectionString, @@ -145,12 +144,9 @@ DiagnosticLogSettings, ErrorAdditionalInfo, ErrorDetail, - ErrorDetailAutoGenerated, ErrorResponse, ErrorResponseAutoGenerated, - ErrorResponseAutoGenerated2, ExcludedPath, - ExtendedResourceProperties, FailoverPolicies, FailoverPolicy, FleetAnalyticsListResult, @@ -174,7 +170,6 @@ GarnetClusterResourceProperties, GarnetClusterResourcePropertiesEndPointsItem, GraphAPIComputeRegionalServiceResource, - GraphAPIComputeServiceResource, GraphAPIComputeServiceResourceCreateUpdateProperties, GraphAPIComputeServiceResourceProperties, GraphResource, @@ -214,15 +209,13 @@ LocationGetResult, LocationListResult, LocationProperties, - ManagedCassandraARMResourceProperties, ManagedCassandraManagedServiceIdentity, ManagedCassandraReaperStatus, ManagedServiceIdentity, - ManagedServiceIdentityUserAssignedIdentity, + ManagedServiceIdentityUserAssignedIdentities, MaterializedViewDefinition, MaterializedViewDetails, MaterializedViewsBuilderRegionalServiceResource, - MaterializedViewsBuilderServiceResource, MaterializedViewsBuilderServiceResourceCreateUpdateProperties, MaterializedViewsBuilderServiceResourceProperties, MaterializedViewsProperties, @@ -289,7 +282,6 @@ PeriodicModeBackupPolicy, PeriodicModeProperties, Permission, - PermissionAutoGenerated, PhysicalPartitionId, PhysicalPartitionStorageInfo, PhysicalPartitionStorageInfoCollection, @@ -308,16 +300,12 @@ ProvisioningIssue, ProvisioningIssueProperties, ProxyResource, - ProxyResourceAutoGenerated, - ProxyResourceAutoGenerated2, RedistributeThroughputParameters, RedistributeThroughputPropertiesResource, RegionForOnlineOffline, RegionalServiceResource, Resource, ResourceAssociation, - ResourceAutoGenerated, - ResourceAutoGenerated2, ResourceRestoreParameters, RestorableDatabaseAccountGetResult, RestorableDatabaseAccountsListResult, @@ -364,6 +352,17 @@ ServiceResourceCreateUpdateProperties, ServiceResourceListResult, ServiceResourceProperties, + SoftDeleteConfiguration, + SoftDeletedDatabaseAccountGetResult, + SoftDeletedDatabaseAccountResource, + SoftDeletedDatabaseAccountsListResult, + SoftDeletedSqlContainerGetResult, + SoftDeletedSqlContainerResource, + SoftDeletedSqlContainersListResult, + SoftDeletedSqlDatabaseGetResult, + SoftDeletedSqlDatabaseResource, + SoftDeletedSqlDatabasesListResult, + SoftDeletionMetadata, SpatialSpec, SqlContainerCreateUpdateParameters, SqlContainerGetPropertiesOptions, @@ -378,7 +377,6 @@ SqlDatabaseListResult, SqlDatabaseResource, SqlDedicatedGatewayRegionalServiceResource, - SqlDedicatedGatewayServiceResource, SqlDedicatedGatewayServiceResourceCreateUpdateProperties, SqlDedicatedGatewayServiceResourceProperties, SqlRoleAssignmentCreateUpdateParameters, @@ -415,7 +413,6 @@ TableRoleDefinitionResource, ThroughputBucketResource, ThroughputPolicyResource, - ThroughputPoolAccountCreateParameters, ThroughputPoolAccountResource, ThroughputPoolAccountsListResult, ThroughputPoolResource, @@ -426,7 +423,6 @@ ThroughputSettingsResource, ThroughputSettingsUpdateParameters, TrackedResource, - TrackedResourceAutoGenerated, UniqueKey, UniqueKeyPolicy, Usage, @@ -475,6 +471,7 @@ FleetAnalyticsPropertiesStorageLocationType, FleetspacePropertiesFleetspaceApiKind, FleetspacePropertiesServiceTier, + GarnetAuthenticationType, GarnetCacheProvisioningState, IndexKind, IndexingMode, @@ -488,7 +485,6 @@ NetworkAclBypass, NetworkSecurityPerimeterConfigurationProvisioningState, NodeState, - NodeStatus, NotebookWorkspaceName, OperationType, PartitionKind, @@ -504,6 +500,7 @@ ServiceStatus, ServiceType, Severity, + SoftDeleteActionKind, SpatialType, Status, SupportedActions, @@ -548,7 +545,6 @@ "Capability", "Capacity", "CapacityModeChangeTransitionState", - "CassandraClusterDataCenterNodeItem", "CassandraClusterPublicStatus", "CassandraClusterPublicStatusDataCentersItem", "CassandraError", @@ -598,6 +594,7 @@ "CommandOutput", "CommandPostBody", "CommandPublicResource", + "ComponentsM9L909SchemasCassandraclusterpublicstatusPropertiesDatacentersItemsPropertiesNodesItems", "CompositePath", "ComputedProperty", "ConflictResolutionPolicy", @@ -633,7 +630,6 @@ "DataTransferJobGetResults", "DataTransferJobProperties", "DataTransferRegionalServiceResource", - "DataTransferServiceResource", "DataTransferServiceResourceCreateUpdateProperties", "DataTransferServiceResourceProperties", "DatabaseAccountConnectionString", @@ -650,12 +646,9 @@ "DiagnosticLogSettings", "ErrorAdditionalInfo", "ErrorDetail", - "ErrorDetailAutoGenerated", "ErrorResponse", "ErrorResponseAutoGenerated", - "ErrorResponseAutoGenerated2", "ExcludedPath", - "ExtendedResourceProperties", "FailoverPolicies", "FailoverPolicy", "FleetAnalyticsListResult", @@ -679,7 +672,6 @@ "GarnetClusterResourceProperties", "GarnetClusterResourcePropertiesEndPointsItem", "GraphAPIComputeRegionalServiceResource", - "GraphAPIComputeServiceResource", "GraphAPIComputeServiceResourceCreateUpdateProperties", "GraphAPIComputeServiceResourceProperties", "GraphResource", @@ -719,15 +711,13 @@ "LocationGetResult", "LocationListResult", "LocationProperties", - "ManagedCassandraARMResourceProperties", "ManagedCassandraManagedServiceIdentity", "ManagedCassandraReaperStatus", "ManagedServiceIdentity", - "ManagedServiceIdentityUserAssignedIdentity", + "ManagedServiceIdentityUserAssignedIdentities", "MaterializedViewDefinition", "MaterializedViewDetails", "MaterializedViewsBuilderRegionalServiceResource", - "MaterializedViewsBuilderServiceResource", "MaterializedViewsBuilderServiceResourceCreateUpdateProperties", "MaterializedViewsBuilderServiceResourceProperties", "MaterializedViewsProperties", @@ -794,7 +784,6 @@ "PeriodicModeBackupPolicy", "PeriodicModeProperties", "Permission", - "PermissionAutoGenerated", "PhysicalPartitionId", "PhysicalPartitionStorageInfo", "PhysicalPartitionStorageInfoCollection", @@ -813,16 +802,12 @@ "ProvisioningIssue", "ProvisioningIssueProperties", "ProxyResource", - "ProxyResourceAutoGenerated", - "ProxyResourceAutoGenerated2", "RedistributeThroughputParameters", "RedistributeThroughputPropertiesResource", "RegionForOnlineOffline", "RegionalServiceResource", "Resource", "ResourceAssociation", - "ResourceAutoGenerated", - "ResourceAutoGenerated2", "ResourceRestoreParameters", "RestorableDatabaseAccountGetResult", "RestorableDatabaseAccountsListResult", @@ -869,6 +854,17 @@ "ServiceResourceCreateUpdateProperties", "ServiceResourceListResult", "ServiceResourceProperties", + "SoftDeleteConfiguration", + "SoftDeletedDatabaseAccountGetResult", + "SoftDeletedDatabaseAccountResource", + "SoftDeletedDatabaseAccountsListResult", + "SoftDeletedSqlContainerGetResult", + "SoftDeletedSqlContainerResource", + "SoftDeletedSqlContainersListResult", + "SoftDeletedSqlDatabaseGetResult", + "SoftDeletedSqlDatabaseResource", + "SoftDeletedSqlDatabasesListResult", + "SoftDeletionMetadata", "SpatialSpec", "SqlContainerCreateUpdateParameters", "SqlContainerGetPropertiesOptions", @@ -883,7 +879,6 @@ "SqlDatabaseListResult", "SqlDatabaseResource", "SqlDedicatedGatewayRegionalServiceResource", - "SqlDedicatedGatewayServiceResource", "SqlDedicatedGatewayServiceResourceCreateUpdateProperties", "SqlDedicatedGatewayServiceResourceProperties", "SqlRoleAssignmentCreateUpdateParameters", @@ -920,7 +915,6 @@ "TableRoleDefinitionResource", "ThroughputBucketResource", "ThroughputPolicyResource", - "ThroughputPoolAccountCreateParameters", "ThroughputPoolAccountResource", "ThroughputPoolAccountsListResult", "ThroughputPoolResource", @@ -931,7 +925,6 @@ "ThroughputSettingsResource", "ThroughputSettingsUpdateParameters", "TrackedResource", - "TrackedResourceAutoGenerated", "UniqueKey", "UniqueKeyPolicy", "Usage", @@ -977,6 +970,7 @@ "FleetAnalyticsPropertiesStorageLocationType", "FleetspacePropertiesFleetspaceApiKind", "FleetspacePropertiesServiceTier", + "GarnetAuthenticationType", "GarnetCacheProvisioningState", "IndexKind", "IndexingMode", @@ -990,7 +984,6 @@ "NetworkAclBypass", "NetworkSecurityPerimeterConfigurationProvisioningState", "NodeState", - "NodeStatus", "NotebookWorkspaceName", "OperationType", "PartitionKind", @@ -1006,6 +999,7 @@ "ServiceStatus", "ServiceType", "Severity", + "SoftDeleteActionKind", "SpatialType", "Status", "SupportedActions", diff --git a/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/models/_cosmos_db_management_client_enums.py b/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/models/_cosmos_db_management_client_enums.py index 2e0a02d2ebe..24249c2da80 100644 --- a/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/models/_cosmos_db_management_client_enums.py +++ b/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/models/_cosmos_db_management_client_enums.py @@ -20,13 +20,12 @@ class AccessRuleDirection(str, Enum, metaclass=CaseInsensitiveEnumMeta): class AllocationState(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Allocation state of the cluster and data center resources. Active implies the virtual machines - of the cluster are allocated, deallocated implies virtual machines and resources are - deallocated. - """ + """Allocation state of the cluster and data center resources.""" ACTIVE = "Active" + """Active implies the virtual machines of the cluster are allocated.""" DEALLOCATED = "Deallocated" + """Deallocated implies virtual machines and resources are deallocated.""" class AnalyticalStorageSchemaType(str, Enum, metaclass=CaseInsensitiveEnumMeta): @@ -178,6 +177,8 @@ class ContinuousTier(str, Enum, metaclass=CaseInsensitiveEnumMeta): CONTINUOUS7_DAYS = "Continuous7Days" CONTINUOUS30_DAYS = "Continuous30Days" + CONTINUOUS35_DAYS = "Continuous35Days" + """Continuous 35 Days backup tier.""" class CopyJobMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): @@ -242,6 +243,7 @@ class DataTransferComponent(str, Enum, metaclass=CaseInsensitiveEnumMeta): COSMOS_DB_MONGO_V_CORE = "CosmosDBMongoVCore" COSMOS_DB_SQL = "CosmosDBSql" AZURE_BLOB_STORAGE = "AzureBlobStorage" + BASE_COSMOS_DATA_TRANSFER_DATA_SOURCE_SINK = "BaseCosmosDataTransferDataSourceSink" class DataTransferJobMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): @@ -324,15 +326,28 @@ class FleetspacePropertiesServiceTier(str, Enum, metaclass=CaseInsensitiveEnumMe BUSINESS_CRITICAL = "BusinessCritical" +class GarnetAuthenticationType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The authentication method used for the Garnet cluster.""" + + ENTRA = "Entra" + """Microsoft Entra authentication.""" + + class GarnetCacheProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The status of the resource at the time the operation was called.""" CREATING = "Creating" + """Creating""" UPDATING = "Updating" + """Updating""" DELETING = "Deleting" + """Deleting""" SUCCEEDED = "Succeeded" + """Succeeded""" FAILED = "Failed" + """Failed""" CANCELED = "Canceled" + """Canceled""" class IndexingMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): @@ -451,13 +466,6 @@ class NodeState(str, Enum, metaclass=CaseInsensitiveEnumMeta): STOPPED = "Stopped" -class NodeStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Indicates whether the node is functioning or not.""" - - UP = "Up" - DOWN = "Down" - - class NotebookWorkspaceName(str, Enum, metaclass=CaseInsensitiveEnumMeta): """NotebookWorkspaceName.""" @@ -594,6 +602,15 @@ class Severity(str, Enum, metaclass=CaseInsensitiveEnumMeta): ERROR = "Error" +class SoftDeleteActionKind(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """SoftDeleteActionKind.""" + + RESTORE_SOFT_DELETED_RESOURCE = "RestoreSoftDeletedResource" + """Restores the soft-deleted resource to active/online state.""" + PERMANENT_DELETE_RESOURCE = "PermanentDeleteResource" + """Permanently deletes the soft-deleted resource.""" + + class SpatialType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Indicates the spatial type of index.""" @@ -611,11 +628,11 @@ class Status(str, Enum, metaclass=CaseInsensitiveEnumMeta): INTERNALLY_READY = "InternallyReady" ONLINE = "Online" DELETING = "Deleting" - CREATING = "Creating" SUCCEEDED = "Succeeded" FAILED = "Failed" CANCELED = "Canceled" UPDATING = "Updating" + CREATING = "Creating" class SupportedActions(str, Enum, metaclass=CaseInsensitiveEnumMeta): diff --git a/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/models/_models_py3.py b/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/models/_models_py3.py index 6eddd74c895..cfcf331932b 100644 --- a/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/models/_models_py3.py +++ b/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/models/_models_py3.py @@ -147,20 +147,28 @@ class AccountKeyMetadata(_serialization.Model): missing from the object, it means that the last key regeneration was triggered before 2022-06-18. :vartype generation_time: ~datetime.datetime + :ivar approximate_last_usage_time: Approximate time in UTC of the most recent usage of the key + in ISO-8601 format. + If the value is missing from the object, it means there is no recorded data plane + usage for this key. + :vartype approximate_last_usage_time: ~datetime.datetime """ _validation = { "generation_time": {"readonly": True}, + "approximate_last_usage_time": {"readonly": True}, } _attribute_map = { "generation_time": {"key": "generationTime", "type": "iso-8601"}, + "approximate_last_usage_time": {"key": "approximateLastUsageTime", "type": "iso-8601"}, } def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) self.generation_time: Optional[datetime.datetime] = None + self.approximate_last_usage_time: Optional[datetime.datetime] = None class AnalyticalStorageConfiguration(_serialization.Model): @@ -520,7 +528,7 @@ class DataTransferDataSourceSink(_serialization.Model): All required parameters must be populated in order to send to server. :ivar component: Known values are: "CosmosDBCassandra", "CosmosDBMongo", "CosmosDBMongoVCore", - "CosmosDBSql", and "AzureBlobStorage". + "CosmosDBSql", "AzureBlobStorage", and "BaseCosmosDataTransferDataSourceSink". :vartype component: str or ~azure.mgmt.cosmosdb.models.DataTransferComponent """ @@ -552,7 +560,7 @@ class AzureBlobDataTransferDataSourceSink(DataTransferDataSourceSink): All required parameters must be populated in order to send to server. :ivar component: Known values are: "CosmosDBCassandra", "CosmosDBMongo", "CosmosDBMongoVCore", - "CosmosDBSql", and "AzureBlobStorage". + "CosmosDBSql", "AzureBlobStorage", and "BaseCosmosDataTransferDataSourceSink". :vartype component: str or ~azure.mgmt.cosmosdb.models.DataTransferComponent :ivar container_name: Required. :vartype container_name: str @@ -613,24 +621,24 @@ def __init__(self, *, endpoint_url: str, **kwargs: Any) -> None: class BackupInformation(_serialization.Model): """Backup information of a resource. - Variables are only populated by the server, and will be ignored when sending a request. - :ivar continuous_backup_information: Information about the status of continuous backups. :vartype continuous_backup_information: ~azure.mgmt.cosmosdb.models.ContinuousBackupInformation """ - _validation = { - "continuous_backup_information": {"readonly": True}, - } - _attribute_map = { "continuous_backup_information": {"key": "continuousBackupInformation", "type": "ContinuousBackupInformation"}, } - def __init__(self, **kwargs: Any) -> None: - """ """ + def __init__( + self, *, continuous_backup_information: Optional["_models.ContinuousBackupInformation"] = None, **kwargs: Any + ) -> None: + """ + :keyword continuous_backup_information: Information about the status of continuous backups. + :paramtype continuous_backup_information: + ~azure.mgmt.cosmosdb.models.ContinuousBackupInformation + """ super().__init__(**kwargs) - self.continuous_backup_information: Optional["_models.ContinuousBackupInformation"] = None + self.continuous_backup_information = continuous_backup_information class BackupPolicy(_serialization.Model): @@ -891,7 +899,7 @@ class BaseCosmosDataTransferDataSourceSink(DataTransferDataSourceSink): All required parameters must be populated in order to send to server. :ivar component: Known values are: "CosmosDBCassandra", "CosmosDBMongo", "CosmosDBMongoVCore", - "CosmosDBSql", and "AzureBlobStorage". + "CosmosDBSql", "AzureBlobStorage", and "BaseCosmosDataTransferDataSourceSink". :vartype component: str or ~azure.mgmt.cosmosdb.models.DataTransferComponent :ivar remote_account_name: :vartype remote_account_name: str @@ -1145,160 +1153,6 @@ def __init__( self.capacity_mode_last_successful_transition_end_timestamp: Optional[datetime.datetime] = None -class CassandraClusterDataCenterNodeItem(_serialization.Model): - """CassandraClusterDataCenterNodeItem. - - :ivar address: The node's IP address. - :vartype address: str - :ivar state: The state of the node in Cassandra ring. Known values are: "Normal", "Leaving", - "Joining", "Moving", and "Stopped". - :vartype state: str or ~azure.mgmt.cosmosdb.models.NodeState - :ivar status: - :vartype status: str - :ivar cassandra_process_status: Cassandra service status on this node. - :vartype cassandra_process_status: str - :ivar load: The amount of file system data in the data directory (e.g., 47.66 kB), excluding - all content in the snapshots subdirectories. Because all SSTable data files are included, any - data that is not cleaned up (such as TTL-expired cells or tombstones) is counted. - :vartype load: str - :ivar tokens: List of tokens this node covers. - :vartype tokens: list[str] - :ivar size: - :vartype size: int - :ivar host_id: The network ID of the node. - :vartype host_id: str - :ivar rack: The rack this node is part of. - :vartype rack: str - :ivar timestamp: The timestamp when these statistics were captured. - :vartype timestamp: str - :ivar disk_used_kb: The amount of disk used, in kB, of the directory /var/lib/cassandra. - :vartype disk_used_kb: int - :ivar disk_free_kb: The amount of disk free, in kB, of the directory /var/lib/cassandra. - :vartype disk_free_kb: int - :ivar memory_used_kb: Used memory (calculated as total - free - buffers - cache), in kB. - :vartype memory_used_kb: int - :ivar memory_buffers_and_cached_kb: Memory used by kernel buffers (Buffers in /proc/meminfo) - and page cache and slabs (Cached and SReclaimable in /proc/meminfo), in kB. - :vartype memory_buffers_and_cached_kb: int - :ivar memory_free_kb: Unused memory (MemFree and SwapFree in /proc/meminfo), in kB. - :vartype memory_free_kb: int - :ivar memory_total_kb: Total installed memory (MemTotal and SwapTotal in /proc/meminfo), in kB. - :vartype memory_total_kb: int - :ivar cpu_usage: A float representing the current system-wide CPU utilization as a percentage. - :vartype cpu_usage: float - :ivar is_latest_model: If node has been updated to latest model. - :vartype is_latest_model: bool - """ - - _attribute_map = { - "address": {"key": "address", "type": "str"}, - "state": {"key": "state", "type": "str"}, - "status": {"key": "status", "type": "str"}, - "cassandra_process_status": {"key": "cassandraProcessStatus", "type": "str"}, - "load": {"key": "load", "type": "str"}, - "tokens": {"key": "tokens", "type": "[str]"}, - "size": {"key": "size", "type": "int"}, - "host_id": {"key": "hostID", "type": "str"}, - "rack": {"key": "rack", "type": "str"}, - "timestamp": {"key": "timestamp", "type": "str"}, - "disk_used_kb": {"key": "diskUsedKB", "type": "int"}, - "disk_free_kb": {"key": "diskFreeKB", "type": "int"}, - "memory_used_kb": {"key": "memoryUsedKB", "type": "int"}, - "memory_buffers_and_cached_kb": {"key": "memoryBuffersAndCachedKB", "type": "int"}, - "memory_free_kb": {"key": "memoryFreeKB", "type": "int"}, - "memory_total_kb": {"key": "memoryTotalKB", "type": "int"}, - "cpu_usage": {"key": "cpuUsage", "type": "float"}, - "is_latest_model": {"key": "isLatestModel", "type": "bool"}, - } - - def __init__( - self, - *, - address: Optional[str] = None, - state: Optional[Union[str, "_models.NodeState"]] = None, - status: Optional[str] = None, - cassandra_process_status: Optional[str] = None, - load: Optional[str] = None, - tokens: Optional[list[str]] = None, - size: Optional[int] = None, - host_id: Optional[str] = None, - rack: Optional[str] = None, - timestamp: Optional[str] = None, - disk_used_kb: Optional[int] = None, - disk_free_kb: Optional[int] = None, - memory_used_kb: Optional[int] = None, - memory_buffers_and_cached_kb: Optional[int] = None, - memory_free_kb: Optional[int] = None, - memory_total_kb: Optional[int] = None, - cpu_usage: Optional[float] = None, - is_latest_model: Optional[bool] = None, - **kwargs: Any - ) -> None: - """ - :keyword address: The node's IP address. - :paramtype address: str - :keyword state: The state of the node in Cassandra ring. Known values are: "Normal", "Leaving", - "Joining", "Moving", and "Stopped". - :paramtype state: str or ~azure.mgmt.cosmosdb.models.NodeState - :keyword status: - :paramtype status: str - :keyword cassandra_process_status: Cassandra service status on this node. - :paramtype cassandra_process_status: str - :keyword load: The amount of file system data in the data directory (e.g., 47.66 kB), excluding - all content in the snapshots subdirectories. Because all SSTable data files are included, any - data that is not cleaned up (such as TTL-expired cells or tombstones) is counted. - :paramtype load: str - :keyword tokens: List of tokens this node covers. - :paramtype tokens: list[str] - :keyword size: - :paramtype size: int - :keyword host_id: The network ID of the node. - :paramtype host_id: str - :keyword rack: The rack this node is part of. - :paramtype rack: str - :keyword timestamp: The timestamp when these statistics were captured. - :paramtype timestamp: str - :keyword disk_used_kb: The amount of disk used, in kB, of the directory /var/lib/cassandra. - :paramtype disk_used_kb: int - :keyword disk_free_kb: The amount of disk free, in kB, of the directory /var/lib/cassandra. - :paramtype disk_free_kb: int - :keyword memory_used_kb: Used memory (calculated as total - free - buffers - cache), in kB. - :paramtype memory_used_kb: int - :keyword memory_buffers_and_cached_kb: Memory used by kernel buffers (Buffers in /proc/meminfo) - and page cache and slabs (Cached and SReclaimable in /proc/meminfo), in kB. - :paramtype memory_buffers_and_cached_kb: int - :keyword memory_free_kb: Unused memory (MemFree and SwapFree in /proc/meminfo), in kB. - :paramtype memory_free_kb: int - :keyword memory_total_kb: Total installed memory (MemTotal and SwapTotal in /proc/meminfo), in - kB. - :paramtype memory_total_kb: int - :keyword cpu_usage: A float representing the current system-wide CPU utilization as a - percentage. - :paramtype cpu_usage: float - :keyword is_latest_model: If node has been updated to latest model. - :paramtype is_latest_model: bool - """ - super().__init__(**kwargs) - self.address = address - self.state = state - self.status = status - self.cassandra_process_status = cassandra_process_status - self.load = load - self.tokens = tokens - self.size = size - self.host_id = host_id - self.rack = rack - self.timestamp = timestamp - self.disk_used_kb = disk_used_kb - self.disk_free_kb = disk_free_kb - self.memory_used_kb = memory_used_kb - self.memory_buffers_and_cached_kb = memory_buffers_and_cached_kb - self.memory_free_kb = memory_free_kb - self.memory_total_kb = memory_total_kb - self.cpu_usage = cpu_usage - self.is_latest_model = is_latest_model - - class CassandraClusterPublicStatus(_serialization.Model): """Properties of a managed Cassandra cluster public status. @@ -1366,13 +1220,17 @@ class CassandraClusterPublicStatusDataCentersItem(_serialization.Model): # pyli :ivar seed_nodes: A list of all seed nodes in the cluster, managed and unmanaged. :vartype seed_nodes: list[str] :ivar nodes: - :vartype nodes: list[~azure.mgmt.cosmosdb.models.CassandraClusterDataCenterNodeItem] + :vartype nodes: + list[~azure.mgmt.cosmosdb.models.ComponentsM9L909SchemasCassandraclusterpublicstatusPropertiesDatacentersItemsPropertiesNodesItems] """ _attribute_map = { "name": {"key": "name", "type": "str"}, "seed_nodes": {"key": "seedNodes", "type": "[str]"}, - "nodes": {"key": "nodes", "type": "[CassandraClusterDataCenterNodeItem]"}, + "nodes": { + "key": "nodes", + "type": "[ComponentsM9L909SchemasCassandraclusterpublicstatusPropertiesDatacentersItemsPropertiesNodesItems]", + }, } def __init__( @@ -1380,7 +1238,11 @@ def __init__( *, name: Optional[str] = None, seed_nodes: Optional[list[str]] = None, - nodes: Optional[list["_models.CassandraClusterDataCenterNodeItem"]] = None, + nodes: Optional[ + list[ + "_models.ComponentsM9L909SchemasCassandraclusterpublicstatusPropertiesDatacentersItemsPropertiesNodesItems" + ] + ] = None, **kwargs: Any ) -> None: """ @@ -1389,7 +1251,8 @@ def __init__( :keyword seed_nodes: A list of all seed nodes in the cluster, managed and unmanaged. :paramtype seed_nodes: list[str] :keyword nodes: - :paramtype nodes: list[~azure.mgmt.cosmosdb.models.CassandraClusterDataCenterNodeItem] + :paramtype nodes: + list[~azure.mgmt.cosmosdb.models.ComponentsM9L909SchemasCassandraclusterpublicstatusPropertiesDatacentersItemsPropertiesNodesItems] """ super().__init__(**kwargs) self.name = name @@ -1570,41 +1433,6 @@ class CassandraKeyspaceGetPropertiesOptions(OptionsResource): """ -class ExtendedResourceProperties(_serialization.Model): - """The system generated resource properties associated with SQL databases, SQL containers, Gremlin - databases and Gremlin graphs. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar rid: A system generated property. A unique identifier. - :vartype rid: str - :ivar ts: A system generated property that denotes the last updated timestamp of the resource. - :vartype ts: float - :ivar etag: A system generated property representing the resource etag required for optimistic - concurrency control. - :vartype etag: str - """ - - _validation = { - "rid": {"readonly": True}, - "ts": {"readonly": True}, - "etag": {"readonly": True}, - } - - _attribute_map = { - "rid": {"key": "_rid", "type": "str"}, - "ts": {"key": "_ts", "type": "float"}, - "etag": {"key": "_etag", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.rid: Optional[str] = None - self.ts: Optional[float] = None - self.etag: Optional[str] = None - - class CassandraKeyspaceResource(_serialization.Model): """Cosmos DB Cassandra keyspace resource object. @@ -1631,13 +1459,15 @@ def __init__(self, *, id: str, **kwargs: Any) -> None: # pylint: disable=redefi self.id = id -class CassandraKeyspaceGetPropertiesResource(CassandraKeyspaceResource, ExtendedResourceProperties): +class CassandraKeyspaceGetPropertiesResource(CassandraKeyspaceResource): """CassandraKeyspaceGetPropertiesResource. 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: Name of the Cosmos DB Cassandra keyspace. Required. + :vartype id: str :ivar rid: A system generated property. A unique identifier. :vartype rid: str :ivar ts: A system generated property that denotes the last updated timestamp of the resource. @@ -1645,22 +1475,20 @@ class CassandraKeyspaceGetPropertiesResource(CassandraKeyspaceResource, Extended :ivar etag: A system generated property representing the resource etag required for optimistic concurrency control. :vartype etag: str - :ivar id: Name of the Cosmos DB Cassandra keyspace. Required. - :vartype id: str """ _validation = { + "id": {"required": True}, "rid": {"readonly": True}, "ts": {"readonly": True}, "etag": {"readonly": True}, - "id": {"required": True}, } _attribute_map = { + "id": {"key": "id", "type": "str"}, "rid": {"key": "_rid", "type": "str"}, "ts": {"key": "_ts", "type": "float"}, "etag": {"key": "_etag", "type": "str"}, - "id": {"key": "id", "type": "str"}, } def __init__(self, *, id: str, **kwargs: Any) -> None: # pylint: disable=redefined-builtin @@ -1672,74 +1500,111 @@ def __init__(self, *, id: str, **kwargs: Any) -> None: # pylint: disable=redefi self.rid: Optional[str] = None self.ts: Optional[float] = None self.etag: Optional[str] = None - self.id = id -class CassandraKeyspaceGetResults(ARMResourceProperties): - """An Azure Cosmos DB Cassandra keyspace. +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: The unique resource identifier of the ARM resource. + :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 ARM resource. + :ivar name: The name of the resource. :vartype name: str - :ivar type: The type of Azure resource. + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". :vartype type: str - :ivar location: The location of the resource group to which the resource belongs. - :vartype location: str - :ivar tags: Tags are a list of key-value pairs that describe the resource. These tags can be - used in viewing and grouping this resource (across resource groups). A maximum of 15 tags can - be provided for a resource. Each tag must have a key no greater than 128 characters and value - no greater than 256 characters. For example, the default experience for a template type is set - with "defaultExperience": "Cassandra". Current "defaultExperience" values also include "Table", - "Graph", "DocumentDB", and "MongoDB". - :vartype tags: dict[str, str] - :ivar identity: Identity for the resource. - :vartype identity: ~azure.mgmt.cosmosdb.models.ManagedServiceIdentity - :ivar resource: - :vartype resource: ~azure.mgmt.cosmosdb.models.CassandraKeyspaceGetPropertiesResource - :ivar options: - :vartype options: ~azure.mgmt.cosmosdb.models.CassandraKeyspaceGetPropertiesOptions + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.cosmosdb.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"}, - "location": {"key": "location", "type": "str"}, - "tags": {"key": "tags", "type": "{str}"}, - "identity": {"key": "identity", "type": "ManagedServiceIdentity"}, - "resource": {"key": "properties.resource", "type": "CassandraKeyspaceGetPropertiesResource"}, - "options": {"key": "properties.options", "type": "CassandraKeyspaceGetPropertiesOptions"}, + "system_data": {"key": "systemData", "type": "SystemData"}, } - def __init__( - self, - *, - location: Optional[str] = None, - tags: Optional[dict[str, str]] = None, - identity: Optional["_models.ManagedServiceIdentity"] = None, - resource: Optional["_models.CassandraKeyspaceGetPropertiesResource"] = None, - options: Optional["_models.CassandraKeyspaceGetPropertiesOptions"] = None, - **kwargs: Any - ) -> None: - """ - :keyword location: The location of the resource group to which the resource belongs. - :paramtype location: str - :keyword tags: Tags are a list of key-value pairs that describe the resource. These tags can be - used in viewing and grouping this resource (across resource groups). A maximum of 15 tags can - be provided for a resource. Each tag must have a key no greater than 128 characters and value - no greater than 256 characters. For example, the default experience for a template type is set - with "defaultExperience": "Cassandra". Current "defaultExperience" values also include "Table", - "Graph", "DocumentDB", and "MongoDB". + 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 CassandraKeyspaceGetResults(Resource): + """An Azure Cosmos DB Cassandra keyspace. + + 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.cosmosdb.models.SystemData + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + :ivar location: The geo-location where the resource lives. + :vartype location: str + :ivar identity: Identity for the resource. + :vartype identity: ~azure.mgmt.cosmosdb.models.ManagedServiceIdentity + :ivar resource: + :vartype resource: ~azure.mgmt.cosmosdb.models.CassandraKeyspaceGetPropertiesResource + :ivar options: + :vartype options: ~azure.mgmt.cosmosdb.models.CassandraKeyspaceGetPropertiesOptions + """ + + _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"}, + "tags": {"key": "tags", "type": "{str}"}, + "location": {"key": "location", "type": "str"}, + "identity": {"key": "identity", "type": "ManagedServiceIdentity"}, + "resource": {"key": "properties.resource", "type": "CassandraKeyspaceGetPropertiesResource"}, + "options": {"key": "properties.options", "type": "CassandraKeyspaceGetPropertiesOptions"}, + } + + def __init__( + self, + *, + tags: Optional[dict[str, str]] = None, + location: Optional[str] = None, + identity: Optional["_models.ManagedServiceIdentity"] = None, + resource: Optional["_models.CassandraKeyspaceGetPropertiesResource"] = None, + options: Optional["_models.CassandraKeyspaceGetPropertiesOptions"] = None, + **kwargs: Any + ) -> None: + """ + :keyword tags: Resource tags. :paramtype tags: dict[str, str] + :keyword location: The geo-location where the resource lives. + :paramtype location: str :keyword identity: Identity for the resource. :paramtype identity: ~azure.mgmt.cosmosdb.models.ManagedServiceIdentity :keyword resource: @@ -1747,7 +1612,10 @@ def __init__( :keyword options: :paramtype options: ~azure.mgmt.cosmosdb.models.CassandraKeyspaceGetPropertiesOptions """ - super().__init__(location=location, tags=tags, identity=identity, **kwargs) + super().__init__(**kwargs) + self.tags = tags + self.location = location + self.identity = identity self.resource = resource self.options = options @@ -1759,6 +1627,8 @@ class CassandraKeyspaceListResult(_serialization.Model): :ivar value: List of Cassandra keyspaces and their properties. :vartype value: list[~azure.mgmt.cosmosdb.models.CassandraKeyspaceGetResults] + :ivar next_link: + :vartype next_link: str """ _validation = { @@ -1767,12 +1637,17 @@ class CassandraKeyspaceListResult(_serialization.Model): _attribute_map = { "value": {"key": "value", "type": "[CassandraKeyspaceGetResults]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__(self, **kwargs: Any) -> None: - """ """ + def __init__(self, *, next_link: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword next_link: + :paramtype next_link: str + """ super().__init__(**kwargs) self.value: Optional[list["_models.CassandraKeyspaceGetResults"]] = None + self.next_link = next_link class CassandraPartitionKey(_serialization.Model): @@ -1796,19 +1671,18 @@ def __init__(self, *, name: Optional[str] = None, **kwargs: Any) -> None: class CassandraRoleAssignmentListResult(_serialization.Model): - """The relevant Role Assignments. + """The response of a CassandraRoleAssignmentResource list operation. - 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 value: List of Role Assignments and their properties. + :ivar value: The CassandraRoleAssignmentResource items on this page. Required. :vartype value: list[~azure.mgmt.cosmosdb.models.CassandraRoleAssignmentResource] - :ivar next_link: The link used to get the next page of results. + :ivar next_link: The link to the next page of items. :vartype next_link: str """ _validation = { - "value": {"readonly": True}, - "next_link": {"readonly": True}, + "value": {"required": True}, } _attribute_map = { @@ -1816,52 +1690,18 @@ class CassandraRoleAssignmentListResult(_serialization.Model): "next_link": {"key": "nextLink", "type": "str"}, } - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.value: Optional[list["_models.CassandraRoleAssignmentResource"]] = None - self.next_link: Optional[str] = None - - -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.cosmosdb.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: - """ """ + def __init__( + self, *, value: list["_models.CassandraRoleAssignmentResource"], next_link: Optional[str] = None, **kwargs: Any + ) -> None: + """ + :keyword value: The CassandraRoleAssignmentResource items on this page. Required. + :paramtype value: list[~azure.mgmt.cosmosdb.models.CassandraRoleAssignmentResource] + :keyword next_link: The link to the next page of items. + :paramtype next_link: str + """ 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 + self.value = value + self.next_link = next_link class ProxyResource(Resource): @@ -1959,19 +1799,18 @@ def __init__( class CassandraRoleDefinitionListResult(_serialization.Model): - """The relevant Role Definitions. + """The response of a CassandraRoleDefinitionResource list operation. - 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 value: List of Role Definitions and their properties. + :ivar value: The CassandraRoleDefinitionResource items on this page. Required. :vartype value: list[~azure.mgmt.cosmosdb.models.CassandraRoleDefinitionResource] - :ivar next_link: The link used to get the next page of results. + :ivar next_link: The link to the next page of items. :vartype next_link: str """ _validation = { - "value": {"readonly": True}, - "next_link": {"readonly": True}, + "value": {"required": True}, } _attribute_map = { @@ -1979,11 +1818,18 @@ class CassandraRoleDefinitionListResult(_serialization.Model): "next_link": {"key": "nextLink", "type": "str"}, } - def __init__(self, **kwargs: Any) -> None: - """ """ + def __init__( + self, *, value: list["_models.CassandraRoleDefinitionResource"], next_link: Optional[str] = None, **kwargs: Any + ) -> None: + """ + :keyword value: The CassandraRoleDefinitionResource items on this page. Required. + :paramtype value: list[~azure.mgmt.cosmosdb.models.CassandraRoleDefinitionResource] + :keyword next_link: The link to the next page of items. + :paramtype next_link: str + """ super().__init__(**kwargs) - self.value: Optional[list["_models.CassandraRoleDefinitionResource"]] = None - self.next_link: Optional[str] = None + self.value = value + self.next_link = next_link class CassandraRoleDefinitionResource(ProxyResource): @@ -2454,20 +2300,13 @@ def __init__( self.analytical_storage_ttl = analytical_storage_ttl -class CassandraTableGetPropertiesResource(CassandraTableResource, ExtendedResourceProperties): +class CassandraTableGetPropertiesResource(CassandraTableResource): """CassandraTableGetPropertiesResource. 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 rid: A system generated property. A unique identifier. - :vartype rid: str - :ivar ts: A system generated property that denotes the last updated timestamp of the resource. - :vartype ts: float - :ivar etag: A system generated property representing the resource etag required for optimistic - concurrency control. - :vartype etag: str :ivar id: Name of the Cosmos DB Cassandra table. Required. :vartype id: str :ivar default_ttl: Time to live of the Cosmos DB Cassandra table. @@ -2476,23 +2315,30 @@ class CassandraTableGetPropertiesResource(CassandraTableResource, ExtendedResour :vartype schema: ~azure.mgmt.cosmosdb.models.CassandraSchema :ivar analytical_storage_ttl: Analytical TTL. :vartype analytical_storage_ttl: int + :ivar rid: A system generated property. A unique identifier. + :vartype rid: str + :ivar ts: A system generated property that denotes the last updated timestamp of the resource. + :vartype ts: float + :ivar etag: A system generated property representing the resource etag required for optimistic + concurrency control. + :vartype etag: str """ _validation = { + "id": {"required": True}, "rid": {"readonly": True}, "ts": {"readonly": True}, "etag": {"readonly": True}, - "id": {"required": True}, } _attribute_map = { - "rid": {"key": "_rid", "type": "str"}, - "ts": {"key": "_ts", "type": "float"}, - "etag": {"key": "_etag", "type": "str"}, "id": {"key": "id", "type": "str"}, "default_ttl": {"key": "defaultTtl", "type": "int"}, "schema": {"key": "schema", "type": "CassandraSchema"}, "analytical_storage_ttl": {"key": "analyticalStorageTtl", "type": "int"}, + "rid": {"key": "_rid", "type": "str"}, + "ts": {"key": "_ts", "type": "float"}, + "etag": {"key": "_etag", "type": "str"}, } def __init__( @@ -2520,32 +2366,28 @@ def __init__( self.rid: Optional[str] = None self.ts: Optional[float] = None self.etag: Optional[str] = None - self.id = id - self.default_ttl = default_ttl - self.schema = schema - self.analytical_storage_ttl = analytical_storage_ttl -class CassandraTableGetResults(ARMResourceProperties): +class CassandraTableGetResults(Resource): """An Azure Cosmos DB Cassandra table. Variables are only populated by the server, and will be ignored when sending a request. - :ivar id: The unique resource identifier of the ARM resource. + :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 ARM resource. + :ivar name: The name of the resource. :vartype name: str - :ivar type: The type of Azure resource. + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". :vartype type: str - :ivar location: The location of the resource group to which the resource belongs. - :vartype location: str - :ivar tags: Tags are a list of key-value pairs that describe the resource. These tags can be - used in viewing and grouping this resource (across resource groups). A maximum of 15 tags can - be provided for a resource. Each tag must have a key no greater than 128 characters and value - no greater than 256 characters. For example, the default experience for a template type is set - with "defaultExperience": "Cassandra". Current "defaultExperience" values also include "Table", - "Graph", "DocumentDB", and "MongoDB". + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.cosmosdb.models.SystemData + :ivar tags: Resource tags. :vartype tags: dict[str, str] + :ivar location: The geo-location where the resource lives. + :vartype location: str :ivar identity: Identity for the resource. :vartype identity: ~azure.mgmt.cosmosdb.models.ManagedServiceIdentity :ivar resource: @@ -2558,14 +2400,16 @@ class CassandraTableGetResults(ARMResourceProperties): "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"}, - "location": {"key": "location", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, "tags": {"key": "tags", "type": "{str}"}, + "location": {"key": "location", "type": "str"}, "identity": {"key": "identity", "type": "ManagedServiceIdentity"}, "resource": {"key": "properties.resource", "type": "CassandraTableGetPropertiesResource"}, "options": {"key": "properties.options", "type": "CassandraTableGetPropertiesOptions"}, @@ -2574,23 +2418,18 @@ class CassandraTableGetResults(ARMResourceProperties): def __init__( self, *, - location: Optional[str] = None, tags: Optional[dict[str, str]] = None, + location: Optional[str] = None, identity: Optional["_models.ManagedServiceIdentity"] = None, resource: Optional["_models.CassandraTableGetPropertiesResource"] = None, options: Optional["_models.CassandraTableGetPropertiesOptions"] = None, **kwargs: Any ) -> None: """ - :keyword location: The location of the resource group to which the resource belongs. - :paramtype location: str - :keyword tags: Tags are a list of key-value pairs that describe the resource. These tags can be - used in viewing and grouping this resource (across resource groups). A maximum of 15 tags can - be provided for a resource. Each tag must have a key no greater than 128 characters and value - no greater than 256 characters. For example, the default experience for a template type is set - with "defaultExperience": "Cassandra". Current "defaultExperience" values also include "Table", - "Graph", "DocumentDB", and "MongoDB". + :keyword tags: Resource tags. :paramtype tags: dict[str, str] + :keyword location: The geo-location where the resource lives. + :paramtype location: str :keyword identity: Identity for the resource. :paramtype identity: ~azure.mgmt.cosmosdb.models.ManagedServiceIdentity :keyword resource: @@ -2598,7 +2437,10 @@ def __init__( :keyword options: :paramtype options: ~azure.mgmt.cosmosdb.models.CassandraTableGetPropertiesOptions """ - super().__init__(location=location, tags=tags, identity=identity, **kwargs) + super().__init__(**kwargs) + self.tags = tags + self.location = location + self.identity = identity self.resource = resource self.options = options @@ -2610,6 +2452,8 @@ class CassandraTableListResult(_serialization.Model): :ivar value: List of Cassandra tables and their properties. :vartype value: list[~azure.mgmt.cosmosdb.models.CassandraTableGetResults] + :ivar next_link: + :vartype next_link: str """ _validation = { @@ -2618,12 +2462,17 @@ class CassandraTableListResult(_serialization.Model): _attribute_map = { "value": {"key": "value", "type": "[CassandraTableGetResults]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__(self, **kwargs: Any) -> None: - """ """ + def __init__(self, *, next_link: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword next_link: + :paramtype next_link: str + """ super().__init__(**kwargs) self.value: Optional[list["_models.CassandraTableGetResults"]] = None + self.next_link = next_link class CassandraViewCreateUpdateParameters(ARMResourceProperties): @@ -2752,13 +2601,17 @@ def __init__(self, *, id: str, view_definition: str, **kwargs: Any) -> None: # self.view_definition = view_definition -class CassandraViewGetPropertiesResource(CassandraViewResource, ExtendedResourceProperties): +class CassandraViewGetPropertiesResource(CassandraViewResource): """CassandraViewGetPropertiesResource. 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: Name of the Cosmos DB Cassandra view. Required. + :vartype id: str + :ivar view_definition: View Definition of the Cosmos DB Cassandra view. Required. + :vartype view_definition: str :ivar rid: A system generated property. A unique identifier. :vartype rid: str :ivar ts: A system generated property that denotes the last updated timestamp of the resource. @@ -2766,26 +2619,22 @@ class CassandraViewGetPropertiesResource(CassandraViewResource, ExtendedResource :ivar etag: A system generated property representing the resource etag required for optimistic concurrency control. :vartype etag: str - :ivar id: Name of the Cosmos DB Cassandra view. Required. - :vartype id: str - :ivar view_definition: View Definition of the Cosmos DB Cassandra view. Required. - :vartype view_definition: str """ _validation = { + "id": {"required": True}, + "view_definition": {"required": True}, "rid": {"readonly": True}, "ts": {"readonly": True}, "etag": {"readonly": True}, - "id": {"required": True}, - "view_definition": {"required": True}, } _attribute_map = { + "id": {"key": "id", "type": "str"}, + "view_definition": {"key": "viewDefinition", "type": "str"}, "rid": {"key": "_rid", "type": "str"}, "ts": {"key": "_ts", "type": "float"}, "etag": {"key": "_etag", "type": "str"}, - "id": {"key": "id", "type": "str"}, - "view_definition": {"key": "viewDefinition", "type": "str"}, } def __init__(self, *, id: str, view_definition: str, **kwargs: Any) -> None: # pylint: disable=redefined-builtin @@ -2799,30 +2648,28 @@ def __init__(self, *, id: str, view_definition: str, **kwargs: Any) -> None: # self.rid: Optional[str] = None self.ts: Optional[float] = None self.etag: Optional[str] = None - self.id = id - self.view_definition = view_definition -class CassandraViewGetResults(ARMResourceProperties): +class CassandraViewGetResults(Resource): """An Azure Cosmos DB Cassandra view. Variables are only populated by the server, and will be ignored when sending a request. - :ivar id: The unique resource identifier of the ARM resource. + :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 ARM resource. + :ivar name: The name of the resource. :vartype name: str - :ivar type: The type of Azure resource. + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". :vartype type: str - :ivar location: The location of the resource group to which the resource belongs. - :vartype location: str - :ivar tags: Tags are a list of key-value pairs that describe the resource. These tags can be - used in viewing and grouping this resource (across resource groups). A maximum of 15 tags can - be provided for a resource. Each tag must have a key no greater than 128 characters and value - no greater than 256 characters. For example, the default experience for a template type is set - with "defaultExperience": "Cassandra". Current "defaultExperience" values also include "Table", - "Graph", "DocumentDB", and "MongoDB". + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.cosmosdb.models.SystemData + :ivar tags: Resource tags. :vartype tags: dict[str, str] + :ivar location: The geo-location where the resource lives. + :vartype location: str :ivar identity: Identity for the resource. :vartype identity: ~azure.mgmt.cosmosdb.models.ManagedServiceIdentity :ivar resource: @@ -2835,14 +2682,16 @@ class CassandraViewGetResults(ARMResourceProperties): "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"}, - "location": {"key": "location", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, "tags": {"key": "tags", "type": "{str}"}, + "location": {"key": "location", "type": "str"}, "identity": {"key": "identity", "type": "ManagedServiceIdentity"}, "resource": {"key": "properties.resource", "type": "CassandraViewGetPropertiesResource"}, "options": {"key": "properties.options", "type": "CassandraViewGetPropertiesOptions"}, @@ -2851,23 +2700,18 @@ class CassandraViewGetResults(ARMResourceProperties): def __init__( self, *, - location: Optional[str] = None, tags: Optional[dict[str, str]] = None, + location: Optional[str] = None, identity: Optional["_models.ManagedServiceIdentity"] = None, resource: Optional["_models.CassandraViewGetPropertiesResource"] = None, options: Optional["_models.CassandraViewGetPropertiesOptions"] = None, **kwargs: Any ) -> None: """ - :keyword location: The location of the resource group to which the resource belongs. - :paramtype location: str - :keyword tags: Tags are a list of key-value pairs that describe the resource. These tags can be - used in viewing and grouping this resource (across resource groups). A maximum of 15 tags can - be provided for a resource. Each tag must have a key no greater than 128 characters and value - no greater than 256 characters. For example, the default experience for a template type is set - with "defaultExperience": "Cassandra". Current "defaultExperience" values also include "Table", - "Graph", "DocumentDB", and "MongoDB". + :keyword tags: Resource tags. :paramtype tags: dict[str, str] + :keyword location: The geo-location where the resource lives. + :paramtype location: str :keyword identity: Identity for the resource. :paramtype identity: ~azure.mgmt.cosmosdb.models.ManagedServiceIdentity :keyword resource: @@ -2875,7 +2719,10 @@ def __init__( :keyword options: :paramtype options: ~azure.mgmt.cosmosdb.models.CassandraViewGetPropertiesOptions """ - super().__init__(location=location, tags=tags, identity=identity, **kwargs) + super().__init__(**kwargs) + self.tags = tags + self.location = location + self.identity = identity self.resource = resource self.options = options @@ -2887,6 +2734,8 @@ class CassandraViewListResult(_serialization.Model): :ivar value: List of Cassandra views and their properties. :vartype value: list[~azure.mgmt.cosmosdb.models.CassandraViewGetResults] + :ivar next_link: + :vartype next_link: str """ _validation = { @@ -2895,12 +2744,17 @@ class CassandraViewListResult(_serialization.Model): _attribute_map = { "value": {"key": "value", "type": "[CassandraViewGetResults]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__(self, **kwargs: Any) -> None: - """ """ + def __init__(self, *, next_link: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword next_link: + :paramtype next_link: str + """ super().__init__(**kwargs) self.value: Optional[list["_models.CassandraViewGetResults"]] = None + self.next_link = next_link class Certificate(_serialization.Model): @@ -2926,17 +2780,16 @@ def __init__(self, *, pem: Optional[str] = None, **kwargs: Any) -> None: class ChaosFaultListResponse(_serialization.Model): """Chaos Fault List Response. - 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 value: List of Chaos Faults. + :ivar value: The chaosFaultResource items on this page. Required. :vartype value: list[~azure.mgmt.cosmosdb.models.ChaosFaultResource] - :ivar next_link: The link used to get the next page of results. + :ivar next_link: The link to the next page of items. :vartype next_link: str """ _validation = { - "value": {"readonly": True}, - "next_link": {"readonly": True}, + "value": {"required": True}, } _attribute_map = { @@ -2944,11 +2797,18 @@ class ChaosFaultListResponse(_serialization.Model): "next_link": {"key": "nextLink", "type": "str"}, } - def __init__(self, **kwargs: Any) -> None: - """ """ + def __init__( + self, *, value: list["_models.ChaosFaultResource"], next_link: Optional[str] = None, **kwargs: Any + ) -> None: + """ + :keyword value: The chaosFaultResource items on this page. Required. + :paramtype value: list[~azure.mgmt.cosmosdb.models.ChaosFaultResource] + :keyword next_link: The link to the next page of items. + :paramtype next_link: str + """ super().__init__(**kwargs) - self.value: Optional[list["_models.ChaosFaultResource"]] = None - self.next_link: Optional[str] = None + self.value = value + self.next_link = next_link class ChaosFaultResource(ProxyResource): @@ -3167,18 +3027,11 @@ def __init__( self.key_wrap_metadata = key_wrap_metadata -class ClientEncryptionKeyGetPropertiesResource(ClientEncryptionKeyResource, ExtendedResourceProperties): +class ClientEncryptionKeyGetPropertiesResource(ClientEncryptionKeyResource): """ClientEncryptionKeyGetPropertiesResource. Variables are only populated by the server, and will be ignored when sending a request. - :ivar rid: A system generated property. A unique identifier. - :vartype rid: str - :ivar ts: A system generated property that denotes the last updated timestamp of the resource. - :vartype ts: float - :ivar etag: A system generated property representing the resource etag required for optimistic - concurrency control. - :vartype etag: str :ivar id: Name of the ClientEncryptionKey. :vartype id: str :ivar encryption_algorithm: Encryption algorithm that will be used along with this client @@ -3190,6 +3043,13 @@ class ClientEncryptionKeyGetPropertiesResource(ClientEncryptionKeyResource, Exte :ivar key_wrap_metadata: Metadata for the wrapping provider that can be used to unwrap the wrapped client encryption key. :vartype key_wrap_metadata: ~azure.mgmt.cosmosdb.models.KeyWrapMetadata + :ivar rid: A system generated property. A unique identifier. + :vartype rid: str + :ivar ts: A system generated property that denotes the last updated timestamp of the resource. + :vartype ts: float + :ivar etag: A system generated property representing the resource etag required for optimistic + concurrency control. + :vartype etag: str """ _validation = { @@ -3199,13 +3059,13 @@ class ClientEncryptionKeyGetPropertiesResource(ClientEncryptionKeyResource, Exte } _attribute_map = { - "rid": {"key": "_rid", "type": "str"}, - "ts": {"key": "_ts", "type": "float"}, - "etag": {"key": "_etag", "type": "str"}, "id": {"key": "id", "type": "str"}, "encryption_algorithm": {"key": "encryptionAlgorithm", "type": "str"}, "wrapped_data_encryption_key": {"key": "wrappedDataEncryptionKey", "type": "bytearray"}, "key_wrap_metadata": {"key": "keyWrapMetadata", "type": "KeyWrapMetadata"}, + "rid": {"key": "_rid", "type": "str"}, + "ts": {"key": "_ts", "type": "float"}, + "etag": {"key": "_etag", "type": "str"}, } def __init__( @@ -3240,23 +3100,24 @@ def __init__( self.rid: Optional[str] = None self.ts: Optional[float] = None self.etag: Optional[str] = None - self.id = id - self.encryption_algorithm = encryption_algorithm - self.wrapped_data_encryption_key = wrapped_data_encryption_key - self.key_wrap_metadata = key_wrap_metadata -class ClientEncryptionKeyGetResults(ARMProxyResource): +class ClientEncryptionKeyGetResults(ProxyResource): """Client Encryption Key. Variables are only populated by the server, and will be ignored when sending a request. - :ivar id: The unique resource identifier of the database account. + :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 database account. + :ivar name: The name of the resource. :vartype name: str - :ivar type: The type of Azure resource. + :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.cosmosdb.models.SystemData :ivar resource: :vartype resource: ~azure.mgmt.cosmosdb.models.ClientEncryptionKeyGetPropertiesResource """ @@ -3265,12 +3126,14 @@ class ClientEncryptionKeyGetResults(ARMProxyResource): "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"}, "resource": {"key": "properties.resource", "type": "ClientEncryptionKeyGetPropertiesResource"}, } @@ -3292,6 +3155,8 @@ class ClientEncryptionKeysListResult(_serialization.Model): :ivar value: List of client encryption keys and their properties. :vartype value: list[~azure.mgmt.cosmosdb.models.ClientEncryptionKeyGetResults] + :ivar next_link: + :vartype next_link: str """ _validation = { @@ -3300,12 +3165,17 @@ class ClientEncryptionKeysListResult(_serialization.Model): _attribute_map = { "value": {"key": "value", "type": "[ClientEncryptionKeyGetResults]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__(self, **kwargs: Any) -> None: - """ """ + def __init__(self, *, next_link: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword next_link: + :paramtype next_link: str + """ super().__init__(**kwargs) self.value: Optional[list["_models.ClientEncryptionKeyGetResults"]] = None + self.next_link = next_link class ClientEncryptionPolicy(_serialization.Model): @@ -3375,26 +3245,28 @@ def __init__(self, *, name: Optional[str] = None, order_by: Optional[str] = None self.order_by = order_by -class ManagedCassandraARMResourceProperties(_serialization.Model): - """The core properties of ARM resources. +class ClusterResource(Resource): + """Representation of a managed Cassandra cluster. Variables are only populated by the server, and will be ignored when sending a request. - :ivar id: The unique resource identifier of the ARM resource. + :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 ARM resource. + :ivar name: The name of the resource. :vartype name: str - :ivar type: The type of Azure resource. + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". :vartype type: str - :ivar location: The location of the resource group to which the resource belongs. - :vartype location: str - :ivar tags: Tags are a list of key-value pairs that describe the resource. These tags can be - used in viewing and grouping this resource (across resource groups). A maximum of 15 tags can - be provided for a resource. Each tag must have a key no greater than 128 characters and value - no greater than 256 characters. For example, the default experience for a template type is set - with "defaultExperience": "Cassandra". Current "defaultExperience" values also include "Table", - "Graph", "DocumentDB", and "MongoDB". + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.cosmosdb.models.SystemData + :ivar properties: Properties of a managed Cassandra cluster. + :vartype properties: ~azure.mgmt.cosmosdb.models.ClusterResourceProperties + :ivar tags: Resource tags. :vartype tags: dict[str, str] + :ivar location: The geo-location where the resource lives. + :vartype location: str :ivar identity: Identity for the resource. :vartype identity: ~azure.mgmt.cosmosdb.models.ManagedCassandraManagedServiceIdentity """ @@ -3403,117 +3275,46 @@ class ManagedCassandraARMResourceProperties(_serialization.Model): "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"}, - "location": {"key": "location", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "properties": {"key": "properties", "type": "ClusterResourceProperties"}, "tags": {"key": "tags", "type": "{str}"}, + "location": {"key": "location", "type": "str"}, "identity": {"key": "identity", "type": "ManagedCassandraManagedServiceIdentity"}, } def __init__( self, *, - location: Optional[str] = None, + properties: Optional["_models.ClusterResourceProperties"] = None, tags: Optional[dict[str, str]] = None, + location: Optional[str] = None, identity: Optional["_models.ManagedCassandraManagedServiceIdentity"] = None, **kwargs: Any ) -> None: """ - :keyword location: The location of the resource group to which the resource belongs. - :paramtype location: str - :keyword tags: Tags are a list of key-value pairs that describe the resource. These tags can be - used in viewing and grouping this resource (across resource groups). A maximum of 15 tags can - be provided for a resource. Each tag must have a key no greater than 128 characters and value - no greater than 256 characters. For example, the default experience for a template type is set - with "defaultExperience": "Cassandra". Current "defaultExperience" values also include "Table", - "Graph", "DocumentDB", and "MongoDB". + :keyword properties: Properties of a managed Cassandra cluster. + :paramtype properties: ~azure.mgmt.cosmosdb.models.ClusterResourceProperties + :keyword tags: Resource tags. :paramtype tags: dict[str, str] + :keyword location: The geo-location where the resource lives. + :paramtype location: str :keyword identity: Identity for the resource. :paramtype identity: ~azure.mgmt.cosmosdb.models.ManagedCassandraManagedServiceIdentity """ super().__init__(**kwargs) - self.id: Optional[str] = None - self.name: Optional[str] = None - self.type: Optional[str] = None - self.location = location + self.properties = properties self.tags = tags + self.location = location self.identity = identity -class ClusterResource(ManagedCassandraARMResourceProperties): - """Representation of a managed Cassandra cluster. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The unique resource identifier of the ARM resource. - :vartype id: str - :ivar name: The name of the ARM resource. - :vartype name: str - :ivar type: The type of Azure resource. - :vartype type: str - :ivar location: The location of the resource group to which the resource belongs. - :vartype location: str - :ivar tags: Tags are a list of key-value pairs that describe the resource. These tags can be - used in viewing and grouping this resource (across resource groups). A maximum of 15 tags can - be provided for a resource. Each tag must have a key no greater than 128 characters and value - no greater than 256 characters. For example, the default experience for a template type is set - with "defaultExperience": "Cassandra". Current "defaultExperience" values also include "Table", - "Graph", "DocumentDB", and "MongoDB". - :vartype tags: dict[str, str] - :ivar identity: Identity for the resource. - :vartype identity: ~azure.mgmt.cosmosdb.models.ManagedCassandraManagedServiceIdentity - :ivar properties: Properties of a managed Cassandra cluster. - :vartype properties: ~azure.mgmt.cosmosdb.models.ClusterResourceProperties - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "location": {"key": "location", "type": "str"}, - "tags": {"key": "tags", "type": "{str}"}, - "identity": {"key": "identity", "type": "ManagedCassandraManagedServiceIdentity"}, - "properties": {"key": "properties", "type": "ClusterResourceProperties"}, - } - - def __init__( - self, - *, - location: Optional[str] = None, - tags: Optional[dict[str, str]] = None, - identity: Optional["_models.ManagedCassandraManagedServiceIdentity"] = None, - properties: Optional["_models.ClusterResourceProperties"] = None, - **kwargs: Any - ) -> None: - """ - :keyword location: The location of the resource group to which the resource belongs. - :paramtype location: str - :keyword tags: Tags are a list of key-value pairs that describe the resource. These tags can be - used in viewing and grouping this resource (across resource groups). A maximum of 15 tags can - be provided for a resource. Each tag must have a key no greater than 128 characters and value - no greater than 256 characters. For example, the default experience for a template type is set - with "defaultExperience": "Cassandra". Current "defaultExperience" values also include "Table", - "Graph", "DocumentDB", and "MongoDB". - :paramtype tags: dict[str, str] - :keyword identity: Identity for the resource. - :paramtype identity: ~azure.mgmt.cosmosdb.models.ManagedCassandraManagedServiceIdentity - :keyword properties: Properties of a managed Cassandra cluster. - :paramtype properties: ~azure.mgmt.cosmosdb.models.ClusterResourceProperties - """ - super().__init__(location=location, tags=tags, identity=identity, **kwargs) - self.properties = properties - - class ClusterResourceProperties(_serialization.Model): """Properties of a managed Cassandra cluster. @@ -3815,7 +3616,7 @@ class CommandAsyncPostBody(_serialization.Model): :ivar command: The command which should be run. Required. :vartype command: str :ivar arguments: The arguments for the command to be run. - :vartype arguments: JSON + :vartype arguments: any :ivar host: IP address of the cassandra host to run the command on. Required. :vartype host: str :ivar cassandra_stop_start: If true, stops cassandra before executing the command and then @@ -3844,7 +3645,7 @@ def __init__( *, command: str, host: str, - arguments: Optional[JSON] = None, + arguments: Optional[Any] = None, cassandra_stop_start: Optional[bool] = None, read_write: Optional[bool] = None, **kwargs: Any @@ -3853,7 +3654,7 @@ def __init__( :keyword command: The command which should be run. Required. :paramtype command: str :keyword arguments: The arguments for the command to be run. - :paramtype arguments: JSON + :paramtype arguments: any :keyword host: IP address of the cassandra host to run the command on. Required. :paramtype host: str :keyword cassandra_stop_start: If true, stops cassandra before executing the command and then @@ -3963,7 +3764,7 @@ class CommandPublicResource(_serialization.Model): :ivar command_id: The unique id of command. :vartype command_id: str :ivar arguments: The arguments for the command to be run. - :vartype arguments: JSON + :vartype arguments: any :ivar host: IP address of the cassandra host to run the command on. :vartype host: str :ivar is_admin: Whether command has admin privileges. @@ -4001,7 +3802,7 @@ def __init__( *, command: Optional[str] = None, command_id: Optional[str] = None, - arguments: Optional[JSON] = None, + arguments: Optional[Any] = None, host: Optional[str] = None, is_admin: Optional[bool] = None, cassandra_stop_start: Optional[bool] = None, @@ -4017,7 +3818,7 @@ def __init__( :keyword command_id: The unique id of command. :paramtype command_id: str :keyword arguments: The arguments for the command to be run. - :paramtype arguments: JSON + :paramtype arguments: any :keyword host: IP address of the cassandra host to run the command on. :paramtype host: str :keyword is_admin: Whether command has admin privileges. @@ -4049,39 +3850,195 @@ def __init__( self.output_file = output_file -class CompositePath(_serialization.Model): - """CompositePath. - - :ivar path: The path for which the indexing behavior applies to. Index paths typically start - with root and end with wildcard (/path/*). - :vartype path: str - :ivar order: Sort order for composite paths. Known values are: "ascending" and "descending". - :vartype order: str or ~azure.mgmt.cosmosdb.models.CompositePathSortOrder - """ - - _attribute_map = { - "path": {"key": "path", "type": "str"}, - "order": {"key": "order", "type": "str"}, - } - - def __init__( - self, - *, - path: Optional[str] = None, - order: Optional[Union[str, "_models.CompositePathSortOrder"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword path: The path for which the indexing behavior applies to. Index paths typically start - with root and end with wildcard (/path/*). - :paramtype path: str - :keyword order: Sort order for composite paths. Known values are: "ascending" and "descending". - :paramtype order: str or ~azure.mgmt.cosmosdb.models.CompositePathSortOrder - """ - super().__init__(**kwargs) - self.path = path - self.order = order - +class ComponentsM9L909SchemasCassandraclusterpublicstatusPropertiesDatacentersItemsPropertiesNodesItems( + _serialization.Model +): # pylint: disable=name-too-long + """ComponentsM9L909SchemasCassandraclusterpublicstatusPropertiesDatacentersItemsPropertiesNodesItems. + + :ivar address: The node's IP address. + :vartype address: str + :ivar state: The state of the node in Cassandra ring. Known values are: "Normal", "Leaving", + "Joining", "Moving", and "Stopped". + :vartype state: str or ~azure.mgmt.cosmosdb.models.NodeState + :ivar status: + :vartype status: str + :ivar cassandra_process_status: Cassandra service status on this node. + :vartype cassandra_process_status: str + :ivar load: The amount of file system data in the data directory (e.g., 47.66 kB), excluding + all content in the snapshots subdirectories. Because all SSTable data files are included, any + data that is not cleaned up (such as TTL-expired cells or tombstones) is counted. + :vartype load: str + :ivar tokens: List of tokens this node covers. + :vartype tokens: list[str] + :ivar size: + :vartype size: int + :ivar host_id: The network ID of the node. + :vartype host_id: str + :ivar rack: The rack this node is part of. + :vartype rack: str + :ivar timestamp: The timestamp when these statistics were captured. + :vartype timestamp: str + :ivar disk_used_kb: The amount of disk used, in kB, of the directory /var/lib/cassandra. + :vartype disk_used_kb: int + :ivar disk_free_kb: The amount of disk free, in kB, of the directory /var/lib/cassandra. + :vartype disk_free_kb: int + :ivar memory_used_kb: Used memory (calculated as total - free - buffers - cache), in kB. + :vartype memory_used_kb: int + :ivar memory_buffers_and_cached_kb: Memory used by kernel buffers (Buffers in /proc/meminfo) + and page cache and slabs (Cached and SReclaimable in /proc/meminfo), in kB. + :vartype memory_buffers_and_cached_kb: int + :ivar memory_free_kb: Unused memory (MemFree and SwapFree in /proc/meminfo), in kB. + :vartype memory_free_kb: int + :ivar memory_total_kb: Total installed memory (MemTotal and SwapTotal in /proc/meminfo), in kB. + :vartype memory_total_kb: int + :ivar cpu_usage: A float representing the current system-wide CPU utilization as a percentage. + :vartype cpu_usage: float + :ivar is_latest_model: If node has been updated to latest model. + :vartype is_latest_model: bool + """ + + _attribute_map = { + "address": {"key": "address", "type": "str"}, + "state": {"key": "state", "type": "str"}, + "status": {"key": "status", "type": "str"}, + "cassandra_process_status": {"key": "cassandraProcessStatus", "type": "str"}, + "load": {"key": "load", "type": "str"}, + "tokens": {"key": "tokens", "type": "[str]"}, + "size": {"key": "size", "type": "int"}, + "host_id": {"key": "hostID", "type": "str"}, + "rack": {"key": "rack", "type": "str"}, + "timestamp": {"key": "timestamp", "type": "str"}, + "disk_used_kb": {"key": "diskUsedKB", "type": "int"}, + "disk_free_kb": {"key": "diskFreeKB", "type": "int"}, + "memory_used_kb": {"key": "memoryUsedKB", "type": "int"}, + "memory_buffers_and_cached_kb": {"key": "memoryBuffersAndCachedKB", "type": "int"}, + "memory_free_kb": {"key": "memoryFreeKB", "type": "int"}, + "memory_total_kb": {"key": "memoryTotalKB", "type": "int"}, + "cpu_usage": {"key": "cpuUsage", "type": "float"}, + "is_latest_model": {"key": "isLatestModel", "type": "bool"}, + } + + def __init__( + self, + *, + address: Optional[str] = None, + state: Optional[Union[str, "_models.NodeState"]] = None, + status: Optional[str] = None, + cassandra_process_status: Optional[str] = None, + load: Optional[str] = None, + tokens: Optional[list[str]] = None, + size: Optional[int] = None, + host_id: Optional[str] = None, + rack: Optional[str] = None, + timestamp: Optional[str] = None, + disk_used_kb: Optional[int] = None, + disk_free_kb: Optional[int] = None, + memory_used_kb: Optional[int] = None, + memory_buffers_and_cached_kb: Optional[int] = None, + memory_free_kb: Optional[int] = None, + memory_total_kb: Optional[int] = None, + cpu_usage: Optional[float] = None, + is_latest_model: Optional[bool] = None, + **kwargs: Any + ) -> None: + """ + :keyword address: The node's IP address. + :paramtype address: str + :keyword state: The state of the node in Cassandra ring. Known values are: "Normal", "Leaving", + "Joining", "Moving", and "Stopped". + :paramtype state: str or ~azure.mgmt.cosmosdb.models.NodeState + :keyword status: + :paramtype status: str + :keyword cassandra_process_status: Cassandra service status on this node. + :paramtype cassandra_process_status: str + :keyword load: The amount of file system data in the data directory (e.g., 47.66 kB), excluding + all content in the snapshots subdirectories. Because all SSTable data files are included, any + data that is not cleaned up (such as TTL-expired cells or tombstones) is counted. + :paramtype load: str + :keyword tokens: List of tokens this node covers. + :paramtype tokens: list[str] + :keyword size: + :paramtype size: int + :keyword host_id: The network ID of the node. + :paramtype host_id: str + :keyword rack: The rack this node is part of. + :paramtype rack: str + :keyword timestamp: The timestamp when these statistics were captured. + :paramtype timestamp: str + :keyword disk_used_kb: The amount of disk used, in kB, of the directory /var/lib/cassandra. + :paramtype disk_used_kb: int + :keyword disk_free_kb: The amount of disk free, in kB, of the directory /var/lib/cassandra. + :paramtype disk_free_kb: int + :keyword memory_used_kb: Used memory (calculated as total - free - buffers - cache), in kB. + :paramtype memory_used_kb: int + :keyword memory_buffers_and_cached_kb: Memory used by kernel buffers (Buffers in /proc/meminfo) + and page cache and slabs (Cached and SReclaimable in /proc/meminfo), in kB. + :paramtype memory_buffers_and_cached_kb: int + :keyword memory_free_kb: Unused memory (MemFree and SwapFree in /proc/meminfo), in kB. + :paramtype memory_free_kb: int + :keyword memory_total_kb: Total installed memory (MemTotal and SwapTotal in /proc/meminfo), in + kB. + :paramtype memory_total_kb: int + :keyword cpu_usage: A float representing the current system-wide CPU utilization as a + percentage. + :paramtype cpu_usage: float + :keyword is_latest_model: If node has been updated to latest model. + :paramtype is_latest_model: bool + """ + super().__init__(**kwargs) + self.address = address + self.state = state + self.status = status + self.cassandra_process_status = cassandra_process_status + self.load = load + self.tokens = tokens + self.size = size + self.host_id = host_id + self.rack = rack + self.timestamp = timestamp + self.disk_used_kb = disk_used_kb + self.disk_free_kb = disk_free_kb + self.memory_used_kb = memory_used_kb + self.memory_buffers_and_cached_kb = memory_buffers_and_cached_kb + self.memory_free_kb = memory_free_kb + self.memory_total_kb = memory_total_kb + self.cpu_usage = cpu_usage + self.is_latest_model = is_latest_model + + +class CompositePath(_serialization.Model): + """CompositePath. + + :ivar path: The path for which the indexing behavior applies to. Index paths typically start + with root and end with wildcard (/path/*). + :vartype path: str + :ivar order: Sort order for composite paths. Known values are: "ascending" and "descending". + :vartype order: str or ~azure.mgmt.cosmosdb.models.CompositePathSortOrder + """ + + _attribute_map = { + "path": {"key": "path", "type": "str"}, + "order": {"key": "order", "type": "str"}, + } + + def __init__( + self, + *, + path: Optional[str] = None, + order: Optional[Union[str, "_models.CompositePathSortOrder"]] = None, + **kwargs: Any + ) -> None: + """ + :keyword path: The path for which the indexing behavior applies to. Index paths typically start + with root and end with wildcard (/path/*). + :paramtype path: str + :keyword order: Sort order for composite paths. Known values are: "ascending" and "descending". + :paramtype order: str or ~azure.mgmt.cosmosdb.models.CompositePathSortOrder + """ + super().__init__(**kwargs) + self.path = path + self.order = order + class ComputedProperty(_serialization.Model): """The definition of a computed property. @@ -4415,8 +4372,8 @@ def __init__( class ContinuousModeProperties(_serialization.Model): """Configuration values for periodic mode backup. - :ivar tier: Enum to indicate type of Continuos backup mode. Known values are: "Continuous7Days" - and "Continuous30Days". + :ivar tier: Enum to indicate type of Continuos backup mode. Known values are: + "Continuous7Days", "Continuous30Days", and "Continuous35Days". :vartype tier: str or ~azure.mgmt.cosmosdb.models.ContinuousTier """ @@ -4427,7 +4384,7 @@ class ContinuousModeProperties(_serialization.Model): def __init__(self, *, tier: Optional[Union[str, "_models.ContinuousTier"]] = None, **kwargs: Any) -> None: """ :keyword tier: Enum to indicate type of Continuos backup mode. Known values are: - "Continuous7Days" and "Continuous30Days". + "Continuous7Days", "Continuous30Days", and "Continuous35Days". :paramtype tier: str or ~azure.mgmt.cosmosdb.models.ContinuousTier """ super().__init__(**kwargs) @@ -4437,17 +4394,16 @@ def __init__(self, *, tier: Optional[Union[str, "_models.ContinuousTier"]] = Non class CopyJobFeedResults(_serialization.Model): """The List operation response, that contains the Copy Jobs and their properties. - 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 value: List of Copy Jobs and their properties. + :ivar value: The CopyJobGetResults items on this page. Required. :vartype value: list[~azure.mgmt.cosmosdb.models.CopyJobGetResults] - :ivar next_link: URL to get the next set of Copy Job list results if there are any. + :ivar next_link: The link to the next page of items. :vartype next_link: str """ _validation = { - "value": {"readonly": True}, - "next_link": {"readonly": True}, + "value": {"required": True}, } _attribute_map = { @@ -4455,26 +4411,38 @@ class CopyJobFeedResults(_serialization.Model): "next_link": {"key": "nextLink", "type": "str"}, } - def __init__(self, **kwargs: Any) -> None: - """ """ + def __init__( + self, *, value: list["_models.CopyJobGetResults"], next_link: Optional[str] = None, **kwargs: Any + ) -> None: + """ + :keyword value: The CopyJobGetResults items on this page. Required. + :paramtype value: list[~azure.mgmt.cosmosdb.models.CopyJobGetResults] + :keyword next_link: The link to the next page of items. + :paramtype next_link: str + """ super().__init__(**kwargs) - self.value: Optional[list["_models.CopyJobGetResults"]] = None - self.next_link: Optional[str] = None + self.value = value + self.next_link = next_link -class CopyJobGetResults(ARMProxyResource): +class CopyJobGetResults(ProxyResource): """A Cosmos DB Copy Job. 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: The unique resource identifier of the database account. + :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 database account. + :ivar name: The name of the resource. :vartype name: str - :ivar type: The type of Azure resource. + :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.cosmosdb.models.SystemData :ivar properties: The properties of a Copy Job. Required. :vartype properties: ~azure.mgmt.cosmosdb.models.CopyJobProperties """ @@ -4483,6 +4451,7 @@ class CopyJobGetResults(ARMProxyResource): "id": {"readonly": True}, "name": {"readonly": True}, "type": {"readonly": True}, + "system_data": {"readonly": True}, "properties": {"required": True}, } @@ -4490,6 +4459,7 @@ class CopyJobGetResults(ARMProxyResource): "id": {"key": "id", "type": "str"}, "name": {"key": "name", "type": "str"}, "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, "properties": {"key": "properties", "type": "CopyJobProperties"}, } @@ -4523,7 +4493,7 @@ class CopyJobProperties(_serialization.Model): :ivar worker_count: Worker count. :vartype worker_count: int :ivar error: Error response for Faulted job. - :vartype error: ~azure.mgmt.cosmosdb.models.ErrorResponseAutoGenerated + :vartype error: ~azure.mgmt.cosmosdb.models.ErrorResponse :ivar duration: Total Duration of Job. :vartype duration: str :ivar mode: Mode of job execution. Known values are: "Offline" and "Online". @@ -4548,7 +4518,7 @@ class CopyJobProperties(_serialization.Model): "total_count": {"key": "totalCount", "type": "int"}, "last_updated_utc_time": {"key": "lastUpdatedUtcTime", "type": "iso-8601"}, "worker_count": {"key": "workerCount", "type": "int"}, - "error": {"key": "error", "type": "ErrorResponseAutoGenerated"}, + "error": {"key": "error", "type": "ErrorResponse"}, "duration": {"key": "duration", "type": "str"}, "mode": {"key": "mode", "type": "str"}, } @@ -4576,7 +4546,7 @@ def __init__( self.total_count: Optional[int] = None self.last_updated_utc_time: Optional[datetime.datetime] = None self.worker_count = worker_count - self.error: Optional["_models.ErrorResponseAutoGenerated"] = None + self.error: Optional["_models.ErrorResponse"] = None self.duration: Optional[str] = None self.mode = mode @@ -4657,7 +4627,7 @@ class CosmosCassandraDataTransferDataSourceSink(BaseCosmosDataTransferDataSource All required parameters must be populated in order to send to server. :ivar component: Known values are: "CosmosDBCassandra", "CosmosDBMongo", "CosmosDBMongoVCore", - "CosmosDBSql", and "AzureBlobStorage". + "CosmosDBSql", "AzureBlobStorage", and "BaseCosmosDataTransferDataSourceSink". :vartype component: str or ~azure.mgmt.cosmosdb.models.DataTransferComponent :ivar remote_account_name: :vartype remote_account_name: str @@ -4855,7 +4825,7 @@ class CosmosMongoDataTransferDataSourceSink(BaseCosmosDataTransferDataSourceSink All required parameters must be populated in order to send to server. :ivar component: Known values are: "CosmosDBCassandra", "CosmosDBMongo", "CosmosDBMongoVCore", - "CosmosDBSql", and "AzureBlobStorage". + "CosmosDBSql", "AzureBlobStorage", and "BaseCosmosDataTransferDataSourceSink". :vartype component: str or ~azure.mgmt.cosmosdb.models.DataTransferComponent :ivar remote_account_name: :vartype remote_account_name: str @@ -4901,7 +4871,7 @@ class CosmosMongoVCoreDataTransferDataSourceSink(DataTransferDataSourceSink): # All required parameters must be populated in order to send to server. :ivar component: Known values are: "CosmosDBCassandra", "CosmosDBMongo", "CosmosDBMongoVCore", - "CosmosDBSql", and "AzureBlobStorage". + "CosmosDBSql", "AzureBlobStorage", and "BaseCosmosDataTransferDataSourceSink". :vartype component: str or ~azure.mgmt.cosmosdb.models.DataTransferComponent :ivar database_name: Required. :vartype database_name: str @@ -4960,7 +4930,7 @@ class CosmosSqlDataTransferDataSourceSink(BaseCosmosDataTransferDataSourceSink): All required parameters must be populated in order to send to server. :ivar component: Known values are: "CosmosDBCassandra", "CosmosDBMongo", "CosmosDBMongoVCore", - "CosmosDBSql", and "AzureBlobStorage". + "CosmosDBSql", "AzureBlobStorage", and "BaseCosmosDataTransferDataSourceSink". :vartype component: str or ~azure.mgmt.cosmosdb.models.DataTransferComponent :ivar remote_account_name: :vartype remote_account_name: str @@ -5148,8 +5118,8 @@ class DatabaseAccountCreateUpdateParameters(ARMResourceProperties): :ivar locations: An array that contains the georeplication locations enabled for the Cosmos DB account. Required. :vartype locations: list[~azure.mgmt.cosmosdb.models.Location] - :ivar database_account_offer_type: The offer type for the database. Required. Default value is - "Standard". + :ivar database_account_offer_type: The offer type for the Cosmos DB database account. Required. + Default value is "Standard". :vartype database_account_offer_type: str :ivar ip_rules: List of IpRules. :vartype ip_rules: list[~azure.mgmt.cosmosdb.models.IpAddressOrRange] @@ -5253,6 +5223,11 @@ class DatabaseAccountCreateUpdateParameters(ARMResourceProperties): :ivar enable_all_versions_and_deletes_change_feed: Flag to indicate if All Versions and Deletes Change feed feature is enabled on the account. :vartype enable_all_versions_and_deletes_change_feed: bool + :ivar soft_delete_configuration: The configuration for soft delete on the Cosmos DB account. + :vartype soft_delete_configuration: ~azure.mgmt.cosmosdb.models.SoftDeleteConfiguration + :ivar enforce_hierarchical_partition_key_id_last_level: Flag to indicate enabling/disabling of + hierarchical partition key ID last level enforcement on the account. + :vartype enforce_hierarchical_partition_key_id_last_level: bool """ _validation = { @@ -5323,6 +5298,11 @@ class DatabaseAccountCreateUpdateParameters(ARMResourceProperties): "key": "properties.enableAllVersionsAndDeletesChangeFeed", "type": "bool", }, + "soft_delete_configuration": {"key": "properties.softDeleteConfiguration", "type": "SoftDeleteConfiguration"}, + "enforce_hierarchical_partition_key_id_last_level": { + "key": "properties.enforceHierarchicalPartitionKeyIdLastLevel", + "type": "bool", + }, } database_account_offer_type = "Standard" @@ -5352,7 +5332,7 @@ def __init__( # pylint: disable=too-many-locals api_properties: Optional["_models.ApiProperties"] = None, enable_analytical_storage: Optional[bool] = None, analytical_storage_configuration: Optional["_models.AnalyticalStorageConfiguration"] = None, - create_mode: Union[str, "_models.CreateMode"] = "Default", + create_mode: Optional[Union[str, "_models.CreateMode"]] = None, backup_policy: Optional["_models.BackupPolicy"] = None, cors: Optional[list["_models.CorsPolicy"]] = None, network_acl_bypass: Optional[Union[str, "_models.NetworkAclBypass"]] = None, @@ -5371,6 +5351,8 @@ def __init__( # pylint: disable=too-many-locals default_priority_level: Optional[Union[str, "_models.DefaultPriorityLevel"]] = None, enable_per_region_per_partition_autoscale: Optional[bool] = None, enable_all_versions_and_deletes_change_feed: Optional[bool] = None, + soft_delete_configuration: Optional["_models.SoftDeleteConfiguration"] = None, + enforce_hierarchical_partition_key_id_last_level: Optional[bool] = None, **kwargs: Any ) -> None: """ @@ -5492,6 +5474,11 @@ def __init__( # pylint: disable=too-many-locals :keyword enable_all_versions_and_deletes_change_feed: Flag to indicate if All Versions and Deletes Change feed feature is enabled on the account. :paramtype enable_all_versions_and_deletes_change_feed: bool + :keyword soft_delete_configuration: The configuration for soft delete on the Cosmos DB account. + :paramtype soft_delete_configuration: ~azure.mgmt.cosmosdb.models.SoftDeleteConfiguration + :keyword enforce_hierarchical_partition_key_id_last_level: Flag to indicate enabling/disabling + of hierarchical partition key ID last level enforcement on the account. + :paramtype enforce_hierarchical_partition_key_id_last_level: bool """ super().__init__(location=location, tags=tags, identity=identity, **kwargs) self.kind = kind @@ -5533,35 +5520,35 @@ def __init__( # pylint: disable=too-many-locals self.default_priority_level = default_priority_level self.enable_per_region_per_partition_autoscale = enable_per_region_per_partition_autoscale self.enable_all_versions_and_deletes_change_feed = enable_all_versions_and_deletes_change_feed + self.soft_delete_configuration = soft_delete_configuration + self.enforce_hierarchical_partition_key_id_last_level = enforce_hierarchical_partition_key_id_last_level -class DatabaseAccountGetResults(ARMResourceProperties): +class DatabaseAccountGetResults(Resource): """An Azure Cosmos DB database account. Variables are only populated by the server, and will be ignored when sending a request. - :ivar id: The unique resource identifier of the ARM resource. + :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 ARM resource. + :ivar name: The name of the resource. :vartype name: str - :ivar type: The type of Azure resource. + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". :vartype type: str - :ivar location: The location of the resource group to which the resource belongs. - :vartype location: str - :ivar tags: Tags are a list of key-value pairs that describe the resource. These tags can be - used in viewing and grouping this resource (across resource groups). A maximum of 15 tags can - be provided for a resource. Each tag must have a key no greater than 128 characters and value - no greater than 256 characters. For example, the default experience for a template type is set - with "defaultExperience": "Cassandra". Current "defaultExperience" values also include "Table", - "Graph", "DocumentDB", and "MongoDB". + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.cosmosdb.models.SystemData + :ivar tags: Resource tags. :vartype tags: dict[str, str] + :ivar location: The geo-location where the resource lives. + :vartype location: str :ivar identity: Identity for the resource. :vartype identity: ~azure.mgmt.cosmosdb.models.ManagedServiceIdentity :ivar kind: Indicates the type of database account. This can only be set at database account creation. Known values are: "GlobalDocumentDB", "MongoDB", and "Parse". :vartype kind: str or ~azure.mgmt.cosmosdb.models.DatabaseAccountKind - :ivar system_data: The system meta data relating to this resource. - :vartype system_data: ~azure.mgmt.cosmosdb.models.SystemData :ivar provisioning_state: The provisioning state of the resource. :vartype provisioning_state: str :ivar document_endpoint: The connection endpoint for the Cosmos DB database account. @@ -5695,6 +5682,8 @@ class DatabaseAccountGetResults(ARMResourceProperties): :ivar enable_all_versions_and_deletes_change_feed: Flag to indicate if All Versions and Deletes Change feed feature is enabled on the account. :vartype enable_all_versions_and_deletes_change_feed: bool + :ivar soft_delete_configuration: The configuration for soft delete on the Cosmos DB account. + :vartype soft_delete_configuration: ~azure.mgmt.cosmosdb.models.SoftDeleteConfiguration :ivar throughput_pool_dedicated_r_us: Total dedicated throughput (RU/s) for database account. Represents the sum of all manual provisioned throughput and all autoscale max RU/s across all shared throughput databases and dedicated throughput containers in the account for 1 region. @@ -5705,6 +5694,9 @@ class DatabaseAccountGetResults(ARMResourceProperties): consumed from the pool, summed across all shared throughput databases and dedicated throughput containers in the account for 1 region. READ ONLY. :vartype throughput_pool_max_consumable_r_us: int + :ivar enforce_hierarchical_partition_key_id_last_level: Flag to indicate enabling/disabling of + hierarchical partition key ID last level enforcement on the account. + :vartype enforce_hierarchical_partition_key_id_last_level: bool """ _validation = { @@ -5729,11 +5721,11 @@ class DatabaseAccountGetResults(ARMResourceProperties): "id": {"key": "id", "type": "str"}, "name": {"key": "name", "type": "str"}, "type": {"key": "type", "type": "str"}, - "location": {"key": "location", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, "tags": {"key": "tags", "type": "{str}"}, + "location": {"key": "location", "type": "str"}, "identity": {"key": "identity", "type": "ManagedServiceIdentity"}, "kind": {"key": "kind", "type": "str"}, - "system_data": {"key": "systemData", "type": "SystemData"}, "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, "document_endpoint": {"key": "properties.documentEndpoint", "type": "str"}, "database_account_offer_type": {"key": "properties.databaseAccountOfferType", "type": "str"}, @@ -5800,15 +5792,20 @@ class DatabaseAccountGetResults(ARMResourceProperties): "key": "properties.enableAllVersionsAndDeletesChangeFeed", "type": "bool", }, + "soft_delete_configuration": {"key": "properties.softDeleteConfiguration", "type": "SoftDeleteConfiguration"}, "throughput_pool_dedicated_r_us": {"key": "properties.throughputPoolDedicatedRUs", "type": "int"}, "throughput_pool_max_consumable_r_us": {"key": "properties.throughputPoolMaxConsumableRUs", "type": "int"}, + "enforce_hierarchical_partition_key_id_last_level": { + "key": "properties.enforceHierarchicalPartitionKeyIdLastLevel", + "type": "bool", + }, } def __init__( # pylint: disable=too-many-locals self, *, - location: Optional[str] = None, tags: Optional[dict[str, str]] = None, + location: Optional[str] = None, identity: Optional["_models.ManagedServiceIdentity"] = None, kind: Optional[Union[str, "_models.DatabaseAccountKind"]] = None, ip_rules: Optional[list["_models.IpAddressOrRange"]] = None, @@ -5828,7 +5825,7 @@ def __init__( # pylint: disable=too-many-locals api_properties: Optional["_models.ApiProperties"] = None, enable_analytical_storage: Optional[bool] = None, analytical_storage_configuration: Optional["_models.AnalyticalStorageConfiguration"] = None, - create_mode: Union[str, "_models.CreateMode"] = "Default", + create_mode: Optional[Union[str, "_models.CreateMode"]] = None, restore_parameters: Optional["_models.RestoreParameters"] = None, backup_policy: Optional["_models.BackupPolicy"] = None, cors: Optional[list["_models.CorsPolicy"]] = None, @@ -5848,20 +5845,17 @@ def __init__( # pylint: disable=too-many-locals default_priority_level: Optional[Union[str, "_models.DefaultPriorityLevel"]] = None, enable_per_region_per_partition_autoscale: Optional[bool] = None, enable_all_versions_and_deletes_change_feed: Optional[bool] = None, + soft_delete_configuration: Optional["_models.SoftDeleteConfiguration"] = None, throughput_pool_dedicated_r_us: Optional[int] = None, throughput_pool_max_consumable_r_us: Optional[int] = None, + enforce_hierarchical_partition_key_id_last_level: Optional[bool] = None, **kwargs: Any ) -> None: """ - :keyword location: The location of the resource group to which the resource belongs. - :paramtype location: str - :keyword tags: Tags are a list of key-value pairs that describe the resource. These tags can be - used in viewing and grouping this resource (across resource groups). A maximum of 15 tags can - be provided for a resource. Each tag must have a key no greater than 128 characters and value - no greater than 256 characters. For example, the default experience for a template type is set - with "defaultExperience": "Cassandra". Current "defaultExperience" values also include "Table", - "Graph", "DocumentDB", and "MongoDB". + :keyword tags: Resource tags. :paramtype tags: dict[str, str] + :keyword location: The geo-location where the resource lives. + :paramtype location: str :keyword identity: Identity for the resource. :paramtype identity: ~azure.mgmt.cosmosdb.models.ManagedServiceIdentity :keyword kind: Indicates the type of database account. This can only be set at database account @@ -5972,6 +5966,8 @@ def __init__( # pylint: disable=too-many-locals :keyword enable_all_versions_and_deletes_change_feed: Flag to indicate if All Versions and Deletes Change feed feature is enabled on the account. :paramtype enable_all_versions_and_deletes_change_feed: bool + :keyword soft_delete_configuration: The configuration for soft delete on the Cosmos DB account. + :paramtype soft_delete_configuration: ~azure.mgmt.cosmosdb.models.SoftDeleteConfiguration :keyword throughput_pool_dedicated_r_us: Total dedicated throughput (RU/s) for database account. Represents the sum of all manual provisioned throughput and all autoscale max RU/s across all shared throughput databases and dedicated throughput containers in the account for 1 @@ -5982,10 +5978,15 @@ def __init__( # pylint: disable=too-many-locals consumed from the pool, summed across all shared throughput databases and dedicated throughput containers in the account for 1 region. READ ONLY. :paramtype throughput_pool_max_consumable_r_us: int + :keyword enforce_hierarchical_partition_key_id_last_level: Flag to indicate enabling/disabling + of hierarchical partition key ID last level enforcement on the account. + :paramtype enforce_hierarchical_partition_key_id_last_level: bool """ - super().__init__(location=location, tags=tags, identity=identity, **kwargs) + super().__init__(**kwargs) + self.tags = tags + self.location = location + self.identity = identity self.kind = kind - self.system_data: Optional["_models.SystemData"] = None self.provisioning_state: Optional[str] = None self.document_endpoint: Optional[str] = None self.database_account_offer_type: Optional[Literal["Standard"]] = None @@ -6034,8 +6035,10 @@ def __init__( # pylint: disable=too-many-locals self.default_priority_level = default_priority_level self.enable_per_region_per_partition_autoscale = enable_per_region_per_partition_autoscale self.enable_all_versions_and_deletes_change_feed = enable_all_versions_and_deletes_change_feed + self.soft_delete_configuration = soft_delete_configuration self.throughput_pool_dedicated_r_us = throughput_pool_dedicated_r_us self.throughput_pool_max_consumable_r_us = throughput_pool_max_consumable_r_us + self.enforce_hierarchical_partition_key_id_last_level = enforce_hierarchical_partition_key_id_last_level class DatabaseAccountKeysMetadata(_serialization.Model): @@ -6177,6 +6180,9 @@ class DatabaseAccountRegenerateKeyParameters(_serialization.Model): :ivar key_kind: The access key to regenerate. Required. Known values are: "primary", "secondary", "primaryReadonly", and "secondaryReadonly". :vartype key_kind: str or ~azure.mgmt.cosmosdb.models.KeyKind + :ivar skip_account_keys_last_usage_check: Optional flag indicating whether to skip account keys + last usage check. + :vartype skip_account_keys_last_usage_check: bool """ _validation = { @@ -6185,16 +6191,27 @@ class DatabaseAccountRegenerateKeyParameters(_serialization.Model): _attribute_map = { "key_kind": {"key": "keyKind", "type": "str"}, + "skip_account_keys_last_usage_check": {"key": "skipAccountKeysLastUsageCheck", "type": "bool"}, } - def __init__(self, *, key_kind: Union[str, "_models.KeyKind"], **kwargs: Any) -> None: + def __init__( + self, + *, + key_kind: Union[str, "_models.KeyKind"], + skip_account_keys_last_usage_check: Optional[bool] = None, + **kwargs: Any + ) -> None: """ :keyword key_kind: The access key to regenerate. Required. Known values are: "primary", "secondary", "primaryReadonly", and "secondaryReadonly". :paramtype key_kind: str or ~azure.mgmt.cosmosdb.models.KeyKind + :keyword skip_account_keys_last_usage_check: Optional flag indicating whether to skip account + keys last usage check. + :paramtype skip_account_keys_last_usage_check: bool """ super().__init__(**kwargs) self.key_kind = key_kind + self.skip_account_keys_last_usage_check = skip_account_keys_last_usage_check class DatabaseAccountsListResult(_serialization.Model): @@ -6204,6 +6221,8 @@ class DatabaseAccountsListResult(_serialization.Model): :ivar value: List of database account and their properties. :vartype value: list[~azure.mgmt.cosmosdb.models.DatabaseAccountGetResults] + :ivar next_link: + :vartype next_link: str """ _validation = { @@ -6212,12 +6231,17 @@ class DatabaseAccountsListResult(_serialization.Model): _attribute_map = { "value": {"key": "value", "type": "[DatabaseAccountGetResults]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__(self, **kwargs: Any) -> None: - """ """ + def __init__(self, *, next_link: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword next_link: + :paramtype next_link: str + """ super().__init__(**kwargs) self.value: Optional[list["_models.DatabaseAccountGetResults"]] = None + self.next_link = next_link class DatabaseAccountUpdateParameters(_serialization.Model): @@ -6337,6 +6361,11 @@ class DatabaseAccountUpdateParameters(_serialization.Model): :ivar enable_all_versions_and_deletes_change_feed: Flag to indicate if All Versions and Deletes Change feed feature is enabled on the account. :vartype enable_all_versions_and_deletes_change_feed: bool + :ivar soft_delete_configuration: The configuration for soft delete on the Cosmos DB account. + :vartype soft_delete_configuration: ~azure.mgmt.cosmosdb.models.SoftDeleteConfiguration + :ivar enforce_hierarchical_partition_key_id_last_level: Flag to indicate enabling/disabling of + hierarchical partition key ID last level enforcement on the account. + :vartype enforce_hierarchical_partition_key_id_last_level: bool """ _validation = { @@ -6395,6 +6424,11 @@ class DatabaseAccountUpdateParameters(_serialization.Model): "key": "properties.enableAllVersionsAndDeletesChangeFeed", "type": "bool", }, + "soft_delete_configuration": {"key": "properties.softDeleteConfiguration", "type": "SoftDeleteConfiguration"}, + "enforce_hierarchical_partition_key_id_last_level": { + "key": "properties.enforceHierarchicalPartitionKeyIdLastLevel", + "type": "bool", + }, } def __init__( # pylint: disable=too-many-locals @@ -6438,6 +6472,8 @@ def __init__( # pylint: disable=too-many-locals default_priority_level: Optional[Union[str, "_models.DefaultPriorityLevel"]] = None, enable_per_region_per_partition_autoscale: Optional[bool] = None, enable_all_versions_and_deletes_change_feed: Optional[bool] = None, + soft_delete_configuration: Optional["_models.SoftDeleteConfiguration"] = None, + enforce_hierarchical_partition_key_id_last_level: Optional[bool] = None, **kwargs: Any ) -> None: """ @@ -6551,6 +6587,11 @@ def __init__( # pylint: disable=too-many-locals :keyword enable_all_versions_and_deletes_change_feed: Flag to indicate if All Versions and Deletes Change feed feature is enabled on the account. :paramtype enable_all_versions_and_deletes_change_feed: bool + :keyword soft_delete_configuration: The configuration for soft delete on the Cosmos DB account. + :paramtype soft_delete_configuration: ~azure.mgmt.cosmosdb.models.SoftDeleteConfiguration + :keyword enforce_hierarchical_partition_key_id_last_level: Flag to indicate enabling/disabling + of hierarchical partition key ID last level enforcement on the account. + :paramtype enforce_hierarchical_partition_key_id_last_level: bool """ super().__init__(**kwargs) self.tags = tags @@ -6592,6 +6633,8 @@ def __init__( # pylint: disable=too-many-locals self.default_priority_level = default_priority_level self.enable_per_region_per_partition_autoscale = enable_per_region_per_partition_autoscale self.enable_all_versions_and_deletes_change_feed = enable_all_versions_and_deletes_change_feed + self.soft_delete_configuration = soft_delete_configuration + self.enforce_hierarchical_partition_key_id_last_level = enforce_hierarchical_partition_key_id_last_level class DatabaseRestoreResource(_serialization.Model): @@ -6622,17 +6665,22 @@ def __init__( self.collection_names = collection_names -class DataCenterResource(ARMProxyResource): +class DataCenterResource(ProxyResource): """A managed Cassandra data center. Variables are only populated by the server, and will be ignored when sending a request. - :ivar id: The unique resource identifier of the database account. + :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 database account. + :ivar name: The name of the resource. :vartype name: str - :ivar type: The type of Azure resource. + :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.cosmosdb.models.SystemData :ivar properties: Properties of a managed Cassandra data center. :vartype properties: ~azure.mgmt.cosmosdb.models.DataCenterResourceProperties """ @@ -6641,12 +6689,14 @@ class DataCenterResource(ARMProxyResource): "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"}, "properties": {"key": "properties", "type": "DataCenterResourceProperties"}, } @@ -6873,7 +6923,7 @@ def __init__( class DataMaskingPolicyExcludedPathsItem(_serialization.Model): - """DataMaskingPolicyExcludedPathsItem. + """JSON path to exclude from masking. All required parameters must be populated in order to send to server. @@ -6899,7 +6949,7 @@ def __init__(self, *, path: str, **kwargs: Any) -> None: class DataMaskingPolicyIncludedPathsItem(_serialization.Model): - """DataMaskingPolicyIncludedPathsItem. + """JSON path to include in the masking policy. All required parameters must be populated in order to send to server. @@ -6953,17 +7003,16 @@ def __init__( class DataTransferJobFeedResults(_serialization.Model): """The List operation response, that contains the Data Transfer jobs and their properties. - 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 value: List of Data Transfer jobs and their properties. + :ivar value: The DataTransferJobGetResults items on this page. Required. :vartype value: list[~azure.mgmt.cosmosdb.models.DataTransferJobGetResults] - :ivar next_link: URL to get the next set of Data Transfer job list results if there are any. + :ivar next_link: The link to the next page of items. :vartype next_link: str """ _validation = { - "value": {"readonly": True}, - "next_link": {"readonly": True}, + "value": {"required": True}, } _attribute_map = { @@ -6971,24 +7020,36 @@ class DataTransferJobFeedResults(_serialization.Model): "next_link": {"key": "nextLink", "type": "str"}, } - def __init__(self, **kwargs: Any) -> None: - """ """ + def __init__( + self, *, value: list["_models.DataTransferJobGetResults"], next_link: Optional[str] = None, **kwargs: Any + ) -> None: + """ + :keyword value: The DataTransferJobGetResults items on this page. Required. + :paramtype value: list[~azure.mgmt.cosmosdb.models.DataTransferJobGetResults] + :keyword next_link: The link to the next page of items. + :paramtype next_link: str + """ super().__init__(**kwargs) - self.value: Optional[list["_models.DataTransferJobGetResults"]] = None - self.next_link: Optional[str] = None + self.value = value + self.next_link = next_link -class DataTransferJobGetResults(ARMProxyResource): +class DataTransferJobGetResults(ProxyResource): """A Cosmos DB Data Transfer Job. Variables are only populated by the server, and will be ignored when sending a request. - :ivar id: The unique resource identifier of the database account. + :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 database account. + :ivar name: The name of the resource. :vartype name: str - :ivar type: The type of Azure resource. + :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.cosmosdb.models.SystemData :ivar job_name: Job Name. :vartype job_name: str :ivar source: Source DataStore details. @@ -7006,7 +7067,7 @@ class DataTransferJobGetResults(ARMProxyResource): :ivar worker_count: Worker count. :vartype worker_count: int :ivar error: Error response for Faulted job. - :vartype error: ~azure.mgmt.cosmosdb.models.ErrorResponseAutoGenerated2 + :vartype error: ~azure.mgmt.cosmosdb.models.ErrorResponseAutoGenerated :ivar duration: Total Duration of Job. :vartype duration: str :ivar mode: Mode of job execution. Known values are: "Offline" and "Online". @@ -7017,6 +7078,7 @@ class DataTransferJobGetResults(ARMProxyResource): "id": {"readonly": True}, "name": {"readonly": True}, "type": {"readonly": True}, + "system_data": {"readonly": True}, "job_name": {"readonly": True}, "status": {"readonly": True}, "processed_count": {"readonly": True}, @@ -7031,6 +7093,7 @@ class DataTransferJobGetResults(ARMProxyResource): "id": {"key": "id", "type": "str"}, "name": {"key": "name", "type": "str"}, "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, "job_name": {"key": "properties.jobName", "type": "str"}, "source": {"key": "properties.source", "type": "DataTransferDataSourceSink"}, "destination": {"key": "properties.destination", "type": "DataTransferDataSourceSink"}, @@ -7039,7 +7102,7 @@ class DataTransferJobGetResults(ARMProxyResource): "total_count": {"key": "properties.totalCount", "type": "int"}, "last_updated_utc_time": {"key": "properties.lastUpdatedUtcTime", "type": "iso-8601"}, "worker_count": {"key": "properties.workerCount", "type": "int"}, - "error": {"key": "properties.error", "type": "ErrorResponseAutoGenerated2"}, + "error": {"key": "properties.error", "type": "ErrorResponseAutoGenerated"}, "duration": {"key": "properties.duration", "type": "str"}, "mode": {"key": "properties.mode", "type": "str"}, } @@ -7072,7 +7135,7 @@ def __init__( self.total_count: Optional[int] = None self.last_updated_utc_time: Optional[datetime.datetime] = None self.worker_count = worker_count - self.error: Optional["_models.ErrorResponseAutoGenerated2"] = None + self.error: Optional["_models.ErrorResponseAutoGenerated"] = None self.duration: Optional[str] = None self.mode = mode @@ -7101,7 +7164,7 @@ class DataTransferJobProperties(_serialization.Model): :ivar worker_count: Worker count. :vartype worker_count: int :ivar error: Error response for Faulted job. - :vartype error: ~azure.mgmt.cosmosdb.models.ErrorResponseAutoGenerated2 + :vartype error: ~azure.mgmt.cosmosdb.models.ErrorResponseAutoGenerated :ivar duration: Total Duration of Job. :vartype duration: str :ivar mode: Mode of job execution. Known values are: "Offline" and "Online". @@ -7130,7 +7193,7 @@ class DataTransferJobProperties(_serialization.Model): "total_count": {"key": "totalCount", "type": "int"}, "last_updated_utc_time": {"key": "lastUpdatedUtcTime", "type": "iso-8601"}, "worker_count": {"key": "workerCount", "type": "int"}, - "error": {"key": "error", "type": "ErrorResponseAutoGenerated2"}, + "error": {"key": "error", "type": "ErrorResponseAutoGenerated"}, "duration": {"key": "duration", "type": "str"}, "mode": {"key": "mode", "type": "str"}, } @@ -7163,7 +7226,7 @@ def __init__( self.total_count: Optional[int] = None self.last_updated_utc_time: Optional[datetime.datetime] = None self.worker_count = worker_count - self.error: Optional["_models.ErrorResponseAutoGenerated2"] = None + self.error: Optional["_models.ErrorResponseAutoGenerated"] = None self.duration: Optional[str] = None self.mode = mode @@ -7217,28 +7280,6 @@ class DataTransferRegionalServiceResource(RegionalServiceResource): """ -class DataTransferServiceResource(_serialization.Model): - """Describes the service response property. - - :ivar properties: Properties for DataTransferServiceResource. - :vartype properties: ~azure.mgmt.cosmosdb.models.DataTransferServiceResourceProperties - """ - - _attribute_map = { - "properties": {"key": "properties", "type": "DataTransferServiceResourceProperties"}, - } - - def __init__( - self, *, properties: Optional["_models.DataTransferServiceResourceProperties"] = None, **kwargs: Any - ) -> None: - """ - :keyword properties: Properties for DataTransferServiceResource. - :paramtype properties: ~azure.mgmt.cosmosdb.models.DataTransferServiceResourceProperties - """ - super().__init__(**kwargs) - self.properties = properties - - class ServiceResourceCreateUpdateProperties(_serialization.Model): """Properties in ServiceResourceCreateUpdateParameters. @@ -7595,49 +7636,6 @@ def __init__(self, **kwargs: Any) -> None: self.additional_info: Optional[list["_models.ErrorAdditionalInfo"]] = None -class ErrorDetailAutoGenerated(_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.cosmosdb.models.ErrorDetailAutoGenerated] - :ivar additional_info: The error additional info. - :vartype additional_info: list[~azure.mgmt.cosmosdb.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": "[ErrorDetailAutoGenerated]"}, - "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.ErrorDetailAutoGenerated"]] = 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.). @@ -7660,27 +7658,6 @@ def __init__(self, *, error: Optional["_models.ErrorDetail"] = None, **kwargs: A class ErrorResponseAutoGenerated(_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.cosmosdb.models.ErrorDetailAutoGenerated - """ - - _attribute_map = { - "error": {"key": "error", "type": "ErrorDetailAutoGenerated"}, - } - - def __init__(self, *, error: Optional["_models.ErrorDetailAutoGenerated"] = None, **kwargs: Any) -> None: - """ - :keyword error: The error object. - :paramtype error: ~azure.mgmt.cosmosdb.models.ErrorDetailAutoGenerated - """ - super().__init__(**kwargs) - self.error = error - - -class ErrorResponseAutoGenerated2(_serialization.Model): """Error Response. :ivar code: Error code. @@ -7801,19 +7778,18 @@ def __init__( class FleetAnalyticsListResult(_serialization.Model): - """The response of the List operation that contains the FleetAnalytics and their properties. + """The response of a FleetAnalyticsResource list operation. - 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 value: List of FleetAnalytics and their properties. + :ivar value: The FleetAnalyticsResource items on this page. Required. :vartype value: list[~azure.mgmt.cosmosdb.models.FleetAnalyticsResource] - :ivar next_link: The link used to get the next page of results. + :ivar next_link: The link to the next page of items. :vartype next_link: str """ _validation = { - "value": {"readonly": True}, - "next_link": {"readonly": True}, + "value": {"required": True}, } _attribute_map = { @@ -7821,75 +7797,21 @@ class FleetAnalyticsListResult(_serialization.Model): "next_link": {"key": "nextLink", "type": "str"}, } - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.value: Optional[list["_models.FleetAnalyticsResource"]] = None - self.next_link: Optional[str] = None - - -class ResourceAutoGenerated2(_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.cosmosdb.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: - """ """ + def __init__( + self, *, value: list["_models.FleetAnalyticsResource"], next_link: Optional[str] = None, **kwargs: Any + ) -> None: + """ + :keyword value: The FleetAnalyticsResource items on this page. Required. + :paramtype value: list[~azure.mgmt.cosmosdb.models.FleetAnalyticsResource] + :keyword next_link: The link to the next page of items. + :paramtype next_link: str + """ 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 ProxyResourceAutoGenerated2(ResourceAutoGenerated2): - """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.cosmosdb.models.SystemData - """ + self.value = value + self.next_link = next_link -class FleetAnalyticsResource(ProxyResourceAutoGenerated2): +class FleetAnalyticsResource(ProxyResource): """An Azure Cosmos DB FleetAnalytics. Variables are only populated by the server, and will be ignored when sending a request. @@ -7906,8 +7828,8 @@ class FleetAnalyticsResource(ProxyResourceAutoGenerated2): information. :vartype system_data: ~azure.mgmt.cosmosdb.models.SystemData :ivar provisioning_state: A provisioning state of the FleetAnalytics. Known values are: - "Uninitialized", "Initializing", "InternallyReady", "Online", "Deleting", "Creating", - "Succeeded", "Failed", "Canceled", and "Updating". + "Uninitialized", "Initializing", "InternallyReady", "Online", "Deleting", "Succeeded", + "Failed", "Canceled", "Updating", and "Creating". :vartype provisioning_state: str or ~azure.mgmt.cosmosdb.models.Status :ivar storage_location_type: The type of the fleet analytics resource. Known values are: "StorageAccount" and "FabricLakehouse". @@ -7922,6 +7844,7 @@ class FleetAnalyticsResource(ProxyResourceAutoGenerated2): "name": {"readonly": True}, "type": {"readonly": True}, "system_data": {"readonly": True}, + "provisioning_state": {"readonly": True}, } _attribute_map = { @@ -7937,16 +7860,11 @@ class FleetAnalyticsResource(ProxyResourceAutoGenerated2): def __init__( self, *, - provisioning_state: Optional[Union[str, "_models.Status"]] = None, storage_location_type: Optional[Union[str, "_models.FleetAnalyticsPropertiesStorageLocationType"]] = None, storage_location_uri: Optional[str] = None, **kwargs: Any ) -> None: """ - :keyword provisioning_state: A provisioning state of the FleetAnalytics. Known values are: - "Uninitialized", "Initializing", "InternallyReady", "Online", "Deleting", "Creating", - "Succeeded", "Failed", "Canceled", and "Updating". - :paramtype provisioning_state: str or ~azure.mgmt.cosmosdb.models.Status :keyword storage_location_type: The type of the fleet analytics resource. Known values are: "StorageAccount" and "FabricLakehouse". :paramtype storage_location_type: str or @@ -7955,25 +7873,24 @@ def __init__( :paramtype storage_location_uri: str """ super().__init__(**kwargs) - self.provisioning_state = provisioning_state + self.provisioning_state: Optional[Union[str, "_models.Status"]] = None self.storage_location_type = storage_location_type self.storage_location_uri = storage_location_uri class FleetListResult(_serialization.Model): - """The response of the List operation that contains the fleets and their properties. + """The response of a FleetResource list operation. - 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 value: List of fleets and their properties. + :ivar value: The FleetResource items on this page. Required. :vartype value: list[~azure.mgmt.cosmosdb.models.FleetResource] - :ivar next_link: The link used to get the next page of results. + :ivar next_link: The link to the next page of items. :vartype next_link: str """ _validation = { - "value": {"readonly": True}, - "next_link": {"readonly": True}, + "value": {"required": True}, } _attribute_map = { @@ -7981,14 +7898,19 @@ class FleetListResult(_serialization.Model): "next_link": {"key": "nextLink", "type": "str"}, } - def __init__(self, **kwargs: Any) -> None: - """ """ + def __init__(self, *, value: list["_models.FleetResource"], next_link: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword value: The FleetResource items on this page. Required. + :paramtype value: list[~azure.mgmt.cosmosdb.models.FleetResource] + :keyword next_link: The link to the next page of items. + :paramtype next_link: str + """ super().__init__(**kwargs) - self.value: Optional[list["_models.FleetResource"]] = None - self.next_link: Optional[str] = None + self.value = value + self.next_link = next_link -class TrackedResource(ResourceAutoGenerated2): +class TrackedResource(Resource): """The resource model definition for an Azure Resource Manager tracked top level resource which has 'tags' and a 'location'. @@ -8065,8 +7987,8 @@ class FleetResource(TrackedResource): :ivar location: The geo-location where the resource lives. Required. :vartype location: str :ivar provisioning_state: A provisioning state of the Fleet. Known values are: "Uninitialized", - "Initializing", "InternallyReady", "Online", "Deleting", "Creating", "Succeeded", "Failed", - "Canceled", and "Updating". + "Initializing", "InternallyReady", "Online", "Deleting", "Succeeded", "Failed", "Canceled", + "Updating", and "Creating". :vartype provisioning_state: str or ~azure.mgmt.cosmosdb.models.Status """ @@ -8076,6 +7998,7 @@ class FleetResource(TrackedResource): "type": {"readonly": True}, "system_data": {"readonly": True}, "location": {"required": True}, + "provisioning_state": {"readonly": True}, } _attribute_map = { @@ -8088,66 +8011,55 @@ class FleetResource(TrackedResource): "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, } - def __init__( - self, - *, - location: str, - tags: Optional[dict[str, str]] = None, - provisioning_state: Optional[Union[str, "_models.Status"]] = None, - **kwargs: Any - ) -> None: + 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 - :keyword provisioning_state: A provisioning state of the Fleet. Known values are: - "Uninitialized", "Initializing", "InternallyReady", "Online", "Deleting", "Creating", - "Succeeded", "Failed", "Canceled", and "Updating". - :paramtype provisioning_state: str or ~azure.mgmt.cosmosdb.models.Status """ super().__init__(tags=tags, location=location, **kwargs) - self.provisioning_state = provisioning_state + self.provisioning_state: Optional[Union[str, "_models.Status"]] = None class FleetResourceUpdate(_serialization.Model): """Represents a fleet resource for updates. + Variables are only populated by the server, and will be ignored when sending a request. + :ivar provisioning_state: A provisioning state of the Fleet. Known values are: "Uninitialized", - "Initializing", "InternallyReady", "Online", "Deleting", "Creating", "Succeeded", "Failed", - "Canceled", and "Updating". + "Initializing", "InternallyReady", "Online", "Deleting", "Succeeded", "Failed", "Canceled", + "Updating", and "Creating". :vartype provisioning_state: str or ~azure.mgmt.cosmosdb.models.Status """ + _validation = { + "provisioning_state": {"readonly": True}, + } + _attribute_map = { "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, } - def __init__(self, *, provisioning_state: Optional[Union[str, "_models.Status"]] = None, **kwargs: Any) -> None: - """ - :keyword provisioning_state: A provisioning state of the Fleet. Known values are: - "Uninitialized", "Initializing", "InternallyReady", "Online", "Deleting", "Creating", - "Succeeded", "Failed", "Canceled", and "Updating". - :paramtype provisioning_state: str or ~azure.mgmt.cosmosdb.models.Status - """ + def __init__(self, **kwargs: Any) -> None: + """ """ super().__init__(**kwargs) - self.provisioning_state = provisioning_state + self.provisioning_state: Optional[Union[str, "_models.Status"]] = None class FleetspaceAccountListResult(_serialization.Model): - """The List operation response, that contains the global database accounts and their properties. + """The response of a FleetspaceAccountResource list operation. - 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 value: List of global database accounts in a fleetspace and their properties. + :ivar value: The FleetspaceAccountResource items on this page. Required. :vartype value: list[~azure.mgmt.cosmosdb.models.FleetspaceAccountResource] - :ivar next_link: The link used to get the next page of results. + :ivar next_link: The link to the next page of items. :vartype next_link: str """ _validation = { - "value": {"readonly": True}, - "next_link": {"readonly": True}, + "value": {"required": True}, } _attribute_map = { @@ -8155,11 +8067,18 @@ class FleetspaceAccountListResult(_serialization.Model): "next_link": {"key": "nextLink", "type": "str"}, } - def __init__(self, **kwargs: Any) -> None: - """ """ + def __init__( + self, *, value: list["_models.FleetspaceAccountResource"], next_link: Optional[str] = None, **kwargs: Any + ) -> None: + """ + :keyword value: The FleetspaceAccountResource items on this page. Required. + :paramtype value: list[~azure.mgmt.cosmosdb.models.FleetspaceAccountResource] + :keyword next_link: The link to the next page of items. + :paramtype next_link: str + """ super().__init__(**kwargs) - self.value: Optional[list["_models.FleetspaceAccountResource"]] = None - self.next_link: Optional[str] = None + self.value = value + self.next_link = next_link class FleetspaceAccountPropertiesGlobalDatabaseAccountProperties(_serialization.Model): # pylint: disable=name-too-long @@ -8190,7 +8109,7 @@ def __init__(self, *, resource_id: Optional[str] = None, arm_location: Optional[ self.arm_location = arm_location -class FleetspaceAccountResource(ProxyResourceAutoGenerated2): +class FleetspaceAccountResource(ProxyResource): """An Azure Cosmos DB Fleetspace Account. Variables are only populated by the server, and will be ignored when sending a request. @@ -8207,8 +8126,8 @@ class FleetspaceAccountResource(ProxyResourceAutoGenerated2): information. :vartype system_data: ~azure.mgmt.cosmosdb.models.SystemData :ivar provisioning_state: A provisioning state of the Fleetspace Account. Known values are: - "Uninitialized", "Initializing", "InternallyReady", "Online", "Deleting", "Creating", - "Succeeded", "Failed", "Canceled", and "Updating". + "Uninitialized", "Initializing", "InternallyReady", "Online", "Deleting", "Succeeded", + "Failed", "Canceled", "Updating", and "Creating". :vartype provisioning_state: str or ~azure.mgmt.cosmosdb.models.Status :ivar global_database_account_properties: Configuration for fleetspace Account in the fleetspace. @@ -8221,6 +8140,7 @@ class FleetspaceAccountResource(ProxyResourceAutoGenerated2): "name": {"readonly": True}, "type": {"readonly": True}, "system_data": {"readonly": True}, + "provisioning_state": {"readonly": True}, } _attribute_map = { @@ -8238,41 +8158,35 @@ class FleetspaceAccountResource(ProxyResourceAutoGenerated2): def __init__( self, *, - provisioning_state: Optional[Union[str, "_models.Status"]] = None, global_database_account_properties: Optional[ "_models.FleetspaceAccountPropertiesGlobalDatabaseAccountProperties" ] = None, **kwargs: Any ) -> None: """ - :keyword provisioning_state: A provisioning state of the Fleetspace Account. Known values are: - "Uninitialized", "Initializing", "InternallyReady", "Online", "Deleting", "Creating", - "Succeeded", "Failed", "Canceled", and "Updating". - :paramtype provisioning_state: str or ~azure.mgmt.cosmosdb.models.Status :keyword global_database_account_properties: Configuration for fleetspace Account in the fleetspace. :paramtype global_database_account_properties: ~azure.mgmt.cosmosdb.models.FleetspaceAccountPropertiesGlobalDatabaseAccountProperties """ super().__init__(**kwargs) - self.provisioning_state = provisioning_state + self.provisioning_state: Optional[Union[str, "_models.Status"]] = None self.global_database_account_properties = global_database_account_properties class FleetspaceListResult(_serialization.Model): - """The response of the List operation that contains the fleetspaces and their properties. + """The response of a FleetspaceResource list operation. - 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 value: List of fleetspaces and their properties. + :ivar value: The FleetspaceResource items on this page. Required. :vartype value: list[~azure.mgmt.cosmosdb.models.FleetspaceResource] - :ivar next_link: The link used to get the next page of results. + :ivar next_link: The link to the next page of items. :vartype next_link: str """ _validation = { - "value": {"readonly": True}, - "next_link": {"readonly": True}, + "value": {"required": True}, } _attribute_map = { @@ -8280,11 +8194,18 @@ class FleetspaceListResult(_serialization.Model): "next_link": {"key": "nextLink", "type": "str"}, } - def __init__(self, **kwargs: Any) -> None: - """ """ + def __init__( + self, *, value: list["_models.FleetspaceResource"], next_link: Optional[str] = None, **kwargs: Any + ) -> None: + """ + :keyword value: The FleetspaceResource items on this page. Required. + :paramtype value: list[~azure.mgmt.cosmosdb.models.FleetspaceResource] + :keyword next_link: The link to the next page of items. + :paramtype next_link: str + """ super().__init__(**kwargs) - self.value: Optional[list["_models.FleetspaceResource"]] = None - self.next_link: Optional[str] = None + self.value = value + self.next_link = next_link class FleetspacePropertiesThroughputPoolConfiguration(_serialization.Model): # pylint: disable=name-too-long @@ -8343,7 +8264,7 @@ def __init__( self.max_consumable_r_us = max_consumable_r_us -class FleetspaceResource(ProxyResourceAutoGenerated2): +class FleetspaceResource(ProxyResource): """An Azure Cosmos DB Fleetspace. Variables are only populated by the server, and will be ignored when sending a request. @@ -8360,8 +8281,8 @@ class FleetspaceResource(ProxyResourceAutoGenerated2): information. :vartype system_data: ~azure.mgmt.cosmosdb.models.SystemData :ivar provisioning_state: A provisioning state of the Fleetspace. Known values are: - "Uninitialized", "Initializing", "InternallyReady", "Online", "Deleting", "Creating", - "Succeeded", "Failed", "Canceled", and "Updating". + "Uninitialized", "Initializing", "InternallyReady", "Online", "Deleting", "Succeeded", + "Failed", "Canceled", "Updating", and "Creating". :vartype provisioning_state: str or ~azure.mgmt.cosmosdb.models.Status :ivar fleetspace_api_kind: The kind of API this fleetspace belongs to. Acceptable values: 'NoSQL'. "NoSQL" @@ -8383,6 +8304,7 @@ class FleetspaceResource(ProxyResourceAutoGenerated2): "name": {"readonly": True}, "type": {"readonly": True}, "system_data": {"readonly": True}, + "provisioning_state": {"readonly": True}, "data_regions": {"min_items": 1}, } @@ -8404,7 +8326,6 @@ class FleetspaceResource(ProxyResourceAutoGenerated2): def __init__( self, *, - provisioning_state: Optional[Union[str, "_models.Status"]] = None, fleetspace_api_kind: Optional[Union[str, "_models.FleetspacePropertiesFleetspaceApiKind"]] = None, service_tier: Optional[Union[str, "_models.FleetspacePropertiesServiceTier"]] = None, data_regions: Optional[list[str]] = None, @@ -8412,10 +8333,6 @@ def __init__( **kwargs: Any ) -> None: """ - :keyword provisioning_state: A provisioning state of the Fleetspace. Known values are: - "Uninitialized", "Initializing", "InternallyReady", "Online", "Deleting", "Creating", - "Succeeded", "Failed", "Canceled", and "Updating". - :paramtype provisioning_state: str or ~azure.mgmt.cosmosdb.models.Status :keyword fleetspace_api_kind: The kind of API this fleetspace belongs to. Acceptable values: 'NoSQL'. "NoSQL" :paramtype fleetspace_api_kind: str or @@ -8431,7 +8348,7 @@ def __init__( ~azure.mgmt.cosmosdb.models.FleetspacePropertiesThroughputPoolConfiguration """ super().__init__(**kwargs) - self.provisioning_state = provisioning_state + self.provisioning_state: Optional[Union[str, "_models.Status"]] = None self.fleetspace_api_kind = fleetspace_api_kind self.service_tier = service_tier self.data_regions = data_regions @@ -8441,9 +8358,11 @@ def __init__( class FleetspaceUpdate(_serialization.Model): """Represents a fleetspace resource for updates. + Variables are only populated by the server, and will be ignored when sending a request. + :ivar provisioning_state: A provisioning state of the Fleetspace. Known values are: - "Uninitialized", "Initializing", "InternallyReady", "Online", "Deleting", "Creating", - "Succeeded", "Failed", "Canceled", and "Updating". + "Uninitialized", "Initializing", "InternallyReady", "Online", "Deleting", "Succeeded", + "Failed", "Canceled", "Updating", and "Creating". :vartype provisioning_state: str or ~azure.mgmt.cosmosdb.models.Status :ivar fleetspace_api_kind: The kind of API this fleetspace belongs to. Acceptable values: 'NoSQL'. "NoSQL" @@ -8461,6 +8380,7 @@ class FleetspaceUpdate(_serialization.Model): """ _validation = { + "provisioning_state": {"readonly": True}, "data_regions": {"min_items": 1}, } @@ -8478,7 +8398,6 @@ class FleetspaceUpdate(_serialization.Model): def __init__( self, *, - provisioning_state: Optional[Union[str, "_models.Status"]] = None, fleetspace_api_kind: Optional[Union[str, "_models.FleetspacePropertiesFleetspaceApiKind"]] = None, service_tier: Optional[Union[str, "_models.FleetspacePropertiesServiceTier"]] = None, data_regions: Optional[list[str]] = None, @@ -8486,10 +8405,6 @@ def __init__( **kwargs: Any ) -> None: """ - :keyword provisioning_state: A provisioning state of the Fleetspace. Known values are: - "Uninitialized", "Initializing", "InternallyReady", "Online", "Deleting", "Creating", - "Succeeded", "Failed", "Canceled", and "Updating". - :paramtype provisioning_state: str or ~azure.mgmt.cosmosdb.models.Status :keyword fleetspace_api_kind: The kind of API this fleetspace belongs to. Acceptable values: 'NoSQL'. "NoSQL" :paramtype fleetspace_api_kind: str or @@ -8505,7 +8420,7 @@ def __init__( ~azure.mgmt.cosmosdb.models.FleetspacePropertiesThroughputPoolConfiguration """ super().__init__(**kwargs) - self.provisioning_state = provisioning_state + self.provisioning_state: Optional[Union[str, "_models.Status"]] = None self.fleetspace_api_kind = fleetspace_api_kind self.service_tier = service_tier self.data_regions = data_regions @@ -8624,8 +8539,10 @@ class GarnetClusterResource(TrackedResource): :vartype tags: dict[str, str] :ivar location: The geo-location where the resource lives. Required. :vartype location: str - :ivar properties: Properties of a Garnet cache cluster. + :ivar properties: The resource-specific properties for this resource. :vartype properties: ~azure.mgmt.cosmosdb.models.GarnetClusterResourceProperties + :ivar identity: Identity for the resource. + :vartype identity: ~azure.mgmt.cosmosdb.models.ManagedCassandraManagedServiceIdentity """ _validation = { @@ -8644,6 +8561,7 @@ class GarnetClusterResource(TrackedResource): "tags": {"key": "tags", "type": "{str}"}, "location": {"key": "location", "type": "str"}, "properties": {"key": "properties", "type": "GarnetClusterResourceProperties"}, + "identity": {"key": "identity", "type": "ManagedCassandraManagedServiceIdentity"}, } def __init__( @@ -8652,6 +8570,7 @@ def __init__( location: str, tags: Optional[dict[str, str]] = None, properties: Optional["_models.GarnetClusterResourceProperties"] = None, + identity: Optional["_models.ManagedCassandraManagedServiceIdentity"] = None, **kwargs: Any ) -> None: """ @@ -8659,11 +8578,14 @@ def __init__( :paramtype tags: dict[str, str] :keyword location: The geo-location where the resource lives. Required. :paramtype location: str - :keyword properties: Properties of a Garnet cache cluster. + :keyword properties: The resource-specific properties for this resource. :paramtype properties: ~azure.mgmt.cosmosdb.models.GarnetClusterResourceProperties + :keyword identity: Identity for the resource. + :paramtype identity: ~azure.mgmt.cosmosdb.models.ManagedCassandraManagedServiceIdentity """ super().__init__(tags=tags, location=location, **kwargs) self.properties = properties + self.identity = identity class GarnetClusterResourcePatch(_serialization.Model): @@ -8696,11 +8618,17 @@ class GarnetClusterResourcePatchProperties(_serialization.Model): :vartype cluster_type: str or ~azure.mgmt.cosmosdb.models.ClusterType :ivar extensions: Extensions to be added or updated on cluster. :vartype extensions: list[str] + :ivar authentication_method: The authentication method used for the Garnet cluster. "Entra" + :vartype authentication_method: str or ~azure.mgmt.cosmosdb.models.GarnetAuthenticationType + :ivar persistence: Flag to indicate if persistence is enabled for the Garnet cluster. + :vartype persistence: bool """ _attribute_map = { "cluster_type": {"key": "clusterType", "type": "str"}, "extensions": {"key": "extensions", "type": "[str]"}, + "authentication_method": {"key": "authenticationMethod", "type": "str"}, + "persistence": {"key": "persistence", "type": "bool"}, } def __init__( @@ -8708,6 +8636,8 @@ def __init__( *, cluster_type: Optional[Union[str, "_models.ClusterType"]] = None, extensions: Optional[list[str]] = None, + authentication_method: Optional[Union[str, "_models.GarnetAuthenticationType"]] = None, + persistence: Optional[bool] = None, **kwargs: Any ) -> None: """ @@ -8716,10 +8646,16 @@ def __init__( :paramtype cluster_type: str or ~azure.mgmt.cosmosdb.models.ClusterType :keyword extensions: Extensions to be added or updated on cluster. :paramtype extensions: list[str] + :keyword authentication_method: The authentication method used for the Garnet cluster. "Entra" + :paramtype authentication_method: str or ~azure.mgmt.cosmosdb.models.GarnetAuthenticationType + :keyword persistence: Flag to indicate if persistence is enabled for the Garnet cluster. + :paramtype persistence: bool """ super().__init__(**kwargs) self.cluster_type = cluster_type self.extensions = extensions + self.authentication_method = authentication_method + self.persistence = persistence class GarnetClusterResourceProperties(_serialization.Model): @@ -8727,8 +8663,8 @@ class GarnetClusterResourceProperties(_serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :ivar provisioning_state: The status of the resource at the time the operation was called. - Known values are: "Creating", "Updating", "Deleting", "Succeeded", "Failed", and "Canceled". + :ivar provisioning_state: The provisioning state of the resource. Known values are: "Creating", + "Updating", "Deleting", "Succeeded", "Failed", and "Canceled". :vartype provisioning_state: str or ~azure.mgmt.cosmosdb.models.GarnetCacheProvisioningState :ivar subnet_id: Resource id of a subnet that this cluster's management service should have its network interface attached to. The subnet must be routable to all subnets that will be @@ -8737,18 +8673,22 @@ class GarnetClusterResourceProperties(_serialization.Model): group>`/providers/Microsoft.Network/virtualNetworks/\\ :code:``/subnets/\\ :code:``'. :vartype subnet_id: str - :ivar end_points: endpoints for clients to connect to the cluster. + :ivar end_points: Endpoints for clients to connect to the cluster. :vartype end_points: list[~azure.mgmt.cosmosdb.models.GarnetClusterResourcePropertiesEndPointsItem] :ivar replication_factor: Number of copies of data maintained by the cluster. :vartype replication_factor: int - :ivar node_count: Number of nodes. - :vartype node_count: int + :ivar shard_count: Number of shards in the cluster. + :vartype shard_count: int :ivar node_sku: Virtual Machine SKU used for clusters. Default value is Standard_DS14_v2. :vartype node_sku: str :ivar availability_zone: If the data center has Availability Zone support, apply it to the Virtual Machine ScaleSet that host the garnet cluster virtual machines. :vartype availability_zone: bool + :ivar authentication_method: The authentication method used for the Garnet cluster. "Entra" + :vartype authentication_method: str or ~azure.mgmt.cosmosdb.models.GarnetAuthenticationType + :ivar persistence: Flag to indicate if persistence is enabled for the Garnet cluster. + :vartype persistence: bool :ivar allocation_state: Allocation state of the cluster and data center resources. Active implies the virtual machines of the cluster are allocated, deallocated implies virtual machines and resources are deallocated. Known values are: "Active" and "Deallocated". @@ -8757,7 +8697,7 @@ class GarnetClusterResourceProperties(_serialization.Model): permitted on cluster. Known values are: "Production" and "NonProduction". :vartype cluster_type: str or ~azure.mgmt.cosmosdb.models.ClusterType :ivar provision_error: Error related to resource provisioning. - :vartype provision_error: ~azure.mgmt.cosmosdb.models.ErrorDetailAutoGenerated + :vartype provision_error: ~azure.mgmt.cosmosdb.models.ErrorDetail :ivar extensions: Extensions to be added or updated on cluster. :vartype extensions: list[str] """ @@ -8772,12 +8712,14 @@ class GarnetClusterResourceProperties(_serialization.Model): "subnet_id": {"key": "subnetId", "type": "str"}, "end_points": {"key": "endPoints", "type": "[GarnetClusterResourcePropertiesEndPointsItem]"}, "replication_factor": {"key": "replicationFactor", "type": "int"}, - "node_count": {"key": "nodeCount", "type": "int"}, + "shard_count": {"key": "shardCount", "type": "int"}, "node_sku": {"key": "nodeSku", "type": "str"}, "availability_zone": {"key": "availabilityZone", "type": "bool"}, + "authentication_method": {"key": "authenticationMethod", "type": "str"}, + "persistence": {"key": "persistence", "type": "bool"}, "allocation_state": {"key": "allocationState", "type": "str"}, "cluster_type": {"key": "clusterType", "type": "str"}, - "provision_error": {"key": "provisionError", "type": "ErrorDetailAutoGenerated"}, + "provision_error": {"key": "provisionError", "type": "ErrorDetail"}, "extensions": {"key": "extensions", "type": "[str]"}, } @@ -8786,12 +8728,14 @@ def __init__( *, subnet_id: Optional[str] = None, replication_factor: Optional[int] = None, - node_count: Optional[int] = None, + shard_count: Optional[int] = None, node_sku: Optional[str] = None, availability_zone: Optional[bool] = None, + authentication_method: Optional[Union[str, "_models.GarnetAuthenticationType"]] = None, + persistence: Optional[bool] = None, allocation_state: Optional[Union[str, "_models.AllocationState"]] = None, cluster_type: Optional[Union[str, "_models.ClusterType"]] = None, - provision_error: Optional["_models.ErrorDetailAutoGenerated"] = None, + provision_error: Optional["_models.ErrorDetail"] = None, extensions: Optional[list[str]] = None, **kwargs: Any ) -> None: @@ -8805,13 +8749,17 @@ def __init__( :paramtype subnet_id: str :keyword replication_factor: Number of copies of data maintained by the cluster. :paramtype replication_factor: int - :keyword node_count: Number of nodes. - :paramtype node_count: int + :keyword shard_count: Number of shards in the cluster. + :paramtype shard_count: int :keyword node_sku: Virtual Machine SKU used for clusters. Default value is Standard_DS14_v2. :paramtype node_sku: str :keyword availability_zone: If the data center has Availability Zone support, apply it to the Virtual Machine ScaleSet that host the garnet cluster virtual machines. :paramtype availability_zone: bool + :keyword authentication_method: The authentication method used for the Garnet cluster. "Entra" + :paramtype authentication_method: str or ~azure.mgmt.cosmosdb.models.GarnetAuthenticationType + :keyword persistence: Flag to indicate if persistence is enabled for the Garnet cluster. + :paramtype persistence: bool :keyword allocation_state: Allocation state of the cluster and data center resources. Active implies the virtual machines of the cluster are allocated, deallocated implies virtual machines and resources are deallocated. Known values are: "Active" and "Deallocated". @@ -8820,7 +8768,7 @@ def __init__( permitted on cluster. Known values are: "Production" and "NonProduction". :paramtype cluster_type: str or ~azure.mgmt.cosmosdb.models.ClusterType :keyword provision_error: Error related to resource provisioning. - :paramtype provision_error: ~azure.mgmt.cosmosdb.models.ErrorDetailAutoGenerated + :paramtype provision_error: ~azure.mgmt.cosmosdb.models.ErrorDetail :keyword extensions: Extensions to be added or updated on cluster. :paramtype extensions: list[str] """ @@ -8829,9 +8777,11 @@ def __init__( self.subnet_id = subnet_id self.end_points: Optional[list["_models.GarnetClusterResourcePropertiesEndPointsItem"]] = None self.replication_factor = replication_factor - self.node_count = node_count + self.shard_count = shard_count self.node_sku = node_sku self.availability_zone = availability_zone + self.authentication_method = authentication_method + self.persistence = persistence self.allocation_state = allocation_state self.cluster_type = cluster_type self.provision_error = provision_error @@ -8839,7 +8789,7 @@ def __init__( class GarnetClusterResourcePropertiesEndPointsItem(_serialization.Model): # pylint: disable=name-too-long - """GarnetClusterResourcePropertiesEndPointsItem. + """Endpoint for clients to connect to the cluster. :ivar ip_address: Ipv4 address of the endpoint. :vartype ip_address: str @@ -8900,28 +8850,6 @@ def __init__(self, **kwargs: Any) -> None: self.graph_api_compute_endpoint: Optional[str] = None -class GraphAPIComputeServiceResource(_serialization.Model): - """Describes the service response property for GraphAPICompute. - - :ivar properties: Properties for GraphAPIComputeServiceResource. - :vartype properties: ~azure.mgmt.cosmosdb.models.GraphAPIComputeServiceResourceProperties - """ - - _attribute_map = { - "properties": {"key": "properties", "type": "GraphAPIComputeServiceResourceProperties"}, - } - - def __init__( - self, *, properties: Optional["_models.GraphAPIComputeServiceResourceProperties"] = None, **kwargs: Any - ) -> None: - """ - :keyword properties: Properties for GraphAPIComputeServiceResource. - :paramtype properties: ~azure.mgmt.cosmosdb.models.GraphAPIComputeServiceResourceProperties - """ - super().__init__(**kwargs) - self.properties = properties - - class GraphAPIComputeServiceResourceCreateUpdateProperties( ServiceResourceCreateUpdateProperties ): # pylint: disable=name-too-long @@ -9177,26 +9105,26 @@ class GraphResourceGetPropertiesResource(GraphResource): """ -class GraphResourceGetResults(ARMResourceProperties): +class GraphResourceGetResults(Resource): """An Azure Cosmos DB Graph resource. Variables are only populated by the server, and will be ignored when sending a request. - :ivar id: The unique resource identifier of the ARM resource. + :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 ARM resource. + :ivar name: The name of the resource. :vartype name: str - :ivar type: The type of Azure resource. + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". :vartype type: str - :ivar location: The location of the resource group to which the resource belongs. - :vartype location: str - :ivar tags: Tags are a list of key-value pairs that describe the resource. These tags can be - used in viewing and grouping this resource (across resource groups). A maximum of 15 tags can - be provided for a resource. Each tag must have a key no greater than 128 characters and value - no greater than 256 characters. For example, the default experience for a template type is set - with "defaultExperience": "Cassandra". Current "defaultExperience" values also include "Table", - "Graph", "DocumentDB", and "MongoDB". + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.cosmosdb.models.SystemData + :ivar tags: Resource tags. :vartype tags: dict[str, str] + :ivar location: The geo-location where the resource lives. + :vartype location: str :ivar identity: Identity for the resource. :vartype identity: ~azure.mgmt.cosmosdb.models.ManagedServiceIdentity :ivar resource: @@ -9209,14 +9137,16 @@ class GraphResourceGetResults(ARMResourceProperties): "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"}, - "location": {"key": "location", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, "tags": {"key": "tags", "type": "{str}"}, + "location": {"key": "location", "type": "str"}, "identity": {"key": "identity", "type": "ManagedServiceIdentity"}, "resource": {"key": "properties.resource", "type": "GraphResourceGetPropertiesResource"}, "options": {"key": "properties.options", "type": "GraphResourceGetPropertiesOptions"}, @@ -9225,23 +9155,18 @@ class GraphResourceGetResults(ARMResourceProperties): def __init__( self, *, - location: Optional[str] = None, tags: Optional[dict[str, str]] = None, + location: Optional[str] = None, identity: Optional["_models.ManagedServiceIdentity"] = None, resource: Optional["_models.GraphResourceGetPropertiesResource"] = None, options: Optional["_models.GraphResourceGetPropertiesOptions"] = None, **kwargs: Any ) -> None: """ - :keyword location: The location of the resource group to which the resource belongs. - :paramtype location: str - :keyword tags: Tags are a list of key-value pairs that describe the resource. These tags can be - used in viewing and grouping this resource (across resource groups). A maximum of 15 tags can - be provided for a resource. Each tag must have a key no greater than 128 characters and value - no greater than 256 characters. For example, the default experience for a template type is set - with "defaultExperience": "Cassandra". Current "defaultExperience" values also include "Table", - "Graph", "DocumentDB", and "MongoDB". + :keyword tags: Resource tags. :paramtype tags: dict[str, str] + :keyword location: The geo-location where the resource lives. + :paramtype location: str :keyword identity: Identity for the resource. :paramtype identity: ~azure.mgmt.cosmosdb.models.ManagedServiceIdentity :keyword resource: @@ -9249,7 +9174,10 @@ def __init__( :keyword options: :paramtype options: ~azure.mgmt.cosmosdb.models.GraphResourceGetPropertiesOptions """ - super().__init__(location=location, tags=tags, identity=identity, **kwargs) + super().__init__(**kwargs) + self.tags = tags + self.location = location + self.identity = identity self.resource = resource self.options = options @@ -9261,6 +9189,8 @@ class GraphResourcesListResult(_serialization.Model): :ivar value: List of Graph resource and their properties. :vartype value: list[~azure.mgmt.cosmosdb.models.GraphResourceGetResults] + :ivar next_link: + :vartype next_link: str """ _validation = { @@ -9269,12 +9199,17 @@ class GraphResourcesListResult(_serialization.Model): _attribute_map = { "value": {"key": "value", "type": "[GraphResourceGetResults]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__(self, **kwargs: Any) -> None: - """ """ + def __init__(self, *, next_link: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword next_link: + :paramtype next_link: str + """ super().__init__(**kwargs) self.value: Optional[list["_models.GraphResourceGetResults"]] = None + self.next_link = next_link class GremlinDatabaseCreateUpdateParameters(ARMResourceProperties): @@ -9399,7 +9334,7 @@ def __init__( *, id: str, # pylint: disable=redefined-builtin restore_parameters: Optional["_models.ResourceRestoreParameters"] = None, - create_mode: Union[str, "_models.CreateMode"] = "Default", + create_mode: Optional[Union[str, "_models.CreateMode"]] = None, **kwargs: Any ) -> None: """ @@ -9417,20 +9352,13 @@ def __init__( self.create_mode = create_mode -class GremlinDatabaseGetPropertiesResource(GremlinDatabaseResource, ExtendedResourceProperties): +class GremlinDatabaseGetPropertiesResource(GremlinDatabaseResource): """GremlinDatabaseGetPropertiesResource. 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 rid: A system generated property. A unique identifier. - :vartype rid: str - :ivar ts: A system generated property that denotes the last updated timestamp of the resource. - :vartype ts: float - :ivar etag: A system generated property representing the resource etag required for optimistic - concurrency control. - :vartype etag: str :ivar id: Name of the Cosmos DB Gremlin database. Required. :vartype id: str :ivar restore_parameters: Parameters to indicate the information about the restore. @@ -9438,22 +9366,29 @@ class GremlinDatabaseGetPropertiesResource(GremlinDatabaseResource, ExtendedReso :ivar create_mode: Enum to indicate the mode of resource creation. Known values are: "Default" and "Restore". :vartype create_mode: str or ~azure.mgmt.cosmosdb.models.CreateMode + :ivar rid: A system generated property. A unique identifier. + :vartype rid: str + :ivar ts: A system generated property that denotes the last updated timestamp of the resource. + :vartype ts: float + :ivar etag: A system generated property representing the resource etag required for optimistic + concurrency control. + :vartype etag: str """ _validation = { + "id": {"required": True}, "rid": {"readonly": True}, "ts": {"readonly": True}, "etag": {"readonly": True}, - "id": {"required": True}, } _attribute_map = { - "rid": {"key": "_rid", "type": "str"}, - "ts": {"key": "_ts", "type": "float"}, - "etag": {"key": "_etag", "type": "str"}, "id": {"key": "id", "type": "str"}, "restore_parameters": {"key": "restoreParameters", "type": "ResourceRestoreParameters"}, "create_mode": {"key": "createMode", "type": "str"}, + "rid": {"key": "_rid", "type": "str"}, + "ts": {"key": "_ts", "type": "float"}, + "etag": {"key": "_etag", "type": "str"}, } def __init__( @@ -9461,7 +9396,7 @@ def __init__( *, id: str, # pylint: disable=redefined-builtin restore_parameters: Optional["_models.ResourceRestoreParameters"] = None, - create_mode: Union[str, "_models.CreateMode"] = "Default", + create_mode: Optional[Union[str, "_models.CreateMode"]] = None, **kwargs: Any ) -> None: """ @@ -9477,31 +9412,28 @@ def __init__( self.rid: Optional[str] = None self.ts: Optional[float] = None self.etag: Optional[str] = None - self.id = id - self.restore_parameters = restore_parameters - self.create_mode = create_mode -class GremlinDatabaseGetResults(ARMResourceProperties): +class GremlinDatabaseGetResults(Resource): """An Azure Cosmos DB Gremlin database. Variables are only populated by the server, and will be ignored when sending a request. - :ivar id: The unique resource identifier of the ARM resource. + :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 ARM resource. + :ivar name: The name of the resource. :vartype name: str - :ivar type: The type of Azure resource. + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". :vartype type: str - :ivar location: The location of the resource group to which the resource belongs. - :vartype location: str - :ivar tags: Tags are a list of key-value pairs that describe the resource. These tags can be - used in viewing and grouping this resource (across resource groups). A maximum of 15 tags can - be provided for a resource. Each tag must have a key no greater than 128 characters and value - no greater than 256 characters. For example, the default experience for a template type is set - with "defaultExperience": "Cassandra". Current "defaultExperience" values also include "Table", - "Graph", "DocumentDB", and "MongoDB". + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.cosmosdb.models.SystemData + :ivar tags: Resource tags. :vartype tags: dict[str, str] + :ivar location: The geo-location where the resource lives. + :vartype location: str :ivar identity: Identity for the resource. :vartype identity: ~azure.mgmt.cosmosdb.models.ManagedServiceIdentity :ivar resource: @@ -9514,14 +9446,16 @@ class GremlinDatabaseGetResults(ARMResourceProperties): "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"}, - "location": {"key": "location", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, "tags": {"key": "tags", "type": "{str}"}, + "location": {"key": "location", "type": "str"}, "identity": {"key": "identity", "type": "ManagedServiceIdentity"}, "resource": {"key": "properties.resource", "type": "GremlinDatabaseGetPropertiesResource"}, "options": {"key": "properties.options", "type": "GremlinDatabaseGetPropertiesOptions"}, @@ -9530,23 +9464,18 @@ class GremlinDatabaseGetResults(ARMResourceProperties): def __init__( self, *, - location: Optional[str] = None, tags: Optional[dict[str, str]] = None, + location: Optional[str] = None, identity: Optional["_models.ManagedServiceIdentity"] = None, resource: Optional["_models.GremlinDatabaseGetPropertiesResource"] = None, options: Optional["_models.GremlinDatabaseGetPropertiesOptions"] = None, **kwargs: Any ) -> None: """ - :keyword location: The location of the resource group to which the resource belongs. - :paramtype location: str - :keyword tags: Tags are a list of key-value pairs that describe the resource. These tags can be - used in viewing and grouping this resource (across resource groups). A maximum of 15 tags can - be provided for a resource. Each tag must have a key no greater than 128 characters and value - no greater than 256 characters. For example, the default experience for a template type is set - with "defaultExperience": "Cassandra". Current "defaultExperience" values also include "Table", - "Graph", "DocumentDB", and "MongoDB". + :keyword tags: Resource tags. :paramtype tags: dict[str, str] + :keyword location: The geo-location where the resource lives. + :paramtype location: str :keyword identity: Identity for the resource. :paramtype identity: ~azure.mgmt.cosmosdb.models.ManagedServiceIdentity :keyword resource: @@ -9554,7 +9483,10 @@ def __init__( :keyword options: :paramtype options: ~azure.mgmt.cosmosdb.models.GremlinDatabaseGetPropertiesOptions """ - super().__init__(location=location, tags=tags, identity=identity, **kwargs) + super().__init__(**kwargs) + self.tags = tags + self.location = location + self.identity = identity self.resource = resource self.options = options @@ -9566,6 +9498,8 @@ class GremlinDatabaseListResult(_serialization.Model): :ivar value: List of Gremlin databases and their properties. :vartype value: list[~azure.mgmt.cosmosdb.models.GremlinDatabaseGetResults] + :ivar next_link: + :vartype next_link: str """ _validation = { @@ -9574,12 +9508,17 @@ class GremlinDatabaseListResult(_serialization.Model): _attribute_map = { "value": {"key": "value", "type": "[GremlinDatabaseGetResults]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__(self, **kwargs: Any) -> None: - """ """ + def __init__(self, *, next_link: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword next_link: + :paramtype next_link: str + """ super().__init__(**kwargs) self.value: Optional[list["_models.GremlinDatabaseGetResults"]] = None + self.next_link = next_link class GremlinDatabaseRestoreResource(_serialization.Model): @@ -9759,7 +9698,7 @@ def __init__( conflict_resolution_policy: Optional["_models.ConflictResolutionPolicy"] = None, analytical_storage_ttl: Optional[int] = None, restore_parameters: Optional["_models.ResourceRestoreParameters"] = None, - create_mode: Union[str, "_models.CreateMode"] = "Default", + create_mode: Optional[Union[str, "_models.CreateMode"]] = None, **kwargs: Any ) -> None: """ @@ -9798,20 +9737,13 @@ def __init__( self.create_mode = create_mode -class GremlinGraphGetPropertiesResource(GremlinGraphResource, ExtendedResourceProperties): +class GremlinGraphGetPropertiesResource(GremlinGraphResource): """GremlinGraphGetPropertiesResource. 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 rid: A system generated property. A unique identifier. - :vartype rid: str - :ivar ts: A system generated property that denotes the last updated timestamp of the resource. - :vartype ts: float - :ivar etag: A system generated property representing the resource etag required for optimistic - concurrency control. - :vartype etag: str :ivar id: Name of the Cosmos DB Gremlin graph. Required. :vartype id: str :ivar indexing_policy: The configuration of the indexing policy. By default, the indexing is @@ -9834,19 +9766,23 @@ class GremlinGraphGetPropertiesResource(GremlinGraphResource, ExtendedResourcePr :ivar create_mode: Enum to indicate the mode of resource creation. Known values are: "Default" and "Restore". :vartype create_mode: str or ~azure.mgmt.cosmosdb.models.CreateMode + :ivar rid: A system generated property. A unique identifier. + :vartype rid: str + :ivar ts: A system generated property that denotes the last updated timestamp of the resource. + :vartype ts: float + :ivar etag: A system generated property representing the resource etag required for optimistic + concurrency control. + :vartype etag: str """ _validation = { + "id": {"required": True}, "rid": {"readonly": True}, "ts": {"readonly": True}, "etag": {"readonly": True}, - "id": {"required": True}, } _attribute_map = { - "rid": {"key": "_rid", "type": "str"}, - "ts": {"key": "_ts", "type": "float"}, - "etag": {"key": "_etag", "type": "str"}, "id": {"key": "id", "type": "str"}, "indexing_policy": {"key": "indexingPolicy", "type": "IndexingPolicy"}, "partition_key": {"key": "partitionKey", "type": "ContainerPartitionKey"}, @@ -9856,6 +9792,9 @@ class GremlinGraphGetPropertiesResource(GremlinGraphResource, ExtendedResourcePr "analytical_storage_ttl": {"key": "analyticalStorageTtl", "type": "int"}, "restore_parameters": {"key": "restoreParameters", "type": "ResourceRestoreParameters"}, "create_mode": {"key": "createMode", "type": "str"}, + "rid": {"key": "_rid", "type": "str"}, + "ts": {"key": "_ts", "type": "float"}, + "etag": {"key": "_etag", "type": "str"}, } def __init__( @@ -9869,7 +9808,7 @@ def __init__( conflict_resolution_policy: Optional["_models.ConflictResolutionPolicy"] = None, analytical_storage_ttl: Optional[int] = None, restore_parameters: Optional["_models.ResourceRestoreParameters"] = None, - create_mode: Union[str, "_models.CreateMode"] = "Default", + create_mode: Optional[Union[str, "_models.CreateMode"]] = None, **kwargs: Any ) -> None: """ @@ -9911,37 +9850,28 @@ def __init__( self.rid: Optional[str] = None self.ts: Optional[float] = None self.etag: Optional[str] = None - self.id = id - self.indexing_policy = indexing_policy - self.partition_key = partition_key - self.default_ttl = default_ttl - self.unique_key_policy = unique_key_policy - self.conflict_resolution_policy = conflict_resolution_policy - self.analytical_storage_ttl = analytical_storage_ttl - self.restore_parameters = restore_parameters - self.create_mode = create_mode -class GremlinGraphGetResults(ARMResourceProperties): +class GremlinGraphGetResults(Resource): """An Azure Cosmos DB Gremlin graph. Variables are only populated by the server, and will be ignored when sending a request. - :ivar id: The unique resource identifier of the ARM resource. + :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 ARM resource. + :ivar name: The name of the resource. :vartype name: str - :ivar type: The type of Azure resource. + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". :vartype type: str - :ivar location: The location of the resource group to which the resource belongs. - :vartype location: str - :ivar tags: Tags are a list of key-value pairs that describe the resource. These tags can be - used in viewing and grouping this resource (across resource groups). A maximum of 15 tags can - be provided for a resource. Each tag must have a key no greater than 128 characters and value - no greater than 256 characters. For example, the default experience for a template type is set - with "defaultExperience": "Cassandra". Current "defaultExperience" values also include "Table", - "Graph", "DocumentDB", and "MongoDB". + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.cosmosdb.models.SystemData + :ivar tags: Resource tags. :vartype tags: dict[str, str] + :ivar location: The geo-location where the resource lives. + :vartype location: str :ivar identity: Identity for the resource. :vartype identity: ~azure.mgmt.cosmosdb.models.ManagedServiceIdentity :ivar resource: @@ -9954,14 +9884,16 @@ class GremlinGraphGetResults(ARMResourceProperties): "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"}, - "location": {"key": "location", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, "tags": {"key": "tags", "type": "{str}"}, + "location": {"key": "location", "type": "str"}, "identity": {"key": "identity", "type": "ManagedServiceIdentity"}, "resource": {"key": "properties.resource", "type": "GremlinGraphGetPropertiesResource"}, "options": {"key": "properties.options", "type": "GremlinGraphGetPropertiesOptions"}, @@ -9970,23 +9902,18 @@ class GremlinGraphGetResults(ARMResourceProperties): def __init__( self, *, - location: Optional[str] = None, tags: Optional[dict[str, str]] = None, + location: Optional[str] = None, identity: Optional["_models.ManagedServiceIdentity"] = None, resource: Optional["_models.GremlinGraphGetPropertiesResource"] = None, options: Optional["_models.GremlinGraphGetPropertiesOptions"] = None, **kwargs: Any ) -> None: """ - :keyword location: The location of the resource group to which the resource belongs. - :paramtype location: str - :keyword tags: Tags are a list of key-value pairs that describe the resource. These tags can be - used in viewing and grouping this resource (across resource groups). A maximum of 15 tags can - be provided for a resource. Each tag must have a key no greater than 128 characters and value - no greater than 256 characters. For example, the default experience for a template type is set - with "defaultExperience": "Cassandra". Current "defaultExperience" values also include "Table", - "Graph", "DocumentDB", and "MongoDB". + :keyword tags: Resource tags. :paramtype tags: dict[str, str] + :keyword location: The geo-location where the resource lives. + :paramtype location: str :keyword identity: Identity for the resource. :paramtype identity: ~azure.mgmt.cosmosdb.models.ManagedServiceIdentity :keyword resource: @@ -9994,10 +9921,13 @@ def __init__( :keyword options: :paramtype options: ~azure.mgmt.cosmosdb.models.GremlinGraphGetPropertiesOptions """ - super().__init__(location=location, tags=tags, identity=identity, **kwargs) - self.resource = resource - self.options = options - + super().__init__(**kwargs) + self.tags = tags + self.location = location + self.identity = identity + self.resource = resource + self.options = options + class GremlinGraphListResult(_serialization.Model): """The List operation response, that contains the graphs and their properties. @@ -10006,6 +9936,8 @@ class GremlinGraphListResult(_serialization.Model): :ivar value: List of graphs and their properties. :vartype value: list[~azure.mgmt.cosmosdb.models.GremlinGraphGetResults] + :ivar next_link: + :vartype next_link: str """ _validation = { @@ -10014,28 +9946,32 @@ class GremlinGraphListResult(_serialization.Model): _attribute_map = { "value": {"key": "value", "type": "[GremlinGraphGetResults]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__(self, **kwargs: Any) -> None: - """ """ + def __init__(self, *, next_link: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword next_link: + :paramtype next_link: str + """ super().__init__(**kwargs) self.value: Optional[list["_models.GremlinGraphGetResults"]] = None + self.next_link = next_link class GremlinRoleAssignmentListResult(_serialization.Model): - """The relevant Role Assignments. + """The response of a GremlinRoleAssignmentResource list operation. - 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 value: List of Role Assignments and their properties. + :ivar value: The GremlinRoleAssignmentResource items on this page. Required. :vartype value: list[~azure.mgmt.cosmosdb.models.GremlinRoleAssignmentResource] - :ivar next_link: The link used to get the next page of results. + :ivar next_link: The link to the next page of items. :vartype next_link: str """ _validation = { - "value": {"readonly": True}, - "next_link": {"readonly": True}, + "value": {"required": True}, } _attribute_map = { @@ -10043,11 +9979,18 @@ class GremlinRoleAssignmentListResult(_serialization.Model): "next_link": {"key": "nextLink", "type": "str"}, } - def __init__(self, **kwargs: Any) -> None: - """ """ + def __init__( + self, *, value: list["_models.GremlinRoleAssignmentResource"], next_link: Optional[str] = None, **kwargs: Any + ) -> None: + """ + :keyword value: The GremlinRoleAssignmentResource items on this page. Required. + :paramtype value: list[~azure.mgmt.cosmosdb.models.GremlinRoleAssignmentResource] + :keyword next_link: The link to the next page of items. + :paramtype next_link: str + """ super().__init__(**kwargs) - self.value: Optional[list["_models.GremlinRoleAssignmentResource"]] = None - self.next_link: Optional[str] = None + self.value = value + self.next_link = next_link class GremlinRoleAssignmentResource(ProxyResource): @@ -10125,19 +10068,18 @@ def __init__( class GremlinRoleDefinitionListResult(_serialization.Model): - """The relevant Role Definitions. + """The response of a GremlinRoleDefinitionResource list operation. - 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 value: List of Role Definitions and their properties. + :ivar value: The GremlinRoleDefinitionResource items on this page. Required. :vartype value: list[~azure.mgmt.cosmosdb.models.GremlinRoleDefinitionResource] - :ivar next_link: The link used to get the next page of results. + :ivar next_link: The link to the next page of items. :vartype next_link: str """ _validation = { - "value": {"readonly": True}, - "next_link": {"readonly": True}, + "value": {"required": True}, } _attribute_map = { @@ -10145,11 +10087,18 @@ class GremlinRoleDefinitionListResult(_serialization.Model): "next_link": {"key": "nextLink", "type": "str"}, } - def __init__(self, **kwargs: Any) -> None: - """ """ + def __init__( + self, *, value: list["_models.GremlinRoleDefinitionResource"], next_link: Optional[str] = None, **kwargs: Any + ) -> None: + """ + :keyword value: The GremlinRoleDefinitionResource items on this page. Required. + :paramtype value: list[~azure.mgmt.cosmosdb.models.GremlinRoleDefinitionResource] + :keyword next_link: The link to the next page of items. + :paramtype next_link: str + """ super().__init__(**kwargs) - self.value: Optional[list["_models.GremlinRoleDefinitionResource"]] = None - self.next_link: Optional[str] = None + self.value = value + self.next_link = next_link class GremlinRoleDefinitionResource(ProxyResource): @@ -10469,6 +10418,8 @@ class ListBackups(_serialization.Model): :ivar value: Container for array of backups. :vartype value: list[~azure.mgmt.cosmosdb.models.BackupResource] + :ivar next_link: + :vartype next_link: str """ _validation = { @@ -10477,12 +10428,17 @@ class ListBackups(_serialization.Model): _attribute_map = { "value": {"key": "value", "type": "[BackupResource]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__(self, **kwargs: Any) -> None: - """ """ + def __init__(self, *, next_link: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword next_link: + :paramtype next_link: str + """ super().__init__(**kwargs) self.value: Optional[list["_models.BackupResource"]] = None + self.next_link = next_link class ListClusters(_serialization.Model): @@ -10490,19 +10446,27 @@ class ListClusters(_serialization.Model): :ivar value: Container for the array of clusters. :vartype value: list[~azure.mgmt.cosmosdb.models.ClusterResource] + :ivar next_link: + :vartype next_link: str """ _attribute_map = { "value": {"key": "value", "type": "[ClusterResource]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__(self, *, value: Optional[list["_models.ClusterResource"]] = None, **kwargs: Any) -> None: + def __init__( + self, *, value: Optional[list["_models.ClusterResource"]] = None, next_link: Optional[str] = None, **kwargs: Any + ) -> None: """ :keyword value: Container for the array of clusters. :paramtype value: list[~azure.mgmt.cosmosdb.models.ClusterResource] + :keyword next_link: + :paramtype next_link: str """ super().__init__(**kwargs) self.value = value + self.next_link = next_link class ListCommands(_serialization.Model): @@ -10512,6 +10476,8 @@ class ListCommands(_serialization.Model): :ivar value: Container for array of commands. :vartype value: list[~azure.mgmt.cosmosdb.models.CommandPublicResource] + :ivar next_link: + :vartype next_link: str """ _validation = { @@ -10520,12 +10486,17 @@ class ListCommands(_serialization.Model): _attribute_map = { "value": {"key": "value", "type": "[CommandPublicResource]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__(self, **kwargs: Any) -> None: - """ """ + def __init__(self, *, next_link: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword next_link: + :paramtype next_link: str + """ super().__init__(**kwargs) self.value: Optional[list["_models.CommandPublicResource"]] = None + self.next_link = next_link class ListDataCenters(_serialization.Model): @@ -10535,6 +10506,8 @@ class ListDataCenters(_serialization.Model): :ivar value: Container for array of data centers. :vartype value: list[~azure.mgmt.cosmosdb.models.DataCenterResource] + :ivar next_link: + :vartype next_link: str """ _validation = { @@ -10543,40 +10516,49 @@ class ListDataCenters(_serialization.Model): _attribute_map = { "value": {"key": "value", "type": "[DataCenterResource]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__(self, **kwargs: Any) -> None: - """ """ + def __init__(self, *, next_link: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword next_link: + :paramtype next_link: str + """ super().__init__(**kwargs) self.value: Optional[list["_models.DataCenterResource"]] = None + self.next_link = next_link class ListGarnetClusters(_serialization.Model): """List of Garnet clusters. - Variables are only populated by the server, and will be ignored when sending a request. - :ivar value: Container for the array of clusters. :vartype value: list[~azure.mgmt.cosmosdb.models.GarnetClusterResource] :ivar next_link: The link used to get the next page of results. :vartype next_link: str """ - _validation = { - "value": {"readonly": True}, - "next_link": {"readonly": True}, - } - _attribute_map = { "value": {"key": "value", "type": "[GarnetClusterResource]"}, "next_link": {"key": "nextLink", "type": "str"}, } - def __init__(self, **kwargs: Any) -> None: - """ """ + def __init__( + self, + *, + value: Optional[list["_models.GarnetClusterResource"]] = None, + next_link: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword value: Container for the array of clusters. + :paramtype value: list[~azure.mgmt.cosmosdb.models.GarnetClusterResource] + :keyword next_link: The link used to get the next page of results. + :paramtype next_link: str + """ super().__init__(**kwargs) - self.value: Optional[list["_models.GarnetClusterResource"]] = None - self.next_link: Optional[str] = None + self.value = value + self.next_link = next_link class Location(_serialization.Model): @@ -10649,17 +10631,22 @@ def __init__( self.is_zone_redundant = is_zone_redundant -class LocationGetResult(ARMProxyResource): +class LocationGetResult(ProxyResource): """Cosmos DB location get result. Variables are only populated by the server, and will be ignored when sending a request. - :ivar id: The unique resource identifier of the database account. + :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 database account. + :ivar name: The name of the resource. :vartype name: str - :ivar type: The type of Azure resource. + :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.cosmosdb.models.SystemData :ivar properties: Cosmos DB location metadata. :vartype properties: ~azure.mgmt.cosmosdb.models.LocationProperties """ @@ -10668,12 +10655,14 @@ class LocationGetResult(ARMProxyResource): "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"}, "properties": {"key": "properties", "type": "LocationProperties"}, } @@ -10693,6 +10682,8 @@ class LocationListResult(_serialization.Model): :ivar value: List of Cosmos DB locations and their properties. :vartype value: list[~azure.mgmt.cosmosdb.models.LocationGetResult] + :ivar next_link: + :vartype next_link: str """ _validation = { @@ -10701,12 +10692,17 @@ class LocationListResult(_serialization.Model): _attribute_map = { "value": {"key": "value", "type": "[LocationGetResult]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__(self, **kwargs: Any) -> None: - """ """ + def __init__(self, *, next_link: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword next_link: + :paramtype next_link: str + """ super().__init__(**kwargs) self.value: Optional[list["_models.LocationGetResult"]] = None + self.next_link = next_link class LocationProperties(_serialization.Model): @@ -10729,8 +10725,8 @@ class LocationProperties(_serialization.Model): have access in region for Availability Zones(Az). :vartype is_subscription_region_access_allowed_for_az: bool :ivar status: Enum to indicate current buildout status of the region. Known values are: - "Uninitialized", "Initializing", "InternallyReady", "Online", "Deleting", "Creating", - "Succeeded", "Failed", "Canceled", and "Updating". + "Uninitialized", "Initializing", "InternallyReady", "Online", "Deleting", "Succeeded", + "Failed", "Canceled", "Updating", and "Creating". :vartype status: str or ~azure.mgmt.cosmosdb.models.Status """ @@ -10865,7 +10861,7 @@ class ManagedServiceIdentity(_serialization.Model): identity dictionary key references will be ARM resource ids in the form: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}'. :vartype user_assigned_identities: dict[str, - ~azure.mgmt.cosmosdb.models.ManagedServiceIdentityUserAssignedIdentity] + ~azure.mgmt.cosmosdb.models.ManagedServiceIdentityUserAssignedIdentities] """ _validation = { @@ -10879,7 +10875,7 @@ class ManagedServiceIdentity(_serialization.Model): "type": {"key": "type", "type": "str"}, "user_assigned_identities": { "key": "userAssignedIdentities", - "type": "{ManagedServiceIdentityUserAssignedIdentity}", + "type": "{ManagedServiceIdentityUserAssignedIdentities}", }, } @@ -10887,7 +10883,7 @@ def __init__( self, *, type: Optional[Union[str, "_models.ResourceIdentityType"]] = None, - user_assigned_identities: Optional[dict[str, "_models.ManagedServiceIdentityUserAssignedIdentity"]] = None, + user_assigned_identities: Optional[dict[str, "_models.ManagedServiceIdentityUserAssignedIdentities"]] = None, **kwargs: Any ) -> None: """ @@ -10900,7 +10896,7 @@ def __init__( user identity dictionary key references will be ARM resource ids in the form: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}'. :paramtype user_assigned_identities: dict[str, - ~azure.mgmt.cosmosdb.models.ManagedServiceIdentityUserAssignedIdentity] + ~azure.mgmt.cosmosdb.models.ManagedServiceIdentityUserAssignedIdentities] """ super().__init__(**kwargs) self.principal_id: Optional[str] = None @@ -10909,8 +10905,8 @@ def __init__( self.user_assigned_identities = user_assigned_identities -class ManagedServiceIdentityUserAssignedIdentity(_serialization.Model): # pylint: disable=name-too-long - """ManagedServiceIdentityUserAssignedIdentity. +class ManagedServiceIdentityUserAssignedIdentities(_serialization.Model): # pylint: disable=name-too-long + """ManagedServiceIdentityUserAssignedIdentities. Variables are only populated by the server, and will be ignored when sending a request. @@ -11040,30 +11036,6 @@ class MaterializedViewsBuilderRegionalServiceResource(RegionalServiceResource): """ -class MaterializedViewsBuilderServiceResource(_serialization.Model): - """Describes the service response property for MaterializedViewsBuilder. - - :ivar properties: Properties for MaterializedViewsBuilderServiceResource. - :vartype properties: - ~azure.mgmt.cosmosdb.models.MaterializedViewsBuilderServiceResourceProperties - """ - - _attribute_map = { - "properties": {"key": "properties", "type": "MaterializedViewsBuilderServiceResourceProperties"}, - } - - def __init__( - self, *, properties: Optional["_models.MaterializedViewsBuilderServiceResourceProperties"] = None, **kwargs: Any - ) -> None: - """ - :keyword properties: Properties for MaterializedViewsBuilderServiceResource. - :paramtype properties: - ~azure.mgmt.cosmosdb.models.MaterializedViewsBuilderServiceResourceProperties - """ - super().__init__(**kwargs) - self.properties = properties - - class MaterializedViewsBuilderServiceResourceCreateUpdateProperties( ServiceResourceCreateUpdateProperties ): # pylint: disable=name-too-long @@ -11355,6 +11327,8 @@ class MetricDefinitionsListResult(_serialization.Model): :ivar value: The list of metric definitions for the account. :vartype value: list[~azure.mgmt.cosmosdb.models.MetricDefinition] + :ivar next_link: + :vartype next_link: str """ _validation = { @@ -11363,12 +11337,17 @@ class MetricDefinitionsListResult(_serialization.Model): _attribute_map = { "value": {"key": "value", "type": "[MetricDefinition]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__(self, **kwargs: Any) -> None: - """ """ + def __init__(self, *, next_link: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword next_link: + :paramtype next_link: str + """ super().__init__(**kwargs) self.value: Optional[list["_models.MetricDefinition"]] = None + self.next_link = next_link class MetricListResult(_serialization.Model): @@ -11378,6 +11357,8 @@ class MetricListResult(_serialization.Model): :ivar value: The list of metrics for the account. :vartype value: list[~azure.mgmt.cosmosdb.models.Metric] + :ivar next_link: + :vartype next_link: str """ _validation = { @@ -11386,12 +11367,17 @@ class MetricListResult(_serialization.Model): _attribute_map = { "value": {"key": "value", "type": "[Metric]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__(self, **kwargs: Any) -> None: - """ """ + def __init__(self, *, next_link: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword next_link: + :paramtype next_link: str + """ super().__init__(**kwargs) self.value: Optional[list["_models.Metric"]] = None + self.next_link = next_link class MetricName(_serialization.Model): @@ -11604,7 +11590,7 @@ def __init__( indexes: Optional[list["_models.MongoIndex"]] = None, analytical_storage_ttl: Optional[int] = None, restore_parameters: Optional["_models.ResourceRestoreParameters"] = None, - create_mode: Union[str, "_models.CreateMode"] = "Default", + create_mode: Optional[Union[str, "_models.CreateMode"]] = None, **kwargs: Any ) -> None: """ @@ -11631,20 +11617,13 @@ def __init__( self.create_mode = create_mode -class MongoDBCollectionGetPropertiesResource(MongoDBCollectionResource, ExtendedResourceProperties): +class MongoDBCollectionGetPropertiesResource(MongoDBCollectionResource): """MongoDBCollectionGetPropertiesResource. 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 rid: A system generated property. A unique identifier. - :vartype rid: str - :ivar ts: A system generated property that denotes the last updated timestamp of the resource. - :vartype ts: float - :ivar etag: A system generated property representing the resource etag required for optimistic - concurrency control. - :vartype etag: str :ivar id: Name of the Cosmos DB MongoDB collection. Required. :vartype id: str :ivar shard_key: A key-value pair of shard keys to be applied for the request. @@ -11658,25 +11637,32 @@ class MongoDBCollectionGetPropertiesResource(MongoDBCollectionResource, Extended :ivar create_mode: Enum to indicate the mode of resource creation. Known values are: "Default" and "Restore". :vartype create_mode: str or ~azure.mgmt.cosmosdb.models.CreateMode + :ivar rid: A system generated property. A unique identifier. + :vartype rid: str + :ivar ts: A system generated property that denotes the last updated timestamp of the resource. + :vartype ts: float + :ivar etag: A system generated property representing the resource etag required for optimistic + concurrency control. + :vartype etag: str """ _validation = { + "id": {"required": True}, "rid": {"readonly": True}, "ts": {"readonly": True}, "etag": {"readonly": True}, - "id": {"required": True}, } _attribute_map = { - "rid": {"key": "_rid", "type": "str"}, - "ts": {"key": "_ts", "type": "float"}, - "etag": {"key": "_etag", "type": "str"}, "id": {"key": "id", "type": "str"}, "shard_key": {"key": "shardKey", "type": "{str}"}, "indexes": {"key": "indexes", "type": "[MongoIndex]"}, "analytical_storage_ttl": {"key": "analyticalStorageTtl", "type": "int"}, "restore_parameters": {"key": "restoreParameters", "type": "ResourceRestoreParameters"}, "create_mode": {"key": "createMode", "type": "str"}, + "rid": {"key": "_rid", "type": "str"}, + "ts": {"key": "_ts", "type": "float"}, + "etag": {"key": "_etag", "type": "str"}, } def __init__( @@ -11687,7 +11673,7 @@ def __init__( indexes: Optional[list["_models.MongoIndex"]] = None, analytical_storage_ttl: Optional[int] = None, restore_parameters: Optional["_models.ResourceRestoreParameters"] = None, - create_mode: Union[str, "_models.CreateMode"] = "Default", + create_mode: Optional[Union[str, "_models.CreateMode"]] = None, **kwargs: Any ) -> None: """ @@ -11717,34 +11703,28 @@ def __init__( self.rid: Optional[str] = None self.ts: Optional[float] = None self.etag: Optional[str] = None - self.id = id - self.shard_key = shard_key - self.indexes = indexes - self.analytical_storage_ttl = analytical_storage_ttl - self.restore_parameters = restore_parameters - self.create_mode = create_mode -class MongoDBCollectionGetResults(ARMResourceProperties): +class MongoDBCollectionGetResults(Resource): """An Azure Cosmos DB MongoDB collection. Variables are only populated by the server, and will be ignored when sending a request. - :ivar id: The unique resource identifier of the ARM resource. + :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 ARM resource. + :ivar name: The name of the resource. :vartype name: str - :ivar type: The type of Azure resource. + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". :vartype type: str - :ivar location: The location of the resource group to which the resource belongs. - :vartype location: str - :ivar tags: Tags are a list of key-value pairs that describe the resource. These tags can be - used in viewing and grouping this resource (across resource groups). A maximum of 15 tags can - be provided for a resource. Each tag must have a key no greater than 128 characters and value - no greater than 256 characters. For example, the default experience for a template type is set - with "defaultExperience": "Cassandra". Current "defaultExperience" values also include "Table", - "Graph", "DocumentDB", and "MongoDB". + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.cosmosdb.models.SystemData + :ivar tags: Resource tags. :vartype tags: dict[str, str] + :ivar location: The geo-location where the resource lives. + :vartype location: str :ivar identity: Identity for the resource. :vartype identity: ~azure.mgmt.cosmosdb.models.ManagedServiceIdentity :ivar resource: @@ -11757,14 +11737,16 @@ class MongoDBCollectionGetResults(ARMResourceProperties): "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"}, - "location": {"key": "location", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, "tags": {"key": "tags", "type": "{str}"}, + "location": {"key": "location", "type": "str"}, "identity": {"key": "identity", "type": "ManagedServiceIdentity"}, "resource": {"key": "properties.resource", "type": "MongoDBCollectionGetPropertiesResource"}, "options": {"key": "properties.options", "type": "MongoDBCollectionGetPropertiesOptions"}, @@ -11773,23 +11755,18 @@ class MongoDBCollectionGetResults(ARMResourceProperties): def __init__( self, *, - location: Optional[str] = None, tags: Optional[dict[str, str]] = None, + location: Optional[str] = None, identity: Optional["_models.ManagedServiceIdentity"] = None, resource: Optional["_models.MongoDBCollectionGetPropertiesResource"] = None, options: Optional["_models.MongoDBCollectionGetPropertiesOptions"] = None, **kwargs: Any ) -> None: """ - :keyword location: The location of the resource group to which the resource belongs. - :paramtype location: str - :keyword tags: Tags are a list of key-value pairs that describe the resource. These tags can be - used in viewing and grouping this resource (across resource groups). A maximum of 15 tags can - be provided for a resource. Each tag must have a key no greater than 128 characters and value - no greater than 256 characters. For example, the default experience for a template type is set - with "defaultExperience": "Cassandra". Current "defaultExperience" values also include "Table", - "Graph", "DocumentDB", and "MongoDB". + :keyword tags: Resource tags. :paramtype tags: dict[str, str] + :keyword location: The geo-location where the resource lives. + :paramtype location: str :keyword identity: Identity for the resource. :paramtype identity: ~azure.mgmt.cosmosdb.models.ManagedServiceIdentity :keyword resource: @@ -11797,7 +11774,10 @@ def __init__( :keyword options: :paramtype options: ~azure.mgmt.cosmosdb.models.MongoDBCollectionGetPropertiesOptions """ - super().__init__(location=location, tags=tags, identity=identity, **kwargs) + super().__init__(**kwargs) + self.tags = tags + self.location = location + self.identity = identity self.resource = resource self.options = options @@ -11809,6 +11789,8 @@ class MongoDBCollectionListResult(_serialization.Model): :ivar value: List of MongoDB collections and their properties. :vartype value: list[~azure.mgmt.cosmosdb.models.MongoDBCollectionGetResults] + :ivar next_link: + :vartype next_link: str """ _validation = { @@ -11817,12 +11799,17 @@ class MongoDBCollectionListResult(_serialization.Model): _attribute_map = { "value": {"key": "value", "type": "[MongoDBCollectionGetResults]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__(self, **kwargs: Any) -> None: - """ """ + def __init__(self, *, next_link: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword next_link: + :paramtype next_link: str + """ super().__init__(**kwargs) self.value: Optional[list["_models.MongoDBCollectionGetResults"]] = None + self.next_link = next_link class MongoDBDatabaseCreateUpdateParameters(ARMResourceProperties): @@ -11927,7 +11914,7 @@ class MongoDBDatabaseResource(_serialization.Model): :vartype id: str :ivar restore_parameters: Parameters to indicate the information about the restore. :vartype restore_parameters: ~azure.mgmt.cosmosdb.models.ResourceRestoreParameters - :ivar create_mode: Enum to indicate the mode of resource creation. Known values are: "Default" + :ivar create_mode: Enum to indicate the mode of account creation. Known values are: "Default" and "Restore". :vartype create_mode: str or ~azure.mgmt.cosmosdb.models.CreateMode """ @@ -11947,7 +11934,7 @@ def __init__( *, id: str, # pylint: disable=redefined-builtin restore_parameters: Optional["_models.ResourceRestoreParameters"] = None, - create_mode: Union[str, "_models.CreateMode"] = "Default", + create_mode: Optional[Union[str, "_models.CreateMode"]] = None, **kwargs: Any ) -> None: """ @@ -11955,7 +11942,7 @@ def __init__( :paramtype id: str :keyword restore_parameters: Parameters to indicate the information about the restore. :paramtype restore_parameters: ~azure.mgmt.cosmosdb.models.ResourceRestoreParameters - :keyword create_mode: Enum to indicate the mode of resource creation. Known values are: + :keyword create_mode: Enum to indicate the mode of account creation. Known values are: "Default" and "Restore". :paramtype create_mode: str or ~azure.mgmt.cosmosdb.models.CreateMode """ @@ -11965,13 +11952,20 @@ def __init__( self.create_mode = create_mode -class MongoDBDatabaseGetPropertiesResource(MongoDBDatabaseResource, ExtendedResourceProperties): +class MongoDBDatabaseGetPropertiesResource(MongoDBDatabaseResource): """MongoDBDatabaseGetPropertiesResource. 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: Name of the Cosmos DB MongoDB database. Required. + :vartype id: str + :ivar restore_parameters: Parameters to indicate the information about the restore. + :vartype restore_parameters: ~azure.mgmt.cosmosdb.models.ResourceRestoreParameters + :ivar create_mode: Enum to indicate the mode of account creation. Known values are: "Default" + and "Restore". + :vartype create_mode: str or ~azure.mgmt.cosmosdb.models.CreateMode :ivar rid: A system generated property. A unique identifier. :vartype rid: str :ivar ts: A system generated property that denotes the last updated timestamp of the resource. @@ -11979,29 +11973,22 @@ class MongoDBDatabaseGetPropertiesResource(MongoDBDatabaseResource, ExtendedReso :ivar etag: A system generated property representing the resource etag required for optimistic concurrency control. :vartype etag: str - :ivar id: Name of the Cosmos DB MongoDB database. Required. - :vartype id: str - :ivar restore_parameters: Parameters to indicate the information about the restore. - :vartype restore_parameters: ~azure.mgmt.cosmosdb.models.ResourceRestoreParameters - :ivar create_mode: Enum to indicate the mode of resource creation. Known values are: "Default" - and "Restore". - :vartype create_mode: str or ~azure.mgmt.cosmosdb.models.CreateMode """ _validation = { + "id": {"required": True}, "rid": {"readonly": True}, "ts": {"readonly": True}, "etag": {"readonly": True}, - "id": {"required": True}, } _attribute_map = { - "rid": {"key": "_rid", "type": "str"}, - "ts": {"key": "_ts", "type": "float"}, - "etag": {"key": "_etag", "type": "str"}, "id": {"key": "id", "type": "str"}, "restore_parameters": {"key": "restoreParameters", "type": "ResourceRestoreParameters"}, "create_mode": {"key": "createMode", "type": "str"}, + "rid": {"key": "_rid", "type": "str"}, + "ts": {"key": "_ts", "type": "float"}, + "etag": {"key": "_etag", "type": "str"}, } def __init__( @@ -12009,7 +11996,7 @@ def __init__( *, id: str, # pylint: disable=redefined-builtin restore_parameters: Optional["_models.ResourceRestoreParameters"] = None, - create_mode: Union[str, "_models.CreateMode"] = "Default", + create_mode: Optional[Union[str, "_models.CreateMode"]] = None, **kwargs: Any ) -> None: """ @@ -12017,7 +12004,7 @@ def __init__( :paramtype id: str :keyword restore_parameters: Parameters to indicate the information about the restore. :paramtype restore_parameters: ~azure.mgmt.cosmosdb.models.ResourceRestoreParameters - :keyword create_mode: Enum to indicate the mode of resource creation. Known values are: + :keyword create_mode: Enum to indicate the mode of account creation. Known values are: "Default" and "Restore". :paramtype create_mode: str or ~azure.mgmt.cosmosdb.models.CreateMode """ @@ -12025,31 +12012,28 @@ def __init__( self.rid: Optional[str] = None self.ts: Optional[float] = None self.etag: Optional[str] = None - self.id = id - self.restore_parameters = restore_parameters - self.create_mode = create_mode -class MongoDBDatabaseGetResults(ARMResourceProperties): +class MongoDBDatabaseGetResults(Resource): """An Azure Cosmos DB MongoDB database. Variables are only populated by the server, and will be ignored when sending a request. - :ivar id: The unique resource identifier of the ARM resource. + :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 ARM resource. + :ivar name: The name of the resource. :vartype name: str - :ivar type: The type of Azure resource. + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". :vartype type: str - :ivar location: The location of the resource group to which the resource belongs. - :vartype location: str - :ivar tags: Tags are a list of key-value pairs that describe the resource. These tags can be - used in viewing and grouping this resource (across resource groups). A maximum of 15 tags can - be provided for a resource. Each tag must have a key no greater than 128 characters and value - no greater than 256 characters. For example, the default experience for a template type is set - with "defaultExperience": "Cassandra". Current "defaultExperience" values also include "Table", - "Graph", "DocumentDB", and "MongoDB". + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.cosmosdb.models.SystemData + :ivar tags: Resource tags. :vartype tags: dict[str, str] + :ivar location: The geo-location where the resource lives. + :vartype location: str :ivar identity: Identity for the resource. :vartype identity: ~azure.mgmt.cosmosdb.models.ManagedServiceIdentity :ivar resource: @@ -12062,14 +12046,16 @@ class MongoDBDatabaseGetResults(ARMResourceProperties): "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"}, - "location": {"key": "location", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, "tags": {"key": "tags", "type": "{str}"}, + "location": {"key": "location", "type": "str"}, "identity": {"key": "identity", "type": "ManagedServiceIdentity"}, "resource": {"key": "properties.resource", "type": "MongoDBDatabaseGetPropertiesResource"}, "options": {"key": "properties.options", "type": "MongoDBDatabaseGetPropertiesOptions"}, @@ -12078,23 +12064,18 @@ class MongoDBDatabaseGetResults(ARMResourceProperties): def __init__( self, *, - location: Optional[str] = None, tags: Optional[dict[str, str]] = None, + location: Optional[str] = None, identity: Optional["_models.ManagedServiceIdentity"] = None, resource: Optional["_models.MongoDBDatabaseGetPropertiesResource"] = None, options: Optional["_models.MongoDBDatabaseGetPropertiesOptions"] = None, **kwargs: Any ) -> None: """ - :keyword location: The location of the resource group to which the resource belongs. - :paramtype location: str - :keyword tags: Tags are a list of key-value pairs that describe the resource. These tags can be - used in viewing and grouping this resource (across resource groups). A maximum of 15 tags can - be provided for a resource. Each tag must have a key no greater than 128 characters and value - no greater than 256 characters. For example, the default experience for a template type is set - with "defaultExperience": "Cassandra". Current "defaultExperience" values also include "Table", - "Graph", "DocumentDB", and "MongoDB". + :keyword tags: Resource tags. :paramtype tags: dict[str, str] + :keyword location: The geo-location where the resource lives. + :paramtype location: str :keyword identity: Identity for the resource. :paramtype identity: ~azure.mgmt.cosmosdb.models.ManagedServiceIdentity :keyword resource: @@ -12102,7 +12083,10 @@ def __init__( :keyword options: :paramtype options: ~azure.mgmt.cosmosdb.models.MongoDBDatabaseGetPropertiesOptions """ - super().__init__(location=location, tags=tags, identity=identity, **kwargs) + super().__init__(**kwargs) + self.tags = tags + self.location = location + self.identity = identity self.resource = resource self.options = options @@ -12114,6 +12098,8 @@ class MongoDBDatabaseListResult(_serialization.Model): :ivar value: List of MongoDB databases and their properties. :vartype value: list[~azure.mgmt.cosmosdb.models.MongoDBDatabaseGetResults] + :ivar next_link: + :vartype next_link: str """ _validation = { @@ -12122,12 +12108,17 @@ class MongoDBDatabaseListResult(_serialization.Model): _attribute_map = { "value": {"key": "value", "type": "[MongoDBDatabaseGetResults]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__(self, **kwargs: Any) -> None: - """ """ + def __init__(self, *, next_link: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword next_link: + :paramtype next_link: str + """ super().__init__(**kwargs) self.value: Optional[list["_models.MongoDBDatabaseGetResults"]] = None + self.next_link = next_link class MongoIndex(_serialization.Model): @@ -12211,19 +12202,18 @@ def __init__( class MongoMIRoleAssignmentListResult(_serialization.Model): - """The relevant Role Assignments. + """The response of a MongoMIRoleAssignmentResource list operation. - 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 value: List of Role Assignments and their properties. + :ivar value: The MongoMIRoleAssignmentResource items on this page. Required. :vartype value: list[~azure.mgmt.cosmosdb.models.MongoMIRoleAssignmentResource] - :ivar next_link: The link used to get the next page of results. + :ivar next_link: The link to the next page of items. :vartype next_link: str """ _validation = { - "value": {"readonly": True}, - "next_link": {"readonly": True}, + "value": {"required": True}, } _attribute_map = { @@ -12231,11 +12221,18 @@ class MongoMIRoleAssignmentListResult(_serialization.Model): "next_link": {"key": "nextLink", "type": "str"}, } - def __init__(self, **kwargs: Any) -> None: - """ """ + def __init__( + self, *, value: list["_models.MongoMIRoleAssignmentResource"], next_link: Optional[str] = None, **kwargs: Any + ) -> None: + """ + :keyword value: The MongoMIRoleAssignmentResource items on this page. Required. + :paramtype value: list[~azure.mgmt.cosmosdb.models.MongoMIRoleAssignmentResource] + :keyword next_link: The link to the next page of items. + :paramtype next_link: str + """ super().__init__(**kwargs) - self.value: Optional[list["_models.MongoMIRoleAssignmentResource"]] = None - self.next_link: Optional[str] = None + self.value = value + self.next_link = next_link class MongoMIRoleAssignmentResource(ProxyResource): @@ -12313,19 +12310,18 @@ def __init__( class MongoMIRoleDefinitionListResult(_serialization.Model): - """The relevant Role Definitions. + """The response of a MongoMIRoleDefinitionResource list operation. - 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 value: List of Role Definitions and their properties. + :ivar value: The MongoMIRoleDefinitionResource items on this page. Required. :vartype value: list[~azure.mgmt.cosmosdb.models.MongoMIRoleDefinitionResource] - :ivar next_link: The link used to get the next page of results. + :ivar next_link: The link to the next page of items. :vartype next_link: str """ _validation = { - "value": {"readonly": True}, - "next_link": {"readonly": True}, + "value": {"required": True}, } _attribute_map = { @@ -12333,11 +12329,18 @@ class MongoMIRoleDefinitionListResult(_serialization.Model): "next_link": {"key": "nextLink", "type": "str"}, } - def __init__(self, **kwargs: Any) -> None: - """ """ + def __init__( + self, *, value: list["_models.MongoMIRoleDefinitionResource"], next_link: Optional[str] = None, **kwargs: Any + ) -> None: + """ + :keyword value: The MongoMIRoleDefinitionResource items on this page. Required. + :paramtype value: list[~azure.mgmt.cosmosdb.models.MongoMIRoleDefinitionResource] + :keyword next_link: The link to the next page of items. + :paramtype next_link: str + """ super().__init__(**kwargs) - self.value: Optional[list["_models.MongoMIRoleDefinitionResource"]] = None - self.next_link: Optional[str] = None + self.value = value + self.next_link = next_link class MongoMIRoleDefinitionResource(ProxyResource): @@ -12492,17 +12495,22 @@ def __init__( self.roles = roles -class MongoRoleDefinitionGetResults(ARMProxyResource): +class MongoRoleDefinitionGetResults(ProxyResource): """An Azure Cosmos DB Mongo Role Definition. Variables are only populated by the server, and will be ignored when sending a request. - :ivar id: The unique resource identifier of the database account. + :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 database account. + :ivar name: The name of the resource. :vartype name: str - :ivar type: The type of Azure resource. + :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.cosmosdb.models.SystemData :ivar role_name: A user-friendly name for the Role Definition. Must be unique for the database account. :vartype role_name: str @@ -12524,12 +12532,14 @@ class MongoRoleDefinitionGetResults(ARMProxyResource): "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"}, "role_name": {"key": "properties.roleName", "type": "str"}, "type_properties_type": {"key": "properties.type", "type": "str"}, "database_name": {"key": "properties.databaseName", "type": "str"}, @@ -12579,6 +12589,8 @@ class MongoRoleDefinitionListResult(_serialization.Model): :ivar value: List of Mongo Role Definitions and their properties. :vartype value: list[~azure.mgmt.cosmosdb.models.MongoRoleDefinitionGetResults] + :ivar next_link: + :vartype next_link: str """ _validation = { @@ -12587,12 +12599,17 @@ class MongoRoleDefinitionListResult(_serialization.Model): _attribute_map = { "value": {"key": "value", "type": "[MongoRoleDefinitionGetResults]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__(self, **kwargs: Any) -> None: - """ """ + def __init__(self, *, next_link: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword next_link: + :paramtype next_link: str + """ super().__init__(**kwargs) self.value: Optional[list["_models.MongoRoleDefinitionGetResults"]] = None + self.next_link = next_link class MongoRUToMongoRUCopyJobProperties(BaseCopyJobProperties): @@ -12862,17 +12879,22 @@ def __init__( self.mechanisms = mechanisms -class MongoUserDefinitionGetResults(ARMProxyResource): +class MongoUserDefinitionGetResults(ProxyResource): """An Azure Cosmos DB User Definition. Variables are only populated by the server, and will be ignored when sending a request. - :ivar id: The unique resource identifier of the database account. + :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 database account. + :ivar name: The name of the resource. :vartype name: str - :ivar type: The type of Azure resource. + :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.cosmosdb.models.SystemData :ivar user_name: The user name for User Definition. :vartype user_name: str :ivar password: The password for User Definition. Response does not contain user password. @@ -12893,12 +12915,14 @@ class MongoUserDefinitionGetResults(ARMProxyResource): "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"}, "user_name": {"key": "properties.userName", "type": "str"}, "password": {"key": "properties.password", "type": "str"}, "database_name": {"key": "properties.databaseName", "type": "str"}, @@ -12950,6 +12974,8 @@ class MongoUserDefinitionListResult(_serialization.Model): :ivar value: List of User Definition and their properties. :vartype value: list[~azure.mgmt.cosmosdb.models.MongoUserDefinitionGetResults] + :ivar next_link: + :vartype next_link: str """ _validation = { @@ -12958,12 +12984,17 @@ class MongoUserDefinitionListResult(_serialization.Model): _attribute_map = { "value": {"key": "value", "type": "[MongoUserDefinitionGetResults]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__(self, **kwargs: Any) -> None: - """ """ + def __init__(self, *, next_link: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword next_link: + :paramtype next_link: str + """ super().__init__(**kwargs) self.value: Optional[list["_models.MongoUserDefinitionGetResults"]] = None + self.next_link = next_link class MongoVCoreSourceSinkDetails(_serialization.Model): @@ -13088,14 +13119,20 @@ def __init__( class NetworkSecurityPerimeterConfigurationListResult(_serialization.Model): # pylint: disable=name-too-long - """Result of a list NSP (network security perimeter) configurations request. + """The response of a NetworkSecurityPerimeterConfiguration list operation. - :ivar value: Array of network security perimeter results. + All required parameters must be populated in order to send to server. + + :ivar value: The NetworkSecurityPerimeterConfiguration items on this page. Required. :vartype value: list[~azure.mgmt.cosmosdb.models.NetworkSecurityPerimeterConfiguration] - :ivar next_link: The link used to get the next page of results. + :ivar next_link: The link to the next page of items. :vartype next_link: str """ + _validation = { + "value": {"required": True}, + } + _attribute_map = { "value": {"key": "value", "type": "[NetworkSecurityPerimeterConfiguration]"}, "next_link": {"key": "nextLink", "type": "str"}, @@ -13104,14 +13141,14 @@ class NetworkSecurityPerimeterConfigurationListResult(_serialization.Model): # def __init__( self, *, - value: Optional[list["_models.NetworkSecurityPerimeterConfiguration"]] = None, + value: list["_models.NetworkSecurityPerimeterConfiguration"], next_link: Optional[str] = None, **kwargs: Any ) -> None: """ - :keyword value: Array of network security perimeter results. + :keyword value: The NetworkSecurityPerimeterConfiguration items on this page. Required. :paramtype value: list[~azure.mgmt.cosmosdb.models.NetworkSecurityPerimeterConfiguration] - :keyword next_link: The link used to get the next page of results. + :keyword next_link: The link to the next page of items. :paramtype next_link: str """ super().__init__(**kwargs) @@ -13328,17 +13365,22 @@ def __init__( self.destination = destination -class NotebookWorkspace(ARMProxyResource): +class NotebookWorkspace(ProxyResource): """A notebook workspace resource. Variables are only populated by the server, and will be ignored when sending a request. - :ivar id: The unique resource identifier of the database account. + :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 database account. + :ivar name: The name of the resource. :vartype name: str - :ivar type: The type of Azure resource. + :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.cosmosdb.models.SystemData :ivar notebook_server_endpoint: Specifies the endpoint of Notebook server. :vartype notebook_server_endpoint: str :ivar status: Status of the notebook workspace. Possible values are: Creating, Online, @@ -13350,6 +13392,7 @@ class NotebookWorkspace(ARMProxyResource): "id": {"readonly": True}, "name": {"readonly": True}, "type": {"readonly": True}, + "system_data": {"readonly": True}, "notebook_server_endpoint": {"readonly": True}, "status": {"readonly": True}, } @@ -13358,6 +13401,7 @@ class NotebookWorkspace(ARMProxyResource): "id": {"key": "id", "type": "str"}, "name": {"key": "name", "type": "str"}, "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, "notebook_server_endpoint": {"key": "properties.notebookServerEndpoint", "type": "str"}, "status": {"key": "properties.status", "type": "str"}, } @@ -13417,19 +13461,31 @@ class NotebookWorkspaceListResult(_serialization.Model): :ivar value: Array of notebook workspace resources. :vartype value: list[~azure.mgmt.cosmosdb.models.NotebookWorkspace] + :ivar next_link: + :vartype next_link: str """ _attribute_map = { "value": {"key": "value", "type": "[NotebookWorkspace]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__(self, *, value: Optional[list["_models.NotebookWorkspace"]] = None, **kwargs: Any) -> None: + def __init__( + self, + *, + value: Optional[list["_models.NotebookWorkspace"]] = None, + next_link: Optional[str] = None, + **kwargs: Any + ) -> None: """ :keyword value: Array of notebook workspace resources. :paramtype value: list[~azure.mgmt.cosmosdb.models.NotebookWorkspace] + :keyword next_link: + :paramtype next_link: str """ super().__init__(**kwargs) self.value = value + self.next_link = next_link class Operation(_serialization.Model): @@ -13510,22 +13566,26 @@ class OperationListResult(_serialization.Model): """Result of the request to list Resource Provider operations. It contains a list of operations and a URL link to get the next set of results. - :ivar value: List of operations supported by the Resource Provider. + All required parameters must be populated in order to send to server. + + :ivar value: List of operations supported by the Resource Provider. Required. :vartype value: list[~azure.mgmt.cosmosdb.models.Operation] :ivar next_link: URL to get the next set of operation list results if there are any. :vartype next_link: str """ + _validation = { + "value": {"required": True}, + } + _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: + def __init__(self, *, value: list["_models.Operation"], next_link: Optional[str] = None, **kwargs: Any) -> None: """ - :keyword value: List of operations supported by the Resource Provider. + :keyword value: List of operations supported by the Resource Provider. Required. :paramtype value: list[~azure.mgmt.cosmosdb.models.Operation] :keyword next_link: URL to get the next set of operation list results if there are any. :paramtype next_link: str @@ -13596,6 +13656,8 @@ class PartitionMetricListResult(_serialization.Model): :ivar value: The list of partition-level metrics for the account. :vartype value: list[~azure.mgmt.cosmosdb.models.PartitionMetric] + :ivar next_link: + :vartype next_link: str """ _validation = { @@ -13604,12 +13666,17 @@ class PartitionMetricListResult(_serialization.Model): _attribute_map = { "value": {"key": "value", "type": "[PartitionMetric]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__(self, **kwargs: Any) -> None: - """ """ + def __init__(self, *, next_link: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword next_link: + :paramtype next_link: str + """ super().__init__(**kwargs) self.value: Optional[list["_models.PartitionMetric"]] = None + self.next_link = next_link class Usage(_serialization.Model): @@ -13713,6 +13780,8 @@ class PartitionUsagesResult(_serialization.Model): :ivar value: The list of partition-level usages for the database. A usage is a point in time metric. :vartype value: list[~azure.mgmt.cosmosdb.models.PartitionUsage] + :ivar next_link: + :vartype next_link: str """ _validation = { @@ -13721,12 +13790,17 @@ class PartitionUsagesResult(_serialization.Model): _attribute_map = { "value": {"key": "value", "type": "[PartitionUsage]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__(self, **kwargs: Any) -> None: - """ """ + def __init__(self, *, next_link: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword next_link: + :paramtype next_link: str + """ super().__init__(**kwargs) self.value: Optional[list["_models.PartitionUsage"]] = None + self.next_link = next_link class PercentileMetric(_serialization.Model): @@ -13785,6 +13859,8 @@ class PercentileMetricListResult(_serialization.Model): :ivar value: The list of percentile metrics for the account. :vartype value: list[~azure.mgmt.cosmosdb.models.PercentileMetric] + :ivar next_link: + :vartype next_link: str """ _validation = { @@ -13793,12 +13869,17 @@ class PercentileMetricListResult(_serialization.Model): _attribute_map = { "value": {"key": "value", "type": "[PercentileMetric]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__(self, **kwargs: Any) -> None: - """ """ + def __init__(self, *, next_link: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword next_link: + :paramtype next_link: str + """ super().__init__(**kwargs) self.value: Optional[list["_models.PercentileMetric"]] = None + self.next_link = next_link class PercentileMetricValue(MetricValue): @@ -14012,34 +14093,6 @@ def __init__( self.not_data_actions = not_data_actions -class PermissionAutoGenerated(_serialization.Model): - """The set of data plane operations permitted through this Role Definition. - - :ivar data_actions: An array of data actions that are allowed. - :vartype data_actions: list[str] - :ivar not_data_actions: An array of data actions that are denied. - :vartype not_data_actions: list[str] - """ - - _attribute_map = { - "data_actions": {"key": "dataActions", "type": "[str]"}, - "not_data_actions": {"key": "notDataActions", "type": "[str]"}, - } - - def __init__( - self, *, data_actions: Optional[list[str]] = None, not_data_actions: Optional[list[str]] = None, **kwargs: Any - ) -> None: - """ - :keyword data_actions: An array of data actions that are allowed. - :paramtype data_actions: list[str] - :keyword not_data_actions: An array of data actions that are denied. - :paramtype not_data_actions: list[str] - """ - super().__init__(**kwargs) - self.data_actions = data_actions - self.not_data_actions = not_data_actions - - class PhysicalPartitionId(_serialization.Model): """PhysicalPartitionId object. @@ -14281,100 +14334,53 @@ class PhysicalPartitionThroughputInfoResultPropertiesResource( """ -class ResourceAutoGenerated(_serialization.Model): - """Common fields that are returned in the response for all Azure Resource Manager resources. +class PrivateEndpointConnection(ProxyResource): + """A private endpoint connection. Variables are only populated by the server, and will be ignored when sending a request. - :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :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.cosmosdb.models.SystemData + :ivar private_endpoint: Private endpoint which the connection belongs to. + :vartype private_endpoint: ~azure.mgmt.cosmosdb.models.PrivateEndpointProperty + :ivar private_link_service_connection_state: Connection State of the Private Endpoint + Connection. + :vartype private_link_service_connection_state: + ~azure.mgmt.cosmosdb.models.PrivateLinkServiceConnectionStateProperty + :ivar group_id: Group id of the private endpoint. + :vartype group_id: str + :ivar provisioning_state: Provisioning state of the private endpoint. + :vartype provisioning_state: 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"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.id: Optional[str] = None - self.name: Optional[str] = None - self.type: Optional[str] = None - - -class ProxyResourceAutoGenerated(ResourceAutoGenerated): - """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. 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 - """ - - -class PrivateEndpointConnection(ProxyResourceAutoGenerated): - """A private endpoint connection. - - Variables are only populated by the server, and will be ignored when sending a request. - - :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 private_endpoint: Private endpoint which the connection belongs to. - :vartype private_endpoint: ~azure.mgmt.cosmosdb.models.PrivateEndpointProperty - :ivar private_link_service_connection_state: Connection State of the Private Endpoint - Connection. - :vartype private_link_service_connection_state: - ~azure.mgmt.cosmosdb.models.PrivateLinkServiceConnectionStateProperty - :ivar group_id: Group id of the private endpoint. - :vartype group_id: str - :ivar provisioning_state: Provisioning state of the private endpoint. - :vartype provisioning_state: str - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "private_endpoint": {"key": "properties.privateEndpoint", "type": "PrivateEndpointProperty"}, - "private_link_service_connection_state": { - "key": "properties.privateLinkServiceConnectionState", - "type": "PrivateLinkServiceConnectionStateProperty", - }, - "group_id": {"key": "properties.groupId", "type": "str"}, - "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "private_endpoint": {"key": "properties.privateEndpoint", "type": "PrivateEndpointProperty"}, + "private_link_service_connection_state": { + "key": "properties.privateLinkServiceConnectionState", + "type": "PrivateLinkServiceConnectionStateProperty", + }, + "group_id": {"key": "properties.groupId", "type": "str"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, } def __init__( @@ -14410,19 +14416,31 @@ class PrivateEndpointConnectionListResult(_serialization.Model): :ivar value: Array of private endpoint connections. :vartype value: list[~azure.mgmt.cosmosdb.models.PrivateEndpointConnection] + :ivar next_link: + :vartype next_link: str """ _attribute_map = { "value": {"key": "value", "type": "[PrivateEndpointConnection]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__(self, *, value: Optional[list["_models.PrivateEndpointConnection"]] = None, **kwargs: Any) -> None: + def __init__( + self, + *, + value: Optional[list["_models.PrivateEndpointConnection"]] = None, + next_link: Optional[str] = None, + **kwargs: Any + ) -> None: """ :keyword value: Array of private endpoint connections. :paramtype value: list[~azure.mgmt.cosmosdb.models.PrivateEndpointConnection] + :keyword next_link: + :paramtype next_link: str """ super().__init__(**kwargs) self.value = value + self.next_link = next_link class PrivateEndpointProperty(_serialization.Model): @@ -14445,17 +14463,22 @@ def __init__(self, *, id: Optional[str] = None, **kwargs: Any) -> None: # pylin self.id = id -class PrivateLinkResource(ARMProxyResource): +class PrivateLinkResource(ProxyResource): """A private link resource. Variables are only populated by the server, and will be ignored when sending a request. - :ivar id: The unique resource identifier of the database account. + :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 database account. + :ivar name: The name of the resource. :vartype name: str - :ivar type: The type of Azure resource. + :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.cosmosdb.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. @@ -14468,6 +14491,7 @@ class PrivateLinkResource(ARMProxyResource): "id": {"readonly": True}, "name": {"readonly": True}, "type": {"readonly": True}, + "system_data": {"readonly": True}, "group_id": {"readonly": True}, "required_members": {"readonly": True}, "required_zone_names": {"readonly": True}, @@ -14477,6 +14501,7 @@ class PrivateLinkResource(ARMProxyResource): "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]"}, @@ -14495,19 +14520,31 @@ class PrivateLinkResourceListResult(_serialization.Model): :ivar value: Array of private link resources. :vartype value: list[~azure.mgmt.cosmosdb.models.PrivateLinkResource] + :ivar next_link: + :vartype next_link: str """ _attribute_map = { "value": {"key": "value", "type": "[PrivateLinkResource]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__(self, *, value: Optional[list["_models.PrivateLinkResource"]] = None, **kwargs: Any) -> None: + def __init__( + self, + *, + value: Optional[list["_models.PrivateLinkResource"]] = None, + next_link: Optional[str] = None, + **kwargs: Any + ) -> None: """ :keyword value: Array of private link resources. :paramtype value: list[~azure.mgmt.cosmosdb.models.PrivateLinkResource] + :keyword next_link: + :paramtype next_link: str """ super().__init__(**kwargs) self.value = value + self.next_link = next_link class PrivateLinkServiceConnectionStateProperty(_serialization.Model): # pylint: disable=name-too-long @@ -14944,17 +14981,22 @@ class ResourceRestoreParameters(RestoreParametersBase): """ -class RestorableDatabaseAccountGetResult(_serialization.Model): +class RestorableDatabaseAccountGetResult(ProxyResource): """A Azure Cosmos DB restorable database account. Variables are only populated by the server, and will be ignored when sending a request. - :ivar id: The unique resource identifier of the ARM resource. + :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 ARM resource. + :ivar name: The name of the resource. :vartype name: str - :ivar type: The type of Azure resource. + :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.cosmosdb.models.SystemData :ivar location: The location of the resource group to which the resource belongs. :vartype location: str :ivar account_name: The name of the global database account. @@ -14979,6 +15021,7 @@ class RestorableDatabaseAccountGetResult(_serialization.Model): "id": {"readonly": True}, "name": {"readonly": True}, "type": {"readonly": True}, + "system_data": {"readonly": True}, "api_type": {"readonly": True}, "restorable_locations": {"readonly": True}, } @@ -14987,6 +15030,7 @@ class RestorableDatabaseAccountGetResult(_serialization.Model): "id": {"key": "id", "type": "str"}, "name": {"key": "name", "type": "str"}, "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, "location": {"key": "location", "type": "str"}, "account_name": {"key": "properties.accountName", "type": "str"}, "creation_time": {"key": "properties.creationTime", "type": "iso-8601"}, @@ -15021,9 +15065,6 @@ def __init__( :paramtype deletion_time: ~datetime.datetime """ super().__init__(**kwargs) - self.id: Optional[str] = None - self.name: Optional[str] = None - self.type: Optional[str] = None self.location = location self.account_name = account_name self.creation_time = creation_time @@ -15041,6 +15082,8 @@ class RestorableDatabaseAccountsListResult(_serialization.Model): :ivar value: List of restorable database accounts and their properties. :vartype value: list[~azure.mgmt.cosmosdb.models.RestorableDatabaseAccountGetResult] + :ivar next_link: + :vartype next_link: str """ _validation = { @@ -15049,12 +15092,17 @@ class RestorableDatabaseAccountsListResult(_serialization.Model): _attribute_map = { "value": {"key": "value", "type": "[RestorableDatabaseAccountGetResult]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__(self, **kwargs: Any) -> None: - """ """ + def __init__(self, *, next_link: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword next_link: + :paramtype next_link: str + """ super().__init__(**kwargs) self.value: Optional[list["_models.RestorableDatabaseAccountGetResult"]] = None + self.next_link = next_link class RestorableGremlinDatabaseGetResult(_serialization.Model): @@ -15161,6 +15209,8 @@ class RestorableGremlinDatabasesListResult(_serialization.Model): :ivar value: List of Gremlin database events and their properties. :vartype value: list[~azure.mgmt.cosmosdb.models.RestorableGremlinDatabaseGetResult] + :ivar next_link: + :vartype next_link: str """ _validation = { @@ -15169,12 +15219,17 @@ class RestorableGremlinDatabasesListResult(_serialization.Model): _attribute_map = { "value": {"key": "value", "type": "[RestorableGremlinDatabaseGetResult]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__(self, **kwargs: Any) -> None: - """ """ + def __init__(self, *, next_link: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword next_link: + :paramtype next_link: str + """ super().__init__(**kwargs) self.value: Optional[list["_models.RestorableGremlinDatabaseGetResult"]] = None + self.next_link = next_link class RestorableGremlinGraphGetResult(_serialization.Model): @@ -15281,6 +15336,8 @@ class RestorableGremlinGraphsListResult(_serialization.Model): :ivar value: List of Gremlin graph events and their properties. :vartype value: list[~azure.mgmt.cosmosdb.models.RestorableGremlinGraphGetResult] + :ivar next_link: + :vartype next_link: str """ _validation = { @@ -15289,12 +15346,17 @@ class RestorableGremlinGraphsListResult(_serialization.Model): _attribute_map = { "value": {"key": "value", "type": "[RestorableGremlinGraphGetResult]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__(self, **kwargs: Any) -> None: - """ """ + def __init__(self, *, next_link: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword next_link: + :paramtype next_link: str + """ super().__init__(**kwargs) self.value: Optional[list["_models.RestorableGremlinGraphGetResult"]] = None + self.next_link = next_link class RestorableGremlinResourcesGetResult(_serialization.Model): @@ -15353,6 +15415,8 @@ class RestorableGremlinResourcesListResult(_serialization.Model): :ivar value: List of restorable Gremlin resources, including the gremlin database and graph names. :vartype value: list[~azure.mgmt.cosmosdb.models.RestorableGremlinResourcesGetResult] + :ivar next_link: + :vartype next_link: str """ _validation = { @@ -15361,12 +15425,17 @@ class RestorableGremlinResourcesListResult(_serialization.Model): _attribute_map = { "value": {"key": "value", "type": "[RestorableGremlinResourcesGetResult]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__(self, **kwargs: Any) -> None: - """ """ + def __init__(self, *, next_link: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword next_link: + :paramtype next_link: str + """ super().__init__(**kwargs) self.value: Optional[list["_models.RestorableGremlinResourcesGetResult"]] = None + self.next_link = next_link class RestorableLocationResource(_serialization.Model): @@ -15514,6 +15583,8 @@ class RestorableMongodbCollectionsListResult(_serialization.Model): :ivar value: List of MongoDB collection events and their properties. :vartype value: list[~azure.mgmt.cosmosdb.models.RestorableMongodbCollectionGetResult] + :ivar next_link: + :vartype next_link: str """ _validation = { @@ -15522,12 +15593,17 @@ class RestorableMongodbCollectionsListResult(_serialization.Model): _attribute_map = { "value": {"key": "value", "type": "[RestorableMongodbCollectionGetResult]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__(self, **kwargs: Any) -> None: - """ """ + def __init__(self, *, next_link: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword next_link: + :paramtype next_link: str + """ super().__init__(**kwargs) self.value: Optional[list["_models.RestorableMongodbCollectionGetResult"]] = None + self.next_link = next_link class RestorableMongodbDatabaseGetResult(_serialization.Model): @@ -15634,6 +15710,8 @@ class RestorableMongodbDatabasesListResult(_serialization.Model): :ivar value: List of MongoDB database events and their properties. :vartype value: list[~azure.mgmt.cosmosdb.models.RestorableMongodbDatabaseGetResult] + :ivar next_link: + :vartype next_link: str """ _validation = { @@ -15642,12 +15720,17 @@ class RestorableMongodbDatabasesListResult(_serialization.Model): _attribute_map = { "value": {"key": "value", "type": "[RestorableMongodbDatabaseGetResult]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__(self, **kwargs: Any) -> None: - """ """ + def __init__(self, *, next_link: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword next_link: + :paramtype next_link: str + """ super().__init__(**kwargs) self.value: Optional[list["_models.RestorableMongodbDatabaseGetResult"]] = None + self.next_link = next_link class RestorableMongodbResourcesGetResult(_serialization.Model): @@ -15705,6 +15788,8 @@ class RestorableMongodbResourcesListResult(_serialization.Model): :ivar value: List of restorable MongoDB resources, including the database and collection names. :vartype value: list[~azure.mgmt.cosmosdb.models.RestorableMongodbResourcesGetResult] + :ivar next_link: + :vartype next_link: str """ _validation = { @@ -15713,12 +15798,17 @@ class RestorableMongodbResourcesListResult(_serialization.Model): _attribute_map = { "value": {"key": "value", "type": "[RestorableMongodbResourcesGetResult]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__(self, **kwargs: Any) -> None: - """ """ + def __init__(self, *, next_link: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword next_link: + :paramtype next_link: str + """ super().__init__(**kwargs) self.value: Optional[list["_models.RestorableMongodbResourcesGetResult"]] = None + self.next_link = next_link class RestorableSqlContainerGetResult(_serialization.Model): @@ -15855,7 +15945,7 @@ class SqlContainerResource(_serialization.Model): :vartype analytical_storage_ttl: int :ivar restore_parameters: Parameters to indicate the information about the restore. :vartype restore_parameters: ~azure.mgmt.cosmosdb.models.ResourceRestoreParameters - :ivar create_mode: Enum to indicate the mode of resource creation. Known values are: "Default" + :ivar create_mode: Enum to indicate the mode of account creation. Known values are: "Default" and "Restore". :vartype create_mode: str or ~azure.mgmt.cosmosdb.models.CreateMode :ivar materialized_view_definition: The configuration for defining Materialized Views. This @@ -15912,7 +16002,7 @@ def __init__( client_encryption_policy: Optional["_models.ClientEncryptionPolicy"] = None, analytical_storage_ttl: Optional[int] = None, restore_parameters: Optional["_models.ResourceRestoreParameters"] = None, - create_mode: Union[str, "_models.CreateMode"] = "Default", + create_mode: Optional[Union[str, "_models.CreateMode"]] = None, materialized_view_definition: Optional["_models.MaterializedViewDefinition"] = None, materialized_views: Optional[list["_models.MaterializedViewDetails"]] = None, materialized_views_properties: Optional["_models.MaterializedViewsProperties"] = None, @@ -15944,7 +16034,7 @@ def __init__( :paramtype analytical_storage_ttl: int :keyword restore_parameters: Parameters to indicate the information about the restore. :paramtype restore_parameters: ~azure.mgmt.cosmosdb.models.ResourceRestoreParameters - :keyword create_mode: Enum to indicate the mode of resource creation. Known values are: + :keyword create_mode: Enum to indicate the mode of account creation. Known values are: "Default" and "Restore". :paramtype create_mode: str or ~azure.mgmt.cosmosdb.models.CreateMode :keyword materialized_view_definition: The configuration for defining Materialized Views. This @@ -15985,22 +16075,13 @@ def __init__( self.data_masking_policy = data_masking_policy -class RestorableSqlContainerPropertiesResourceContainer( - SqlContainerResource, ExtendedResourceProperties -): # pylint: disable=name-too-long +class RestorableSqlContainerPropertiesResourceContainer(SqlContainerResource): # pylint: disable=name-too-long """Cosmos DB SQL container resource object. 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 rid: A system generated property. A unique identifier. - :vartype rid: str - :ivar ts: A system generated property that denotes the last updated timestamp of the resource. - :vartype ts: float - :ivar etag: A system generated property representing the resource etag required for optimistic - concurrency control. - :vartype etag: str :ivar id: Name of the Cosmos DB SQL container. Required. :vartype id: str :ivar indexing_policy: The configuration of the indexing policy. By default, the indexing is @@ -16022,7 +16103,7 @@ class RestorableSqlContainerPropertiesResourceContainer( :vartype analytical_storage_ttl: int :ivar restore_parameters: Parameters to indicate the information about the restore. :vartype restore_parameters: ~azure.mgmt.cosmosdb.models.ResourceRestoreParameters - :ivar create_mode: Enum to indicate the mode of resource creation. Known values are: "Default" + :ivar create_mode: Enum to indicate the mode of account creation. Known values are: "Default" and "Restore". :vartype create_mode: str or ~azure.mgmt.cosmosdb.models.CreateMode :ivar materialized_view_definition: The configuration for defining Materialized Views. This @@ -16041,23 +16122,27 @@ class RestorableSqlContainerPropertiesResourceContainer( :vartype full_text_policy: ~azure.mgmt.cosmosdb.models.FullTextPolicy :ivar data_masking_policy: The Data Masking policy for the container. :vartype data_masking_policy: ~azure.mgmt.cosmosdb.models.DataMaskingPolicy + :ivar rid: A system generated property. A unique identifier. + :vartype rid: str + :ivar ts: A system generated property that denotes the last updated timestamp of the resource. + :vartype ts: float + :ivar etag: A system generated property representing the resource etag required for optimistic + concurrency control. + :vartype etag: str :ivar self_property: A system generated property that specifies the addressable path of the container resource. :vartype self_property: str """ _validation = { + "id": {"required": True}, "rid": {"readonly": True}, "ts": {"readonly": True}, "etag": {"readonly": True}, - "id": {"required": True}, "self_property": {"readonly": True}, } _attribute_map = { - "rid": {"key": "_rid", "type": "str"}, - "ts": {"key": "_ts", "type": "float"}, - "etag": {"key": "_etag", "type": "str"}, "id": {"key": "id", "type": "str"}, "indexing_policy": {"key": "indexingPolicy", "type": "IndexingPolicy"}, "partition_key": {"key": "partitionKey", "type": "ContainerPartitionKey"}, @@ -16075,6 +16160,9 @@ class RestorableSqlContainerPropertiesResourceContainer( "vector_embedding_policy": {"key": "vectorEmbeddingPolicy", "type": "VectorEmbeddingPolicy"}, "full_text_policy": {"key": "fullTextPolicy", "type": "FullTextPolicy"}, "data_masking_policy": {"key": "dataMaskingPolicy", "type": "DataMaskingPolicy"}, + "rid": {"key": "_rid", "type": "str"}, + "ts": {"key": "_ts", "type": "float"}, + "etag": {"key": "_etag", "type": "str"}, "self_property": {"key": "_self", "type": "str"}, } @@ -16090,7 +16178,7 @@ def __init__( client_encryption_policy: Optional["_models.ClientEncryptionPolicy"] = None, analytical_storage_ttl: Optional[int] = None, restore_parameters: Optional["_models.ResourceRestoreParameters"] = None, - create_mode: Union[str, "_models.CreateMode"] = "Default", + create_mode: Optional[Union[str, "_models.CreateMode"]] = None, materialized_view_definition: Optional["_models.MaterializedViewDefinition"] = None, materialized_views: Optional[list["_models.MaterializedViewDetails"]] = None, materialized_views_properties: Optional["_models.MaterializedViewsProperties"] = None, @@ -16122,7 +16210,7 @@ def __init__( :paramtype analytical_storage_ttl: int :keyword restore_parameters: Parameters to indicate the information about the restore. :paramtype restore_parameters: ~azure.mgmt.cosmosdb.models.ResourceRestoreParameters - :keyword create_mode: Enum to indicate the mode of resource creation. Known values are: + :keyword create_mode: Enum to indicate the mode of account creation. Known values are: "Default" and "Restore". :paramtype create_mode: str or ~azure.mgmt.cosmosdb.models.CreateMode :keyword materialized_view_definition: The configuration for defining Materialized Views. This @@ -16167,23 +16255,6 @@ def __init__( self.ts: Optional[float] = None self.etag: Optional[str] = None self.self_property: Optional[str] = None - self.id = id - self.indexing_policy = indexing_policy - self.partition_key = partition_key - self.default_ttl = default_ttl - self.unique_key_policy = unique_key_policy - self.conflict_resolution_policy = conflict_resolution_policy - self.client_encryption_policy = client_encryption_policy - self.analytical_storage_ttl = analytical_storage_ttl - self.restore_parameters = restore_parameters - self.create_mode = create_mode - self.materialized_view_definition = materialized_view_definition - self.materialized_views = materialized_views - self.materialized_views_properties = materialized_views_properties - self.computed_properties = computed_properties - self.vector_embedding_policy = vector_embedding_policy - self.full_text_policy = full_text_policy - self.data_masking_policy = data_masking_policy class RestorableSqlContainersListResult(_serialization.Model): @@ -16193,6 +16264,8 @@ class RestorableSqlContainersListResult(_serialization.Model): :ivar value: List of SQL container events and their properties. :vartype value: list[~azure.mgmt.cosmosdb.models.RestorableSqlContainerGetResult] + :ivar next_link: + :vartype next_link: str """ _validation = { @@ -16201,12 +16274,17 @@ class RestorableSqlContainersListResult(_serialization.Model): _attribute_map = { "value": {"key": "value", "type": "[RestorableSqlContainerGetResult]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__(self, **kwargs: Any) -> None: - """ """ + def __init__(self, *, next_link: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword next_link: + :paramtype next_link: str + """ super().__init__(**kwargs) self.value: Optional[list["_models.RestorableSqlContainerGetResult"]] = None + self.next_link = next_link class RestorableSqlDatabaseGetResult(_serialization.Model): @@ -16325,7 +16403,7 @@ class SqlDatabaseResource(_serialization.Model): :vartype id: str :ivar restore_parameters: Parameters to indicate the information about the restore. :vartype restore_parameters: ~azure.mgmt.cosmosdb.models.ResourceRestoreParameters - :ivar create_mode: Enum to indicate the mode of resource creation. Known values are: "Default" + :ivar create_mode: Enum to indicate the mode of account creation. Known values are: "Default" and "Restore". :vartype create_mode: str or ~azure.mgmt.cosmosdb.models.CreateMode """ @@ -16345,7 +16423,7 @@ def __init__( *, id: str, # pylint: disable=redefined-builtin restore_parameters: Optional["_models.ResourceRestoreParameters"] = None, - create_mode: Union[str, "_models.CreateMode"] = "Default", + create_mode: Optional[Union[str, "_models.CreateMode"]] = None, **kwargs: Any ) -> None: """ @@ -16353,7 +16431,7 @@ def __init__( :paramtype id: str :keyword restore_parameters: Parameters to indicate the information about the restore. :paramtype restore_parameters: ~azure.mgmt.cosmosdb.models.ResourceRestoreParameters - :keyword create_mode: Enum to indicate the mode of resource creation. Known values are: + :keyword create_mode: Enum to indicate the mode of account creation. Known values are: "Default" and "Restore". :paramtype create_mode: str or ~azure.mgmt.cosmosdb.models.CreateMode """ @@ -16363,15 +16441,20 @@ def __init__( self.create_mode = create_mode -class RestorableSqlDatabasePropertiesResourceDatabase( - SqlDatabaseResource, ExtendedResourceProperties -): # pylint: disable=name-too-long +class RestorableSqlDatabasePropertiesResourceDatabase(SqlDatabaseResource): # pylint: disable=name-too-long """Cosmos DB SQL database resource object. 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: Name of the Cosmos DB SQL database. Required. + :vartype id: str + :ivar restore_parameters: Parameters to indicate the information about the restore. + :vartype restore_parameters: ~azure.mgmt.cosmosdb.models.ResourceRestoreParameters + :ivar create_mode: Enum to indicate the mode of account creation. Known values are: "Default" + and "Restore". + :vartype create_mode: str or ~azure.mgmt.cosmosdb.models.CreateMode :ivar rid: A system generated property. A unique identifier. :vartype rid: str :ivar ts: A system generated property that denotes the last updated timestamp of the resource. @@ -16379,13 +16462,6 @@ class RestorableSqlDatabasePropertiesResourceDatabase( :ivar etag: A system generated property representing the resource etag required for optimistic concurrency control. :vartype etag: str - :ivar id: Name of the Cosmos DB SQL database. Required. - :vartype id: str - :ivar restore_parameters: Parameters to indicate the information about the restore. - :vartype restore_parameters: ~azure.mgmt.cosmosdb.models.ResourceRestoreParameters - :ivar create_mode: Enum to indicate the mode of resource creation. Known values are: "Default" - and "Restore". - :vartype create_mode: str or ~azure.mgmt.cosmosdb.models.CreateMode :ivar colls: A system generated property that specified the addressable path of the collections resource. :vartype colls: str @@ -16398,22 +16474,22 @@ class RestorableSqlDatabasePropertiesResourceDatabase( """ _validation = { + "id": {"required": True}, "rid": {"readonly": True}, "ts": {"readonly": True}, "etag": {"readonly": True}, - "id": {"required": True}, "colls": {"readonly": True}, "users": {"readonly": True}, "self_property": {"readonly": True}, } _attribute_map = { - "rid": {"key": "_rid", "type": "str"}, - "ts": {"key": "_ts", "type": "float"}, - "etag": {"key": "_etag", "type": "str"}, "id": {"key": "id", "type": "str"}, "restore_parameters": {"key": "restoreParameters", "type": "ResourceRestoreParameters"}, "create_mode": {"key": "createMode", "type": "str"}, + "rid": {"key": "_rid", "type": "str"}, + "ts": {"key": "_ts", "type": "float"}, + "etag": {"key": "_etag", "type": "str"}, "colls": {"key": "_colls", "type": "str"}, "users": {"key": "_users", "type": "str"}, "self_property": {"key": "_self", "type": "str"}, @@ -16424,7 +16500,7 @@ def __init__( *, id: str, # pylint: disable=redefined-builtin restore_parameters: Optional["_models.ResourceRestoreParameters"] = None, - create_mode: Union[str, "_models.CreateMode"] = "Default", + create_mode: Optional[Union[str, "_models.CreateMode"]] = None, **kwargs: Any ) -> None: """ @@ -16432,7 +16508,7 @@ def __init__( :paramtype id: str :keyword restore_parameters: Parameters to indicate the information about the restore. :paramtype restore_parameters: ~azure.mgmt.cosmosdb.models.ResourceRestoreParameters - :keyword create_mode: Enum to indicate the mode of resource creation. Known values are: + :keyword create_mode: Enum to indicate the mode of account creation. Known values are: "Default" and "Restore". :paramtype create_mode: str or ~azure.mgmt.cosmosdb.models.CreateMode """ @@ -16443,9 +16519,6 @@ def __init__( self.colls: Optional[str] = None self.users: Optional[str] = None self.self_property: Optional[str] = None - self.id = id - self.restore_parameters = restore_parameters - self.create_mode = create_mode class RestorableSqlDatabasesListResult(_serialization.Model): @@ -16455,6 +16528,8 @@ class RestorableSqlDatabasesListResult(_serialization.Model): :ivar value: List of SQL database events and their properties. :vartype value: list[~azure.mgmt.cosmosdb.models.RestorableSqlDatabaseGetResult] + :ivar next_link: + :vartype next_link: str """ _validation = { @@ -16463,12 +16538,17 @@ class RestorableSqlDatabasesListResult(_serialization.Model): _attribute_map = { "value": {"key": "value", "type": "[RestorableSqlDatabaseGetResult]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__(self, **kwargs: Any) -> None: - """ """ + def __init__(self, *, next_link: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword next_link: + :paramtype next_link: str + """ super().__init__(**kwargs) self.value: Optional[list["_models.RestorableSqlDatabaseGetResult"]] = None + self.next_link = next_link class RestorableSqlResourcesGetResult(_serialization.Model): @@ -16526,6 +16606,8 @@ class RestorableSqlResourcesListResult(_serialization.Model): :ivar value: List of restorable SQL resources, including the database and collection names. :vartype value: list[~azure.mgmt.cosmosdb.models.RestorableSqlResourcesGetResult] + :ivar next_link: + :vartype next_link: str """ _validation = { @@ -16534,12 +16616,17 @@ class RestorableSqlResourcesListResult(_serialization.Model): _attribute_map = { "value": {"key": "value", "type": "[RestorableSqlResourcesGetResult]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__(self, **kwargs: Any) -> None: - """ """ + def __init__(self, *, next_link: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword next_link: + :paramtype next_link: str + """ super().__init__(**kwargs) self.value: Optional[list["_models.RestorableSqlResourcesGetResult"]] = None + self.next_link = next_link class RestorableTableGetResult(_serialization.Model): @@ -16679,6 +16766,8 @@ class RestorableTableResourcesListResult(_serialization.Model): :ivar value: List of restorable table names. :vartype value: list[~azure.mgmt.cosmosdb.models.RestorableTableResourcesGetResult] + :ivar next_link: + :vartype next_link: str """ _validation = { @@ -16687,12 +16776,17 @@ class RestorableTableResourcesListResult(_serialization.Model): _attribute_map = { "value": {"key": "value", "type": "[RestorableTableResourcesGetResult]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__(self, **kwargs: Any) -> None: - """ """ + def __init__(self, *, next_link: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword next_link: + :paramtype next_link: str + """ super().__init__(**kwargs) self.value: Optional[list["_models.RestorableTableResourcesGetResult"]] = None + self.next_link = next_link class RestorableTablesListResult(_serialization.Model): @@ -16702,6 +16796,8 @@ class RestorableTablesListResult(_serialization.Model): :ivar value: List of Table events and their properties. :vartype value: list[~azure.mgmt.cosmosdb.models.RestorableTableGetResult] + :ivar next_link: + :vartype next_link: str """ _validation = { @@ -16710,12 +16806,17 @@ class RestorableTablesListResult(_serialization.Model): _attribute_map = { "value": {"key": "value", "type": "[RestorableTableGetResult]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__(self, **kwargs: Any) -> None: - """ """ + def __init__(self, *, next_link: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword next_link: + :paramtype next_link: str + """ super().__init__(**kwargs) self.value: Optional[list["_models.RestorableTableGetResult"]] = None + self.next_link = next_link class RestoreParameters(RestoreParametersBase): @@ -16952,17 +17053,22 @@ def __init__(self, *, ip_address: Optional[str] = None, **kwargs: Any) -> None: self.ip_address = ip_address -class ServiceResource(ARMProxyResource): +class ServiceResource(ProxyResource): """Properties for the database account. Variables are only populated by the server, and will be ignored when sending a request. - :ivar id: The unique resource identifier of the database account. + :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 database account. + :ivar name: The name of the resource. :vartype name: str - :ivar type: The type of Azure resource. + :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.cosmosdb.models.SystemData :ivar properties: Services response resource. :vartype properties: ~azure.mgmt.cosmosdb.models.ServiceResourceProperties """ @@ -16971,12 +17077,14 @@ class ServiceResource(ARMProxyResource): "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"}, "properties": {"key": "properties", "type": "ServiceResourceProperties"}, } @@ -17018,6 +17126,8 @@ class ServiceResourceListResult(_serialization.Model): :ivar value: List of Service Resource and their properties. :vartype value: list[~azure.mgmt.cosmosdb.models.ServiceResource] + :ivar next_link: + :vartype next_link: str """ _validation = { @@ -17026,12 +17136,520 @@ class ServiceResourceListResult(_serialization.Model): _attribute_map = { "value": {"key": "value", "type": "[ServiceResource]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__(self, **kwargs: Any) -> None: - """ """ + def __init__(self, *, next_link: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword next_link: + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value: Optional[list["_models.ServiceResource"]] = None + self.next_link = next_link + + +class SoftDeleteConfiguration(_serialization.Model): + """Configuration for soft delete on the Cosmos DB account. + + :ivar soft_deletion_enabled: Flag to indicate whether soft delete is enabled on the account. + :vartype soft_deletion_enabled: bool + :ivar min_minutes_before_permanent_deletion_allowed: Minimum number of minutes before a soft + deleted resource can be permanently deleted. + :vartype min_minutes_before_permanent_deletion_allowed: int + :ivar soft_delete_retention_period_in_minutes: Soft delete retention period in minutes for + resources. + :vartype soft_delete_retention_period_in_minutes: int + """ + + _attribute_map = { + "soft_deletion_enabled": {"key": "softDeletionEnabled", "type": "bool"}, + "min_minutes_before_permanent_deletion_allowed": { + "key": "minMinutesBeforePermanentDeletionAllowed", + "type": "int", + }, + "soft_delete_retention_period_in_minutes": {"key": "softDeleteRetentionPeriodInMinutes", "type": "int"}, + } + + def __init__( + self, + *, + soft_deletion_enabled: Optional[bool] = None, + min_minutes_before_permanent_deletion_allowed: Optional[int] = None, + soft_delete_retention_period_in_minutes: Optional[int] = None, + **kwargs: Any + ) -> None: + """ + :keyword soft_deletion_enabled: Flag to indicate whether soft delete is enabled on the account. + :paramtype soft_deletion_enabled: bool + :keyword min_minutes_before_permanent_deletion_allowed: Minimum number of minutes before a soft + deleted resource can be permanently deleted. + :paramtype min_minutes_before_permanent_deletion_allowed: int + :keyword soft_delete_retention_period_in_minutes: Soft delete retention period in minutes for + resources. + :paramtype soft_delete_retention_period_in_minutes: int + """ + super().__init__(**kwargs) + self.soft_deletion_enabled = soft_deletion_enabled + self.min_minutes_before_permanent_deletion_allowed = min_minutes_before_permanent_deletion_allowed + self.soft_delete_retention_period_in_minutes = soft_delete_retention_period_in_minutes + + +class SoftDeletedDatabaseAccountGetResult(_serialization.Model): + """A Azure Cosmos DB soft-deleted database account. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: The unique resource identifier of the ARM resource. + :vartype id: str + :ivar name: The name of the ARM resource. + :vartype name: str + :ivar type: The type of Azure resource. + :vartype type: str + :ivar location: The location of the resource group to which the resource belongs. + :vartype location: str + :ivar account_name: The name of the database account. + :vartype account_name: str + :ivar soft_deletion_metadata: Metadata related to the soft deletion of the database account. + :vartype soft_deletion_metadata: ~azure.mgmt.cosmosdb.models.SoftDeletionMetadata + :ivar soft_delete_configuration: The soft delete configuration for the database account. + :vartype soft_delete_configuration: ~azure.mgmt.cosmosdb.models.SoftDeleteConfiguration + :ivar resource: A subset of properties of the underlying database account resource. + :vartype resource: ~azure.mgmt.cosmosdb.models.SoftDeletedDatabaseAccountResource + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "account_name": {"key": "properties.accountName", "type": "str"}, + "soft_deletion_metadata": {"key": "properties.softDeletionMetadata", "type": "SoftDeletionMetadata"}, + "soft_delete_configuration": {"key": "properties.softDeleteConfiguration", "type": "SoftDeleteConfiguration"}, + "resource": {"key": "properties.resource", "type": "SoftDeletedDatabaseAccountResource"}, + } + + def __init__( + self, + *, + location: Optional[str] = None, + account_name: Optional[str] = None, + soft_deletion_metadata: Optional["_models.SoftDeletionMetadata"] = None, + soft_delete_configuration: Optional["_models.SoftDeleteConfiguration"] = None, + resource: Optional["_models.SoftDeletedDatabaseAccountResource"] = None, + **kwargs: Any + ) -> None: + """ + :keyword location: The location of the resource group to which the resource belongs. + :paramtype location: str + :keyword account_name: The name of the database account. + :paramtype account_name: str + :keyword soft_deletion_metadata: Metadata related to the soft deletion of the database account. + :paramtype soft_deletion_metadata: ~azure.mgmt.cosmosdb.models.SoftDeletionMetadata + :keyword soft_delete_configuration: The soft delete configuration for the database account. + :paramtype soft_delete_configuration: ~azure.mgmt.cosmosdb.models.SoftDeleteConfiguration + :keyword resource: A subset of properties of the underlying database account resource. + :paramtype resource: ~azure.mgmt.cosmosdb.models.SoftDeletedDatabaseAccountResource + """ + super().__init__(**kwargs) + self.id: Optional[str] = None + self.name: Optional[str] = None + self.type: Optional[str] = None + self.location = location + self.account_name = account_name + self.soft_deletion_metadata = soft_deletion_metadata + self.soft_delete_configuration = soft_delete_configuration + self.resource = resource + + +class SoftDeletedDatabaseAccountResource(_serialization.Model): + """The database account resource information for a soft-deleted account. + + :ivar locations: An array that contains all of the locations enabled for the Cosmos DB account. + :vartype locations: list[~azure.mgmt.cosmosdb.models.Location] + :ivar write_locations: An array that contains the write location(s) for the Cosmos DB account. + :vartype write_locations: list[~azure.mgmt.cosmosdb.models.Location] + :ivar read_locations: An array that contains the read locations enabled for the Cosmos DB + account. + :vartype read_locations: list[~azure.mgmt.cosmosdb.models.Location] + """ + + _attribute_map = { + "locations": {"key": "locations", "type": "[Location]"}, + "write_locations": {"key": "writeLocations", "type": "[Location]"}, + "read_locations": {"key": "readLocations", "type": "[Location]"}, + } + + def __init__( + self, + *, + locations: Optional[list["_models.Location"]] = None, + write_locations: Optional[list["_models.Location"]] = None, + read_locations: Optional[list["_models.Location"]] = None, + **kwargs: Any + ) -> None: + """ + :keyword locations: An array that contains all of the locations enabled for the Cosmos DB + account. + :paramtype locations: list[~azure.mgmt.cosmosdb.models.Location] + :keyword write_locations: An array that contains the write location(s) for the Cosmos DB + account. + :paramtype write_locations: list[~azure.mgmt.cosmosdb.models.Location] + :keyword read_locations: An array that contains the read locations enabled for the Cosmos DB + account. + :paramtype read_locations: list[~azure.mgmt.cosmosdb.models.Location] + """ + super().__init__(**kwargs) + self.locations = locations + self.write_locations = write_locations + self.read_locations = read_locations + + +class SoftDeletedDatabaseAccountsListResult(_serialization.Model): + """The List operation response, that contains the soft-deleted database accounts and their + properties. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: List of soft-deleted database accounts and their properties. + :vartype value: list[~azure.mgmt.cosmosdb.models.SoftDeletedDatabaseAccountGetResult] + :ivar next_link: The URL to get the next set of results. + :vartype next_link: str + """ + + _validation = { + "value": {"readonly": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[SoftDeletedDatabaseAccountGetResult]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__(self, *, next_link: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword next_link: The URL to get the next set of results. + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value: Optional[list["_models.SoftDeletedDatabaseAccountGetResult"]] = None + self.next_link = next_link + + +class SoftDeletedSqlContainerGetResult(_serialization.Model): + """An Azure Cosmos DB soft-deleted SQL container. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: The unique resource identifier of the ARM resource. + :vartype id: str + :ivar name: The name of the ARM resource. + :vartype name: str + :ivar type: The type of Azure resource. + :vartype type: str + :ivar location: The location of the resource group to which the resource belongs. + :vartype location: str + :ivar soft_deletion_metadata: Metadata related to the soft deletion of the SQL container. + :vartype soft_deletion_metadata: ~azure.mgmt.cosmosdb.models.SoftDeletionMetadata + :ivar resource: The resource information for the soft-deleted SQL container. + :vartype resource: ~azure.mgmt.cosmosdb.models.SoftDeletedSqlContainerResource + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "soft_deletion_metadata": {"key": "properties.softDeletionMetadata", "type": "SoftDeletionMetadata"}, + "resource": {"key": "properties.resource", "type": "SoftDeletedSqlContainerResource"}, + } + + def __init__( + self, + *, + location: Optional[str] = None, + soft_deletion_metadata: Optional["_models.SoftDeletionMetadata"] = None, + resource: Optional["_models.SoftDeletedSqlContainerResource"] = None, + **kwargs: Any + ) -> None: + """ + :keyword location: The location of the resource group to which the resource belongs. + :paramtype location: str + :keyword soft_deletion_metadata: Metadata related to the soft deletion of the SQL container. + :paramtype soft_deletion_metadata: ~azure.mgmt.cosmosdb.models.SoftDeletionMetadata + :keyword resource: The resource information for the soft-deleted SQL container. + :paramtype resource: ~azure.mgmt.cosmosdb.models.SoftDeletedSqlContainerResource + """ + super().__init__(**kwargs) + self.id: Optional[str] = None + self.name: Optional[str] = None + self.type: Optional[str] = None + self.location = location + self.soft_deletion_metadata = soft_deletion_metadata + self.resource = resource + + +class SoftDeletedSqlContainerResource(_serialization.Model): + """Cosmos DB SQL container resource object. + + 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: Name of the Cosmos DB SQL container. Required. + :vartype id: str + :ivar rid: A system generated property. A unique identifier. + :vartype rid: str + :ivar partition_key: The configuration of the partition key to be used for partitioning data + into multiple partitions. + :vartype partition_key: ~azure.mgmt.cosmosdb.models.ContainerPartitionKey + :ivar default_ttl: Default time to live. + :vartype default_ttl: int + """ + + _validation = { + "id": {"required": True}, + "rid": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "rid": {"key": "_rid", "type": "str"}, + "partition_key": {"key": "partitionKey", "type": "ContainerPartitionKey"}, + "default_ttl": {"key": "defaultTtl", "type": "int"}, + } + + def __init__( + self, + *, + id: str, # pylint: disable=redefined-builtin + partition_key: Optional["_models.ContainerPartitionKey"] = None, + default_ttl: Optional[int] = None, + **kwargs: Any + ) -> None: + """ + :keyword id: Name of the Cosmos DB SQL container. Required. + :paramtype id: str + :keyword partition_key: The configuration of the partition key to be used for partitioning data + into multiple partitions. + :paramtype partition_key: ~azure.mgmt.cosmosdb.models.ContainerPartitionKey + :keyword default_ttl: Default time to live. + :paramtype default_ttl: int + """ + super().__init__(**kwargs) + self.id = id + self.rid: Optional[str] = None + self.partition_key = partition_key + self.default_ttl = default_ttl + + +class SoftDeletedSqlContainersListResult(_serialization.Model): + """The List operation response, that contains the soft-deleted SQL containers and their + properties. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: List of soft-deleted SQL containers and their properties. + :vartype value: list[~azure.mgmt.cosmosdb.models.SoftDeletedSqlContainerGetResult] + :ivar next_link: The URL to get the next set of results. + :vartype next_link: str + """ + + _validation = { + "value": {"readonly": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[SoftDeletedSqlContainerGetResult]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__(self, *, next_link: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword next_link: The URL to get the next set of results. + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value: Optional[list["_models.SoftDeletedSqlContainerGetResult"]] = None + self.next_link = next_link + + +class SoftDeletedSqlDatabaseGetResult(_serialization.Model): + """An Azure Cosmos DB soft-deleted SQL database. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: The unique resource identifier of the ARM resource. + :vartype id: str + :ivar name: The name of the ARM resource. + :vartype name: str + :ivar type: The type of Azure resource. + :vartype type: str + :ivar location: The location of the resource group to which the resource belongs. + :vartype location: str + :ivar soft_deletion_metadata: Metadata related to the soft deletion of the SQL database. + :vartype soft_deletion_metadata: ~azure.mgmt.cosmosdb.models.SoftDeletionMetadata + :ivar resource: The resource information for the soft-deleted SQL database. + :vartype resource: ~azure.mgmt.cosmosdb.models.SoftDeletedSqlDatabaseResource + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "soft_deletion_metadata": {"key": "properties.softDeletionMetadata", "type": "SoftDeletionMetadata"}, + "resource": {"key": "properties.resource", "type": "SoftDeletedSqlDatabaseResource"}, + } + + def __init__( + self, + *, + location: Optional[str] = None, + soft_deletion_metadata: Optional["_models.SoftDeletionMetadata"] = None, + resource: Optional["_models.SoftDeletedSqlDatabaseResource"] = None, + **kwargs: Any + ) -> None: + """ + :keyword location: The location of the resource group to which the resource belongs. + :paramtype location: str + :keyword soft_deletion_metadata: Metadata related to the soft deletion of the SQL database. + :paramtype soft_deletion_metadata: ~azure.mgmt.cosmosdb.models.SoftDeletionMetadata + :keyword resource: The resource information for the soft-deleted SQL database. + :paramtype resource: ~azure.mgmt.cosmosdb.models.SoftDeletedSqlDatabaseResource + """ + super().__init__(**kwargs) + self.id: Optional[str] = None + self.name: Optional[str] = None + self.type: Optional[str] = None + self.location = location + self.soft_deletion_metadata = soft_deletion_metadata + self.resource = resource + + +class SoftDeletedSqlDatabaseResource(_serialization.Model): + """Cosmos DB SQL database resource object. + + 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: Name of the Cosmos DB SQL database. Required. + :vartype id: str + :ivar rid: A system generated property. A unique identifier. + :vartype rid: str + """ + + _validation = { + "id": {"required": True}, + "rid": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "rid": {"key": "_rid", "type": "str"}, + } + + def __init__(self, *, id: str, **kwargs: Any) -> None: # pylint: disable=redefined-builtin + """ + :keyword id: Name of the Cosmos DB SQL database. Required. + :paramtype id: str + """ + super().__init__(**kwargs) + self.id = id + self.rid: Optional[str] = None + + +class SoftDeletedSqlDatabasesListResult(_serialization.Model): + """The List operation response, that contains the soft-deleted SQL databases and their properties. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: List of soft-deleted SQL databases and their properties. + :vartype value: list[~azure.mgmt.cosmosdb.models.SoftDeletedSqlDatabaseGetResult] + :ivar next_link: The URL to get the next set of results. + :vartype next_link: str + """ + + _validation = { + "value": {"readonly": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[SoftDeletedSqlDatabaseGetResult]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__(self, *, next_link: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword next_link: The URL to get the next set of results. + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value: Optional[list["_models.SoftDeletedSqlDatabaseGetResult"]] = None + self.next_link = next_link + + +class SoftDeletionMetadata(_serialization.Model): + """Metadata about the soft deletion of a resource. + + :ivar is_soft_deleted: Indicates whether the resource is soft deleted. + :vartype is_soft_deleted: bool + :ivar soft_deletion_start_timestamp: The timestamp when the soft deletion started. + :vartype soft_deletion_start_timestamp: int + :ivar soft_deletion_resource_expiration_timestamp: The timestamp when the soft-deleted resource + will expire and be permanently deleted. + :vartype soft_deletion_resource_expiration_timestamp: int + """ + + _attribute_map = { + "is_soft_deleted": {"key": "isSoftDeleted", "type": "bool"}, + "soft_deletion_start_timestamp": {"key": "softDeletionStartTimestamp", "type": "int"}, + "soft_deletion_resource_expiration_timestamp": { + "key": "softDeletionResourceExpirationTimestamp", + "type": "int", + }, + } + + def __init__( + self, + *, + is_soft_deleted: Optional[bool] = None, + soft_deletion_start_timestamp: Optional[int] = None, + soft_deletion_resource_expiration_timestamp: Optional[int] = None, + **kwargs: Any + ) -> None: + """ + :keyword is_soft_deleted: Indicates whether the resource is soft deleted. + :paramtype is_soft_deleted: bool + :keyword soft_deletion_start_timestamp: The timestamp when the soft deletion started. + :paramtype soft_deletion_start_timestamp: int + :keyword soft_deletion_resource_expiration_timestamp: The timestamp when the soft-deleted + resource will expire and be permanently deleted. + :paramtype soft_deletion_resource_expiration_timestamp: int + """ super().__init__(**kwargs) - self.value: Optional[list["_models.ServiceResource"]] = None + self.is_soft_deleted = is_soft_deleted + self.soft_deletion_start_timestamp = soft_deletion_start_timestamp + self.soft_deletion_resource_expiration_timestamp = soft_deletion_resource_expiration_timestamp class SpatialSpec(_serialization.Model): @@ -17161,20 +17779,13 @@ class SqlContainerGetPropertiesOptions(OptionsResource): """ -class SqlContainerGetPropertiesResource(SqlContainerResource, ExtendedResourceProperties): +class SqlContainerGetPropertiesResource(SqlContainerResource): """SqlContainerGetPropertiesResource. 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 rid: A system generated property. A unique identifier. - :vartype rid: str - :ivar ts: A system generated property that denotes the last updated timestamp of the resource. - :vartype ts: float - :ivar etag: A system generated property representing the resource etag required for optimistic - concurrency control. - :vartype etag: str :ivar id: Name of the Cosmos DB SQL container. Required. :vartype id: str :ivar indexing_policy: The configuration of the indexing policy. By default, the indexing is @@ -17196,7 +17807,7 @@ class SqlContainerGetPropertiesResource(SqlContainerResource, ExtendedResourcePr :vartype analytical_storage_ttl: int :ivar restore_parameters: Parameters to indicate the information about the restore. :vartype restore_parameters: ~azure.mgmt.cosmosdb.models.ResourceRestoreParameters - :ivar create_mode: Enum to indicate the mode of resource creation. Known values are: "Default" + :ivar create_mode: Enum to indicate the mode of account creation. Known values are: "Default" and "Restore". :vartype create_mode: str or ~azure.mgmt.cosmosdb.models.CreateMode :ivar materialized_view_definition: The configuration for defining Materialized Views. This @@ -17215,19 +17826,23 @@ class SqlContainerGetPropertiesResource(SqlContainerResource, ExtendedResourcePr :vartype full_text_policy: ~azure.mgmt.cosmosdb.models.FullTextPolicy :ivar data_masking_policy: The Data Masking policy for the container. :vartype data_masking_policy: ~azure.mgmt.cosmosdb.models.DataMaskingPolicy + :ivar rid: A system generated property. A unique identifier. + :vartype rid: str + :ivar ts: A system generated property that denotes the last updated timestamp of the resource. + :vartype ts: float + :ivar etag: A system generated property representing the resource etag required for optimistic + concurrency control. + :vartype etag: str """ _validation = { + "id": {"required": True}, "rid": {"readonly": True}, "ts": {"readonly": True}, "etag": {"readonly": True}, - "id": {"required": True}, } _attribute_map = { - "rid": {"key": "_rid", "type": "str"}, - "ts": {"key": "_ts", "type": "float"}, - "etag": {"key": "_etag", "type": "str"}, "id": {"key": "id", "type": "str"}, "indexing_policy": {"key": "indexingPolicy", "type": "IndexingPolicy"}, "partition_key": {"key": "partitionKey", "type": "ContainerPartitionKey"}, @@ -17245,6 +17860,9 @@ class SqlContainerGetPropertiesResource(SqlContainerResource, ExtendedResourcePr "vector_embedding_policy": {"key": "vectorEmbeddingPolicy", "type": "VectorEmbeddingPolicy"}, "full_text_policy": {"key": "fullTextPolicy", "type": "FullTextPolicy"}, "data_masking_policy": {"key": "dataMaskingPolicy", "type": "DataMaskingPolicy"}, + "rid": {"key": "_rid", "type": "str"}, + "ts": {"key": "_ts", "type": "float"}, + "etag": {"key": "_etag", "type": "str"}, } def __init__( @@ -17259,7 +17877,7 @@ def __init__( client_encryption_policy: Optional["_models.ClientEncryptionPolicy"] = None, analytical_storage_ttl: Optional[int] = None, restore_parameters: Optional["_models.ResourceRestoreParameters"] = None, - create_mode: Union[str, "_models.CreateMode"] = "Default", + create_mode: Optional[Union[str, "_models.CreateMode"]] = None, materialized_view_definition: Optional["_models.MaterializedViewDefinition"] = None, materialized_views: Optional[list["_models.MaterializedViewDetails"]] = None, materialized_views_properties: Optional["_models.MaterializedViewsProperties"] = None, @@ -17291,7 +17909,7 @@ def __init__( :paramtype analytical_storage_ttl: int :keyword restore_parameters: Parameters to indicate the information about the restore. :paramtype restore_parameters: ~azure.mgmt.cosmosdb.models.ResourceRestoreParameters - :keyword create_mode: Enum to indicate the mode of resource creation. Known values are: + :keyword create_mode: Enum to indicate the mode of account creation. Known values are: "Default" and "Restore". :paramtype create_mode: str or ~azure.mgmt.cosmosdb.models.CreateMode :keyword materialized_view_definition: The configuration for defining Materialized Views. This @@ -17335,45 +17953,28 @@ def __init__( self.rid: Optional[str] = None self.ts: Optional[float] = None self.etag: Optional[str] = None - self.id = id - self.indexing_policy = indexing_policy - self.partition_key = partition_key - self.default_ttl = default_ttl - self.unique_key_policy = unique_key_policy - self.conflict_resolution_policy = conflict_resolution_policy - self.client_encryption_policy = client_encryption_policy - self.analytical_storage_ttl = analytical_storage_ttl - self.restore_parameters = restore_parameters - self.create_mode = create_mode - self.materialized_view_definition = materialized_view_definition - self.materialized_views = materialized_views - self.materialized_views_properties = materialized_views_properties - self.computed_properties = computed_properties - self.vector_embedding_policy = vector_embedding_policy - self.full_text_policy = full_text_policy - self.data_masking_policy = data_masking_policy -class SqlContainerGetResults(ARMResourceProperties): +class SqlContainerGetResults(Resource): """An Azure Cosmos DB container. Variables are only populated by the server, and will be ignored when sending a request. - :ivar id: The unique resource identifier of the ARM resource. + :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 ARM resource. + :ivar name: The name of the resource. :vartype name: str - :ivar type: The type of Azure resource. + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". :vartype type: str - :ivar location: The location of the resource group to which the resource belongs. - :vartype location: str - :ivar tags: Tags are a list of key-value pairs that describe the resource. These tags can be - used in viewing and grouping this resource (across resource groups). A maximum of 15 tags can - be provided for a resource. Each tag must have a key no greater than 128 characters and value - no greater than 256 characters. For example, the default experience for a template type is set - with "defaultExperience": "Cassandra". Current "defaultExperience" values also include "Table", - "Graph", "DocumentDB", and "MongoDB". + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.cosmosdb.models.SystemData + :ivar tags: Resource tags. :vartype tags: dict[str, str] + :ivar location: The geo-location where the resource lives. + :vartype location: str :ivar identity: Identity for the resource. :vartype identity: ~azure.mgmt.cosmosdb.models.ManagedServiceIdentity :ivar resource: @@ -17386,14 +17987,16 @@ class SqlContainerGetResults(ARMResourceProperties): "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"}, - "location": {"key": "location", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, "tags": {"key": "tags", "type": "{str}"}, + "location": {"key": "location", "type": "str"}, "identity": {"key": "identity", "type": "ManagedServiceIdentity"}, "resource": {"key": "properties.resource", "type": "SqlContainerGetPropertiesResource"}, "options": {"key": "properties.options", "type": "SqlContainerGetPropertiesOptions"}, @@ -17402,23 +18005,18 @@ class SqlContainerGetResults(ARMResourceProperties): def __init__( self, *, - location: Optional[str] = None, tags: Optional[dict[str, str]] = None, + location: Optional[str] = None, identity: Optional["_models.ManagedServiceIdentity"] = None, resource: Optional["_models.SqlContainerGetPropertiesResource"] = None, options: Optional["_models.SqlContainerGetPropertiesOptions"] = None, **kwargs: Any ) -> None: """ - :keyword location: The location of the resource group to which the resource belongs. - :paramtype location: str - :keyword tags: Tags are a list of key-value pairs that describe the resource. These tags can be - used in viewing and grouping this resource (across resource groups). A maximum of 15 tags can - be provided for a resource. Each tag must have a key no greater than 128 characters and value - no greater than 256 characters. For example, the default experience for a template type is set - with "defaultExperience": "Cassandra". Current "defaultExperience" values also include "Table", - "Graph", "DocumentDB", and "MongoDB". + :keyword tags: Resource tags. :paramtype tags: dict[str, str] + :keyword location: The geo-location where the resource lives. + :paramtype location: str :keyword identity: Identity for the resource. :paramtype identity: ~azure.mgmt.cosmosdb.models.ManagedServiceIdentity :keyword resource: @@ -17426,7 +18024,10 @@ def __init__( :keyword options: :paramtype options: ~azure.mgmt.cosmosdb.models.SqlContainerGetPropertiesOptions """ - super().__init__(location=location, tags=tags, identity=identity, **kwargs) + super().__init__(**kwargs) + self.tags = tags + self.location = location + self.identity = identity self.resource = resource self.options = options @@ -17438,6 +18039,8 @@ class SqlContainerListResult(_serialization.Model): :ivar value: List of containers and their properties. :vartype value: list[~azure.mgmt.cosmosdb.models.SqlContainerGetResults] + :ivar next_link: + :vartype next_link: str """ _validation = { @@ -17446,12 +18049,17 @@ class SqlContainerListResult(_serialization.Model): _attribute_map = { "value": {"key": "value", "type": "[SqlContainerGetResults]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__(self, **kwargs: Any) -> None: - """ """ + def __init__(self, *, next_link: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword next_link: + :paramtype next_link: str + """ super().__init__(**kwargs) self.value: Optional[list["_models.SqlContainerGetResults"]] = None + self.next_link = next_link class SqlDatabaseCreateUpdateParameters(ARMResourceProperties): @@ -17547,13 +18155,20 @@ class SqlDatabaseGetPropertiesOptions(OptionsResource): """ -class SqlDatabaseGetPropertiesResource(SqlDatabaseResource, ExtendedResourceProperties): +class SqlDatabaseGetPropertiesResource(SqlDatabaseResource): """SqlDatabaseGetPropertiesResource. 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: Name of the Cosmos DB SQL database. Required. + :vartype id: str + :ivar restore_parameters: Parameters to indicate the information about the restore. + :vartype restore_parameters: ~azure.mgmt.cosmosdb.models.ResourceRestoreParameters + :ivar create_mode: Enum to indicate the mode of account creation. Known values are: "Default" + and "Restore". + :vartype create_mode: str or ~azure.mgmt.cosmosdb.models.CreateMode :ivar rid: A system generated property. A unique identifier. :vartype rid: str :ivar ts: A system generated property that denotes the last updated timestamp of the resource. @@ -17561,13 +18176,6 @@ class SqlDatabaseGetPropertiesResource(SqlDatabaseResource, ExtendedResourceProp :ivar etag: A system generated property representing the resource etag required for optimistic concurrency control. :vartype etag: str - :ivar id: Name of the Cosmos DB SQL database. Required. - :vartype id: str - :ivar restore_parameters: Parameters to indicate the information about the restore. - :vartype restore_parameters: ~azure.mgmt.cosmosdb.models.ResourceRestoreParameters - :ivar create_mode: Enum to indicate the mode of resource creation. Known values are: "Default" - and "Restore". - :vartype create_mode: str or ~azure.mgmt.cosmosdb.models.CreateMode :ivar colls: A system generated property that specified the addressable path of the collections resource. :vartype colls: str @@ -17577,19 +18185,19 @@ class SqlDatabaseGetPropertiesResource(SqlDatabaseResource, ExtendedResourceProp """ _validation = { + "id": {"required": True}, "rid": {"readonly": True}, "ts": {"readonly": True}, "etag": {"readonly": True}, - "id": {"required": True}, } _attribute_map = { - "rid": {"key": "_rid", "type": "str"}, - "ts": {"key": "_ts", "type": "float"}, - "etag": {"key": "_etag", "type": "str"}, "id": {"key": "id", "type": "str"}, "restore_parameters": {"key": "restoreParameters", "type": "ResourceRestoreParameters"}, "create_mode": {"key": "createMode", "type": "str"}, + "rid": {"key": "_rid", "type": "str"}, + "ts": {"key": "_ts", "type": "float"}, + "etag": {"key": "_etag", "type": "str"}, "colls": {"key": "_colls", "type": "str"}, "users": {"key": "_users", "type": "str"}, } @@ -17599,7 +18207,7 @@ def __init__( *, id: str, # pylint: disable=redefined-builtin restore_parameters: Optional["_models.ResourceRestoreParameters"] = None, - create_mode: Union[str, "_models.CreateMode"] = "Default", + create_mode: Optional[Union[str, "_models.CreateMode"]] = None, colls: Optional[str] = None, users: Optional[str] = None, **kwargs: Any @@ -17609,7 +18217,7 @@ def __init__( :paramtype id: str :keyword restore_parameters: Parameters to indicate the information about the restore. :paramtype restore_parameters: ~azure.mgmt.cosmosdb.models.ResourceRestoreParameters - :keyword create_mode: Enum to indicate the mode of resource creation. Known values are: + :keyword create_mode: Enum to indicate the mode of account creation. Known values are: "Default" and "Restore". :paramtype create_mode: str or ~azure.mgmt.cosmosdb.models.CreateMode :keyword colls: A system generated property that specified the addressable path of the @@ -17625,31 +18233,28 @@ def __init__( self.etag: Optional[str] = None self.colls = colls self.users = users - self.id = id - self.restore_parameters = restore_parameters - self.create_mode = create_mode -class SqlDatabaseGetResults(ARMResourceProperties): +class SqlDatabaseGetResults(Resource): """An Azure Cosmos DB SQL database. Variables are only populated by the server, and will be ignored when sending a request. - :ivar id: The unique resource identifier of the ARM resource. + :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 ARM resource. + :ivar name: The name of the resource. :vartype name: str - :ivar type: The type of Azure resource. + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". :vartype type: str - :ivar location: The location of the resource group to which the resource belongs. - :vartype location: str - :ivar tags: Tags are a list of key-value pairs that describe the resource. These tags can be - used in viewing and grouping this resource (across resource groups). A maximum of 15 tags can - be provided for a resource. Each tag must have a key no greater than 128 characters and value - no greater than 256 characters. For example, the default experience for a template type is set - with "defaultExperience": "Cassandra". Current "defaultExperience" values also include "Table", - "Graph", "DocumentDB", and "MongoDB". + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.cosmosdb.models.SystemData + :ivar tags: Resource tags. :vartype tags: dict[str, str] + :ivar location: The geo-location where the resource lives. + :vartype location: str :ivar identity: Identity for the resource. :vartype identity: ~azure.mgmt.cosmosdb.models.ManagedServiceIdentity :ivar resource: @@ -17662,14 +18267,16 @@ class SqlDatabaseGetResults(ARMResourceProperties): "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"}, - "location": {"key": "location", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, "tags": {"key": "tags", "type": "{str}"}, + "location": {"key": "location", "type": "str"}, "identity": {"key": "identity", "type": "ManagedServiceIdentity"}, "resource": {"key": "properties.resource", "type": "SqlDatabaseGetPropertiesResource"}, "options": {"key": "properties.options", "type": "SqlDatabaseGetPropertiesOptions"}, @@ -17678,23 +18285,18 @@ class SqlDatabaseGetResults(ARMResourceProperties): def __init__( self, *, - location: Optional[str] = None, tags: Optional[dict[str, str]] = None, + location: Optional[str] = None, identity: Optional["_models.ManagedServiceIdentity"] = None, resource: Optional["_models.SqlDatabaseGetPropertiesResource"] = None, options: Optional["_models.SqlDatabaseGetPropertiesOptions"] = None, **kwargs: Any ) -> None: """ - :keyword location: The location of the resource group to which the resource belongs. - :paramtype location: str - :keyword tags: Tags are a list of key-value pairs that describe the resource. These tags can be - used in viewing and grouping this resource (across resource groups). A maximum of 15 tags can - be provided for a resource. Each tag must have a key no greater than 128 characters and value - no greater than 256 characters. For example, the default experience for a template type is set - with "defaultExperience": "Cassandra". Current "defaultExperience" values also include "Table", - "Graph", "DocumentDB", and "MongoDB". + :keyword tags: Resource tags. :paramtype tags: dict[str, str] + :keyword location: The geo-location where the resource lives. + :paramtype location: str :keyword identity: Identity for the resource. :paramtype identity: ~azure.mgmt.cosmosdb.models.ManagedServiceIdentity :keyword resource: @@ -17702,7 +18304,10 @@ def __init__( :keyword options: :paramtype options: ~azure.mgmt.cosmosdb.models.SqlDatabaseGetPropertiesOptions """ - super().__init__(location=location, tags=tags, identity=identity, **kwargs) + super().__init__(**kwargs) + self.tags = tags + self.location = location + self.identity = identity self.resource = resource self.options = options @@ -17714,6 +18319,8 @@ class SqlDatabaseListResult(_serialization.Model): :ivar value: List of SQL databases and their properties. :vartype value: list[~azure.mgmt.cosmosdb.models.SqlDatabaseGetResults] + :ivar next_link: + :vartype next_link: str """ _validation = { @@ -17722,12 +18329,17 @@ class SqlDatabaseListResult(_serialization.Model): _attribute_map = { "value": {"key": "value", "type": "[SqlDatabaseGetResults]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__(self, **kwargs: Any) -> None: - """ """ + def __init__(self, *, next_link: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword next_link: + :paramtype next_link: str + """ super().__init__(**kwargs) self.value: Optional[list["_models.SqlDatabaseGetResults"]] = None + self.next_link = next_link class SqlDedicatedGatewayRegionalServiceResource(RegionalServiceResource): # pylint: disable=name-too-long @@ -17766,28 +18378,6 @@ def __init__(self, **kwargs: Any) -> None: self.sql_dedicated_gateway_endpoint: Optional[str] = None -class SqlDedicatedGatewayServiceResource(_serialization.Model): - """Describes the service response property for SqlDedicatedGateway. - - :ivar properties: Properties for SqlDedicatedGatewayServiceResource. - :vartype properties: ~azure.mgmt.cosmosdb.models.SqlDedicatedGatewayServiceResourceProperties - """ - - _attribute_map = { - "properties": {"key": "properties", "type": "SqlDedicatedGatewayServiceResourceProperties"}, - } - - def __init__( - self, *, properties: Optional["_models.SqlDedicatedGatewayServiceResourceProperties"] = None, **kwargs: Any - ) -> None: - """ - :keyword properties: Properties for SqlDedicatedGatewayServiceResource. - :paramtype properties: ~azure.mgmt.cosmosdb.models.SqlDedicatedGatewayServiceResourceProperties - """ - super().__init__(**kwargs) - self.properties = properties - - class SqlDedicatedGatewayServiceResourceCreateUpdateProperties( ServiceResourceCreateUpdateProperties ): # pylint: disable=name-too-long @@ -17978,17 +18568,22 @@ def __init__( self.principal_id = principal_id -class SqlRoleAssignmentGetResults(ARMProxyResource): +class SqlRoleAssignmentGetResults(ProxyResource): """An Azure Cosmos DB Role Assignment. Variables are only populated by the server, and will be ignored when sending a request. - :ivar id: The unique resource identifier of the database account. + :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 database account. + :ivar name: The name of the resource. :vartype name: str - :ivar type: The type of Azure resource. + :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.cosmosdb.models.SystemData :ivar role_definition_id: The unique identifier for the associated Role Definition. :vartype role_definition_id: str :ivar scope: The data plane resource path for which access is being granted through this Role @@ -18004,12 +18599,14 @@ class SqlRoleAssignmentGetResults(ARMProxyResource): "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"}, "role_definition_id": {"key": "properties.roleDefinitionId", "type": "str"}, "scope": {"key": "properties.scope", "type": "str"}, "principal_id": {"key": "properties.principalId", "type": "str"}, @@ -18047,6 +18644,8 @@ class SqlRoleAssignmentListResult(_serialization.Model): :ivar value: List of Role Assignments and their properties. :vartype value: list[~azure.mgmt.cosmosdb.models.SqlRoleAssignmentGetResults] + :ivar next_link: + :vartype next_link: str """ _validation = { @@ -18055,12 +18654,17 @@ class SqlRoleAssignmentListResult(_serialization.Model): _attribute_map = { "value": {"key": "value", "type": "[SqlRoleAssignmentGetResults]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__(self, **kwargs: Any) -> None: - """ """ + def __init__(self, *, next_link: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword next_link: + :paramtype next_link: str + """ super().__init__(**kwargs) self.value: Optional[list["_models.SqlRoleAssignmentGetResults"]] = None + self.next_link = next_link class SqlRoleDefinitionCreateUpdateParameters(_serialization.Model): @@ -18079,14 +18683,14 @@ class SqlRoleDefinitionCreateUpdateParameters(_serialization.Model): that resources referenced in assignable Scopes need not exist. :vartype assignable_scopes: list[str] :ivar permissions: The set of operations allowed through this Role Definition. - :vartype permissions: list[~azure.mgmt.cosmosdb.models.PermissionAutoGenerated] + :vartype permissions: list[~azure.mgmt.cosmosdb.models.Permission] """ _attribute_map = { "role_name": {"key": "properties.roleName", "type": "str"}, "type": {"key": "properties.type", "type": "str"}, "assignable_scopes": {"key": "properties.assignableScopes", "type": "[str]"}, - "permissions": {"key": "properties.permissions", "type": "[PermissionAutoGenerated]"}, + "permissions": {"key": "properties.permissions", "type": "[Permission]"}, } def __init__( @@ -18095,7 +18699,7 @@ def __init__( role_name: Optional[str] = None, type: Optional[Union[str, "_models.RoleDefinitionType"]] = None, assignable_scopes: Optional[list[str]] = None, - permissions: Optional[list["_models.PermissionAutoGenerated"]] = None, + permissions: Optional[list["_models.Permission"]] = None, **kwargs: Any ) -> None: """ @@ -18112,7 +18716,7 @@ def __init__( that resources referenced in assignable Scopes need not exist. :paramtype assignable_scopes: list[str] :keyword permissions: The set of operations allowed through this Role Definition. - :paramtype permissions: list[~azure.mgmt.cosmosdb.models.PermissionAutoGenerated] + :paramtype permissions: list[~azure.mgmt.cosmosdb.models.Permission] """ super().__init__(**kwargs) self.role_name = role_name @@ -18121,17 +18725,22 @@ def __init__( self.permissions = permissions -class SqlRoleDefinitionGetResults(ARMProxyResource): +class SqlRoleDefinitionGetResults(ProxyResource): """An Azure Cosmos DB SQL Role Definition. Variables are only populated by the server, and will be ignored when sending a request. - :ivar id: The unique resource identifier of the database account. + :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 database account. + :ivar name: The name of the resource. :vartype name: str - :ivar type: The type of Azure resource. + :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.cosmosdb.models.SystemData :ivar role_name: A user-friendly name for the Role Definition. Must be unique for the database account. :vartype role_name: str @@ -18145,23 +18754,25 @@ class SqlRoleDefinitionGetResults(ARMProxyResource): that resources referenced in assignable Scopes need not exist. :vartype assignable_scopes: list[str] :ivar permissions: The set of operations allowed through this Role Definition. - :vartype permissions: list[~azure.mgmt.cosmosdb.models.PermissionAutoGenerated] + :vartype permissions: list[~azure.mgmt.cosmosdb.models.Permission] """ _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"}, "role_name": {"key": "properties.roleName", "type": "str"}, "type_properties_type": {"key": "properties.type", "type": "str"}, "assignable_scopes": {"key": "properties.assignableScopes", "type": "[str]"}, - "permissions": {"key": "properties.permissions", "type": "[PermissionAutoGenerated]"}, + "permissions": {"key": "properties.permissions", "type": "[Permission]"}, } def __init__( @@ -18170,7 +18781,7 @@ def __init__( role_name: Optional[str] = None, type_properties_type: Optional[Union[str, "_models.RoleDefinitionType"]] = None, assignable_scopes: Optional[list[str]] = None, - permissions: Optional[list["_models.PermissionAutoGenerated"]] = None, + permissions: Optional[list["_models.Permission"]] = None, **kwargs: Any ) -> None: """ @@ -18187,7 +18798,7 @@ def __init__( that resources referenced in assignable Scopes need not exist. :paramtype assignable_scopes: list[str] :keyword permissions: The set of operations allowed through this Role Definition. - :paramtype permissions: list[~azure.mgmt.cosmosdb.models.PermissionAutoGenerated] + :paramtype permissions: list[~azure.mgmt.cosmosdb.models.Permission] """ super().__init__(**kwargs) self.role_name = role_name @@ -18203,6 +18814,8 @@ class SqlRoleDefinitionListResult(_serialization.Model): :ivar value: List of Role Definitions and their properties. :vartype value: list[~azure.mgmt.cosmosdb.models.SqlRoleDefinitionGetResults] + :ivar next_link: + :vartype next_link: str """ _validation = { @@ -18211,12 +18824,17 @@ class SqlRoleDefinitionListResult(_serialization.Model): _attribute_map = { "value": {"key": "value", "type": "[SqlRoleDefinitionGetResults]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__(self, **kwargs: Any) -> None: - """ """ + def __init__(self, *, next_link: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword next_link: + :paramtype next_link: str + """ super().__init__(**kwargs) self.value: Optional[list["_models.SqlRoleDefinitionGetResults"]] = None + self.next_link = next_link class SqlStoredProcedureCreateUpdateParameters(ARMResourceProperties): @@ -18335,13 +18953,17 @@ def __init__( self.body = body -class SqlStoredProcedureGetPropertiesResource(SqlStoredProcedureResource, ExtendedResourceProperties): +class SqlStoredProcedureGetPropertiesResource(SqlStoredProcedureResource): """SqlStoredProcedureGetPropertiesResource. 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: Name of the Cosmos DB SQL storedProcedure. Required. + :vartype id: str + :ivar body: Body of the Stored Procedure. + :vartype body: str :ivar rid: A system generated property. A unique identifier. :vartype rid: str :ivar ts: A system generated property that denotes the last updated timestamp of the resource. @@ -18349,25 +18971,21 @@ class SqlStoredProcedureGetPropertiesResource(SqlStoredProcedureResource, Extend :ivar etag: A system generated property representing the resource etag required for optimistic concurrency control. :vartype etag: str - :ivar id: Name of the Cosmos DB SQL storedProcedure. Required. - :vartype id: str - :ivar body: Body of the Stored Procedure. - :vartype body: str """ _validation = { + "id": {"required": True}, "rid": {"readonly": True}, "ts": {"readonly": True}, "etag": {"readonly": True}, - "id": {"required": True}, } _attribute_map = { + "id": {"key": "id", "type": "str"}, + "body": {"key": "body", "type": "str"}, "rid": {"key": "_rid", "type": "str"}, "ts": {"key": "_ts", "type": "float"}, "etag": {"key": "_etag", "type": "str"}, - "id": {"key": "id", "type": "str"}, - "body": {"key": "body", "type": "str"}, } def __init__( @@ -18383,30 +19001,28 @@ def __init__( self.rid: Optional[str] = None self.ts: Optional[float] = None self.etag: Optional[str] = None - self.id = id - self.body = body -class SqlStoredProcedureGetResults(ARMResourceProperties): +class SqlStoredProcedureGetResults(Resource): """An Azure Cosmos DB storedProcedure. Variables are only populated by the server, and will be ignored when sending a request. - :ivar id: The unique resource identifier of the ARM resource. + :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 ARM resource. + :ivar name: The name of the resource. :vartype name: str - :ivar type: The type of Azure resource. + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". :vartype type: str - :ivar location: The location of the resource group to which the resource belongs. - :vartype location: str - :ivar tags: Tags are a list of key-value pairs that describe the resource. These tags can be - used in viewing and grouping this resource (across resource groups). A maximum of 15 tags can - be provided for a resource. Each tag must have a key no greater than 128 characters and value - no greater than 256 characters. For example, the default experience for a template type is set - with "defaultExperience": "Cassandra". Current "defaultExperience" values also include "Table", - "Graph", "DocumentDB", and "MongoDB". + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.cosmosdb.models.SystemData + :ivar tags: Resource tags. :vartype tags: dict[str, str] + :ivar location: The geo-location where the resource lives. + :vartype location: str :ivar identity: Identity for the resource. :vartype identity: ~azure.mgmt.cosmosdb.models.ManagedServiceIdentity :ivar resource: @@ -18417,14 +19033,16 @@ class SqlStoredProcedureGetResults(ARMResourceProperties): "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"}, - "location": {"key": "location", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, "tags": {"key": "tags", "type": "{str}"}, + "location": {"key": "location", "type": "str"}, "identity": {"key": "identity", "type": "ManagedServiceIdentity"}, "resource": {"key": "properties.resource", "type": "SqlStoredProcedureGetPropertiesResource"}, } @@ -18432,28 +19050,26 @@ class SqlStoredProcedureGetResults(ARMResourceProperties): def __init__( self, *, - location: Optional[str] = None, tags: Optional[dict[str, str]] = None, + location: Optional[str] = None, identity: Optional["_models.ManagedServiceIdentity"] = None, resource: Optional["_models.SqlStoredProcedureGetPropertiesResource"] = None, **kwargs: Any ) -> None: """ - :keyword location: The location of the resource group to which the resource belongs. - :paramtype location: str - :keyword tags: Tags are a list of key-value pairs that describe the resource. These tags can be - used in viewing and grouping this resource (across resource groups). A maximum of 15 tags can - be provided for a resource. Each tag must have a key no greater than 128 characters and value - no greater than 256 characters. For example, the default experience for a template type is set - with "defaultExperience": "Cassandra". Current "defaultExperience" values also include "Table", - "Graph", "DocumentDB", and "MongoDB". + :keyword tags: Resource tags. :paramtype tags: dict[str, str] + :keyword location: The geo-location where the resource lives. + :paramtype location: str :keyword identity: Identity for the resource. :paramtype identity: ~azure.mgmt.cosmosdb.models.ManagedServiceIdentity :keyword resource: :paramtype resource: ~azure.mgmt.cosmosdb.models.SqlStoredProcedureGetPropertiesResource """ - super().__init__(location=location, tags=tags, identity=identity, **kwargs) + super().__init__(**kwargs) + self.tags = tags + self.location = location + self.identity = identity self.resource = resource @@ -18464,6 +19080,8 @@ class SqlStoredProcedureListResult(_serialization.Model): :ivar value: List of storedProcedures and their properties. :vartype value: list[~azure.mgmt.cosmosdb.models.SqlStoredProcedureGetResults] + :ivar next_link: + :vartype next_link: str """ _validation = { @@ -18472,12 +19090,17 @@ class SqlStoredProcedureListResult(_serialization.Model): _attribute_map = { "value": {"key": "value", "type": "[SqlStoredProcedureGetResults]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__(self, **kwargs: Any) -> None: - """ """ + def __init__(self, *, next_link: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword next_link: + :paramtype next_link: str + """ super().__init__(**kwargs) self.value: Optional[list["_models.SqlStoredProcedureGetResults"]] = None + self.next_link = next_link class SqlTriggerCreateUpdateParameters(ARMResourceProperties): @@ -18616,20 +19239,13 @@ def __init__( self.trigger_operation = trigger_operation -class SqlTriggerGetPropertiesResource(SqlTriggerResource, ExtendedResourceProperties): +class SqlTriggerGetPropertiesResource(SqlTriggerResource): """SqlTriggerGetPropertiesResource. 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 rid: A system generated property. A unique identifier. - :vartype rid: str - :ivar ts: A system generated property that denotes the last updated timestamp of the resource. - :vartype ts: float - :ivar etag: A system generated property representing the resource etag required for optimistic - concurrency control. - :vartype etag: str :ivar id: Name of the Cosmos DB SQL trigger. Required. :vartype id: str :ivar body: Body of the Trigger. @@ -18639,23 +19255,30 @@ class SqlTriggerGetPropertiesResource(SqlTriggerResource, ExtendedResourceProper :ivar trigger_operation: The operation the trigger is associated with. Known values are: "All", "Create", "Update", "Delete", and "Replace". :vartype trigger_operation: str or ~azure.mgmt.cosmosdb.models.TriggerOperation + :ivar rid: A system generated property. A unique identifier. + :vartype rid: str + :ivar ts: A system generated property that denotes the last updated timestamp of the resource. + :vartype ts: float + :ivar etag: A system generated property representing the resource etag required for optimistic + concurrency control. + :vartype etag: str """ _validation = { + "id": {"required": True}, "rid": {"readonly": True}, "ts": {"readonly": True}, "etag": {"readonly": True}, - "id": {"required": True}, } _attribute_map = { - "rid": {"key": "_rid", "type": "str"}, - "ts": {"key": "_ts", "type": "float"}, - "etag": {"key": "_etag", "type": "str"}, "id": {"key": "id", "type": "str"}, "body": {"key": "body", "type": "str"}, "trigger_type": {"key": "triggerType", "type": "str"}, "trigger_operation": {"key": "triggerOperation", "type": "str"}, + "rid": {"key": "_rid", "type": "str"}, + "ts": {"key": "_ts", "type": "float"}, + "etag": {"key": "_etag", "type": "str"}, } def __init__( @@ -18682,32 +19305,28 @@ def __init__( self.rid: Optional[str] = None self.ts: Optional[float] = None self.etag: Optional[str] = None - self.id = id - self.body = body - self.trigger_type = trigger_type - self.trigger_operation = trigger_operation -class SqlTriggerGetResults(ARMResourceProperties): +class SqlTriggerGetResults(Resource): """An Azure Cosmos DB trigger. Variables are only populated by the server, and will be ignored when sending a request. - :ivar id: The unique resource identifier of the ARM resource. + :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 ARM resource. + :ivar name: The name of the resource. :vartype name: str - :ivar type: The type of Azure resource. + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". :vartype type: str - :ivar location: The location of the resource group to which the resource belongs. - :vartype location: str - :ivar tags: Tags are a list of key-value pairs that describe the resource. These tags can be - used in viewing and grouping this resource (across resource groups). A maximum of 15 tags can - be provided for a resource. Each tag must have a key no greater than 128 characters and value - no greater than 256 characters. For example, the default experience for a template type is set - with "defaultExperience": "Cassandra". Current "defaultExperience" values also include "Table", - "Graph", "DocumentDB", and "MongoDB". + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.cosmosdb.models.SystemData + :ivar tags: Resource tags. :vartype tags: dict[str, str] + :ivar location: The geo-location where the resource lives. + :vartype location: str :ivar identity: Identity for the resource. :vartype identity: ~azure.mgmt.cosmosdb.models.ManagedServiceIdentity :ivar resource: @@ -18718,14 +19337,16 @@ class SqlTriggerGetResults(ARMResourceProperties): "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"}, - "location": {"key": "location", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, "tags": {"key": "tags", "type": "{str}"}, + "location": {"key": "location", "type": "str"}, "identity": {"key": "identity", "type": "ManagedServiceIdentity"}, "resource": {"key": "properties.resource", "type": "SqlTriggerGetPropertiesResource"}, } @@ -18733,28 +19354,26 @@ class SqlTriggerGetResults(ARMResourceProperties): def __init__( self, *, - location: Optional[str] = None, tags: Optional[dict[str, str]] = None, + location: Optional[str] = None, identity: Optional["_models.ManagedServiceIdentity"] = None, resource: Optional["_models.SqlTriggerGetPropertiesResource"] = None, **kwargs: Any ) -> None: """ - :keyword location: The location of the resource group to which the resource belongs. - :paramtype location: str - :keyword tags: Tags are a list of key-value pairs that describe the resource. These tags can be - used in viewing and grouping this resource (across resource groups). A maximum of 15 tags can - be provided for a resource. Each tag must have a key no greater than 128 characters and value - no greater than 256 characters. For example, the default experience for a template type is set - with "defaultExperience": "Cassandra". Current "defaultExperience" values also include "Table", - "Graph", "DocumentDB", and "MongoDB". + :keyword tags: Resource tags. :paramtype tags: dict[str, str] + :keyword location: The geo-location where the resource lives. + :paramtype location: str :keyword identity: Identity for the resource. :paramtype identity: ~azure.mgmt.cosmosdb.models.ManagedServiceIdentity :keyword resource: :paramtype resource: ~azure.mgmt.cosmosdb.models.SqlTriggerGetPropertiesResource """ - super().__init__(location=location, tags=tags, identity=identity, **kwargs) + super().__init__(**kwargs) + self.tags = tags + self.location = location + self.identity = identity self.resource = resource @@ -18765,6 +19384,8 @@ class SqlTriggerListResult(_serialization.Model): :ivar value: List of triggers and their properties. :vartype value: list[~azure.mgmt.cosmosdb.models.SqlTriggerGetResults] + :ivar next_link: + :vartype next_link: str """ _validation = { @@ -18773,12 +19394,17 @@ class SqlTriggerListResult(_serialization.Model): _attribute_map = { "value": {"key": "value", "type": "[SqlTriggerGetResults]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__(self, **kwargs: Any) -> None: - """ """ + def __init__(self, *, next_link: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword next_link: + :paramtype next_link: str + """ super().__init__(**kwargs) self.value: Optional[list["_models.SqlTriggerGetResults"]] = None + self.next_link = next_link class SqlUserDefinedFunctionCreateUpdateParameters(ARMResourceProperties): # pylint: disable=name-too-long @@ -18897,15 +19523,17 @@ def __init__( self.body = body -class SqlUserDefinedFunctionGetPropertiesResource( - SqlUserDefinedFunctionResource, ExtendedResourceProperties -): # pylint: disable=name-too-long +class SqlUserDefinedFunctionGetPropertiesResource(SqlUserDefinedFunctionResource): # pylint: disable=name-too-long """SqlUserDefinedFunctionGetPropertiesResource. 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: Name of the Cosmos DB SQL userDefinedFunction. Required. + :vartype id: str + :ivar body: Body of the User Defined Function. + :vartype body: str :ivar rid: A system generated property. A unique identifier. :vartype rid: str :ivar ts: A system generated property that denotes the last updated timestamp of the resource. @@ -18913,25 +19541,21 @@ class SqlUserDefinedFunctionGetPropertiesResource( :ivar etag: A system generated property representing the resource etag required for optimistic concurrency control. :vartype etag: str - :ivar id: Name of the Cosmos DB SQL userDefinedFunction. Required. - :vartype id: str - :ivar body: Body of the User Defined Function. - :vartype body: str """ _validation = { + "id": {"required": True}, "rid": {"readonly": True}, "ts": {"readonly": True}, "etag": {"readonly": True}, - "id": {"required": True}, } _attribute_map = { + "id": {"key": "id", "type": "str"}, + "body": {"key": "body", "type": "str"}, "rid": {"key": "_rid", "type": "str"}, "ts": {"key": "_ts", "type": "float"}, "etag": {"key": "_etag", "type": "str"}, - "id": {"key": "id", "type": "str"}, - "body": {"key": "body", "type": "str"}, } def __init__( @@ -18947,30 +19571,28 @@ def __init__( self.rid: Optional[str] = None self.ts: Optional[float] = None self.etag: Optional[str] = None - self.id = id - self.body = body -class SqlUserDefinedFunctionGetResults(ARMResourceProperties): +class SqlUserDefinedFunctionGetResults(Resource): """An Azure Cosmos DB userDefinedFunction. Variables are only populated by the server, and will be ignored when sending a request. - :ivar id: The unique resource identifier of the ARM resource. + :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 ARM resource. + :ivar name: The name of the resource. :vartype name: str - :ivar type: The type of Azure resource. + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". :vartype type: str - :ivar location: The location of the resource group to which the resource belongs. - :vartype location: str - :ivar tags: Tags are a list of key-value pairs that describe the resource. These tags can be - used in viewing and grouping this resource (across resource groups). A maximum of 15 tags can - be provided for a resource. Each tag must have a key no greater than 128 characters and value - no greater than 256 characters. For example, the default experience for a template type is set - with "defaultExperience": "Cassandra". Current "defaultExperience" values also include "Table", - "Graph", "DocumentDB", and "MongoDB". + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.cosmosdb.models.SystemData + :ivar tags: Resource tags. :vartype tags: dict[str, str] + :ivar location: The geo-location where the resource lives. + :vartype location: str :ivar identity: Identity for the resource. :vartype identity: ~azure.mgmt.cosmosdb.models.ManagedServiceIdentity :ivar resource: @@ -18981,14 +19603,16 @@ class SqlUserDefinedFunctionGetResults(ARMResourceProperties): "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"}, - "location": {"key": "location", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, "tags": {"key": "tags", "type": "{str}"}, + "location": {"key": "location", "type": "str"}, "identity": {"key": "identity", "type": "ManagedServiceIdentity"}, "resource": {"key": "properties.resource", "type": "SqlUserDefinedFunctionGetPropertiesResource"}, } @@ -18996,28 +19620,26 @@ class SqlUserDefinedFunctionGetResults(ARMResourceProperties): def __init__( self, *, - location: Optional[str] = None, tags: Optional[dict[str, str]] = None, + location: Optional[str] = None, identity: Optional["_models.ManagedServiceIdentity"] = None, resource: Optional["_models.SqlUserDefinedFunctionGetPropertiesResource"] = None, **kwargs: Any ) -> None: """ - :keyword location: The location of the resource group to which the resource belongs. - :paramtype location: str - :keyword tags: Tags are a list of key-value pairs that describe the resource. These tags can be - used in viewing and grouping this resource (across resource groups). A maximum of 15 tags can - be provided for a resource. Each tag must have a key no greater than 128 characters and value - no greater than 256 characters. For example, the default experience for a template type is set - with "defaultExperience": "Cassandra". Current "defaultExperience" values also include "Table", - "Graph", "DocumentDB", and "MongoDB". + :keyword tags: Resource tags. :paramtype tags: dict[str, str] + :keyword location: The geo-location where the resource lives. + :paramtype location: str :keyword identity: Identity for the resource. :paramtype identity: ~azure.mgmt.cosmosdb.models.ManagedServiceIdentity :keyword resource: :paramtype resource: ~azure.mgmt.cosmosdb.models.SqlUserDefinedFunctionGetPropertiesResource """ - super().__init__(location=location, tags=tags, identity=identity, **kwargs) + super().__init__(**kwargs) + self.tags = tags + self.location = location + self.identity = identity self.resource = resource @@ -19028,6 +19650,8 @@ class SqlUserDefinedFunctionListResult(_serialization.Model): :ivar value: List of userDefinedFunctions and their properties. :vartype value: list[~azure.mgmt.cosmosdb.models.SqlUserDefinedFunctionGetResults] + :ivar next_link: + :vartype next_link: str """ _validation = { @@ -19036,12 +19660,17 @@ class SqlUserDefinedFunctionListResult(_serialization.Model): _attribute_map = { "value": {"key": "value", "type": "[SqlUserDefinedFunctionGetResults]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__(self, **kwargs: Any) -> None: - """ """ + def __init__(self, *, next_link: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword next_link: + :paramtype next_link: str + """ super().__init__(**kwargs) self.value: Optional[list["_models.SqlUserDefinedFunctionGetResults"]] = None + self.next_link = next_link class SystemData(_serialization.Model): @@ -19210,7 +19839,7 @@ class TableResource(_serialization.Model): :vartype id: str :ivar restore_parameters: Parameters to indicate the information about the restore. :vartype restore_parameters: ~azure.mgmt.cosmosdb.models.ResourceRestoreParameters - :ivar create_mode: Enum to indicate the mode of resource creation. Known values are: "Default" + :ivar create_mode: Enum to indicate the mode of account creation. Known values are: "Default" and "Restore". :vartype create_mode: str or ~azure.mgmt.cosmosdb.models.CreateMode """ @@ -19230,7 +19859,7 @@ def __init__( *, id: str, # pylint: disable=redefined-builtin restore_parameters: Optional["_models.ResourceRestoreParameters"] = None, - create_mode: Union[str, "_models.CreateMode"] = "Default", + create_mode: Optional[Union[str, "_models.CreateMode"]] = None, **kwargs: Any ) -> None: """ @@ -19238,7 +19867,7 @@ def __init__( :paramtype id: str :keyword restore_parameters: Parameters to indicate the information about the restore. :paramtype restore_parameters: ~azure.mgmt.cosmosdb.models.ResourceRestoreParameters - :keyword create_mode: Enum to indicate the mode of resource creation. Known values are: + :keyword create_mode: Enum to indicate the mode of account creation. Known values are: "Default" and "Restore". :paramtype create_mode: str or ~azure.mgmt.cosmosdb.models.CreateMode """ @@ -19248,13 +19877,20 @@ def __init__( self.create_mode = create_mode -class TableGetPropertiesResource(TableResource, ExtendedResourceProperties): +class TableGetPropertiesResource(TableResource): """TableGetPropertiesResource. 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: Name of the Cosmos DB table. Required. + :vartype id: str + :ivar restore_parameters: Parameters to indicate the information about the restore. + :vartype restore_parameters: ~azure.mgmt.cosmosdb.models.ResourceRestoreParameters + :ivar create_mode: Enum to indicate the mode of account creation. Known values are: "Default" + and "Restore". + :vartype create_mode: str or ~azure.mgmt.cosmosdb.models.CreateMode :ivar rid: A system generated property. A unique identifier. :vartype rid: str :ivar ts: A system generated property that denotes the last updated timestamp of the resource. @@ -19262,29 +19898,22 @@ class TableGetPropertiesResource(TableResource, ExtendedResourceProperties): :ivar etag: A system generated property representing the resource etag required for optimistic concurrency control. :vartype etag: str - :ivar id: Name of the Cosmos DB table. Required. - :vartype id: str - :ivar restore_parameters: Parameters to indicate the information about the restore. - :vartype restore_parameters: ~azure.mgmt.cosmosdb.models.ResourceRestoreParameters - :ivar create_mode: Enum to indicate the mode of resource creation. Known values are: "Default" - and "Restore". - :vartype create_mode: str or ~azure.mgmt.cosmosdb.models.CreateMode """ _validation = { + "id": {"required": True}, "rid": {"readonly": True}, "ts": {"readonly": True}, "etag": {"readonly": True}, - "id": {"required": True}, } _attribute_map = { - "rid": {"key": "_rid", "type": "str"}, - "ts": {"key": "_ts", "type": "float"}, - "etag": {"key": "_etag", "type": "str"}, "id": {"key": "id", "type": "str"}, "restore_parameters": {"key": "restoreParameters", "type": "ResourceRestoreParameters"}, "create_mode": {"key": "createMode", "type": "str"}, + "rid": {"key": "_rid", "type": "str"}, + "ts": {"key": "_ts", "type": "float"}, + "etag": {"key": "_etag", "type": "str"}, } def __init__( @@ -19292,7 +19921,7 @@ def __init__( *, id: str, # pylint: disable=redefined-builtin restore_parameters: Optional["_models.ResourceRestoreParameters"] = None, - create_mode: Union[str, "_models.CreateMode"] = "Default", + create_mode: Optional[Union[str, "_models.CreateMode"]] = None, **kwargs: Any ) -> None: """ @@ -19300,7 +19929,7 @@ def __init__( :paramtype id: str :keyword restore_parameters: Parameters to indicate the information about the restore. :paramtype restore_parameters: ~azure.mgmt.cosmosdb.models.ResourceRestoreParameters - :keyword create_mode: Enum to indicate the mode of resource creation. Known values are: + :keyword create_mode: Enum to indicate the mode of account creation. Known values are: "Default" and "Restore". :paramtype create_mode: str or ~azure.mgmt.cosmosdb.models.CreateMode """ @@ -19308,31 +19937,28 @@ def __init__( self.rid: Optional[str] = None self.ts: Optional[float] = None self.etag: Optional[str] = None - self.id = id - self.restore_parameters = restore_parameters - self.create_mode = create_mode -class TableGetResults(ARMResourceProperties): +class TableGetResults(Resource): """An Azure Cosmos DB Table. Variables are only populated by the server, and will be ignored when sending a request. - :ivar id: The unique resource identifier of the ARM resource. + :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 ARM resource. + :ivar name: The name of the resource. :vartype name: str - :ivar type: The type of Azure resource. + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". :vartype type: str - :ivar location: The location of the resource group to which the resource belongs. - :vartype location: str - :ivar tags: Tags are a list of key-value pairs that describe the resource. These tags can be - used in viewing and grouping this resource (across resource groups). A maximum of 15 tags can - be provided for a resource. Each tag must have a key no greater than 128 characters and value - no greater than 256 characters. For example, the default experience for a template type is set - with "defaultExperience": "Cassandra". Current "defaultExperience" values also include "Table", - "Graph", "DocumentDB", and "MongoDB". + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.cosmosdb.models.SystemData + :ivar tags: Resource tags. :vartype tags: dict[str, str] + :ivar location: The geo-location where the resource lives. + :vartype location: str :ivar identity: Identity for the resource. :vartype identity: ~azure.mgmt.cosmosdb.models.ManagedServiceIdentity :ivar resource: @@ -19345,14 +19971,16 @@ class TableGetResults(ARMResourceProperties): "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"}, - "location": {"key": "location", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, "tags": {"key": "tags", "type": "{str}"}, + "location": {"key": "location", "type": "str"}, "identity": {"key": "identity", "type": "ManagedServiceIdentity"}, "resource": {"key": "properties.resource", "type": "TableGetPropertiesResource"}, "options": {"key": "properties.options", "type": "TableGetPropertiesOptions"}, @@ -19361,23 +19989,18 @@ class TableGetResults(ARMResourceProperties): def __init__( self, *, - location: Optional[str] = None, tags: Optional[dict[str, str]] = None, + location: Optional[str] = None, identity: Optional["_models.ManagedServiceIdentity"] = None, resource: Optional["_models.TableGetPropertiesResource"] = None, options: Optional["_models.TableGetPropertiesOptions"] = None, **kwargs: Any - ) -> None: - """ - :keyword location: The location of the resource group to which the resource belongs. - :paramtype location: str - :keyword tags: Tags are a list of key-value pairs that describe the resource. These tags can be - used in viewing and grouping this resource (across resource groups). A maximum of 15 tags can - be provided for a resource. Each tag must have a key no greater than 128 characters and value - no greater than 256 characters. For example, the default experience for a template type is set - with "defaultExperience": "Cassandra". Current "defaultExperience" values also include "Table", - "Graph", "DocumentDB", and "MongoDB". + ) -> None: + """ + :keyword tags: Resource tags. :paramtype tags: dict[str, str] + :keyword location: The geo-location where the resource lives. + :paramtype location: str :keyword identity: Identity for the resource. :paramtype identity: ~azure.mgmt.cosmosdb.models.ManagedServiceIdentity :keyword resource: @@ -19385,7 +20008,10 @@ def __init__( :keyword options: :paramtype options: ~azure.mgmt.cosmosdb.models.TableGetPropertiesOptions """ - super().__init__(location=location, tags=tags, identity=identity, **kwargs) + super().__init__(**kwargs) + self.tags = tags + self.location = location + self.identity = identity self.resource = resource self.options = options @@ -19397,6 +20023,8 @@ class TableListResult(_serialization.Model): :ivar value: List of Table and their properties. :vartype value: list[~azure.mgmt.cosmosdb.models.TableGetResults] + :ivar next_link: + :vartype next_link: str """ _validation = { @@ -19405,28 +20033,32 @@ class TableListResult(_serialization.Model): _attribute_map = { "value": {"key": "value", "type": "[TableGetResults]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__(self, **kwargs: Any) -> None: - """ """ + def __init__(self, *, next_link: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword next_link: + :paramtype next_link: str + """ super().__init__(**kwargs) self.value: Optional[list["_models.TableGetResults"]] = None + self.next_link = next_link class TableRoleAssignmentListResult(_serialization.Model): - """The relevant Role Assignments. + """The response of a TableRoleAssignmentResource list operation. - 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 value: List of Role Assignments and their properties. + :ivar value: The TableRoleAssignmentResource items on this page. Required. :vartype value: list[~azure.mgmt.cosmosdb.models.TableRoleAssignmentResource] - :ivar next_link: The link used to get the next page of results. + :ivar next_link: The link to the next page of items. :vartype next_link: str """ _validation = { - "value": {"readonly": True}, - "next_link": {"readonly": True}, + "value": {"required": True}, } _attribute_map = { @@ -19434,11 +20066,18 @@ class TableRoleAssignmentListResult(_serialization.Model): "next_link": {"key": "nextLink", "type": "str"}, } - def __init__(self, **kwargs: Any) -> None: - """ """ + def __init__( + self, *, value: list["_models.TableRoleAssignmentResource"], next_link: Optional[str] = None, **kwargs: Any + ) -> None: + """ + :keyword value: The TableRoleAssignmentResource items on this page. Required. + :paramtype value: list[~azure.mgmt.cosmosdb.models.TableRoleAssignmentResource] + :keyword next_link: The link to the next page of items. + :paramtype next_link: str + """ super().__init__(**kwargs) - self.value: Optional[list["_models.TableRoleAssignmentResource"]] = None - self.next_link: Optional[str] = None + self.value = value + self.next_link = next_link class TableRoleAssignmentResource(ProxyResource): @@ -19516,19 +20155,18 @@ def __init__( class TableRoleDefinitionListResult(_serialization.Model): - """The relevant Role Definitions. + """The response of a TableRoleDefinitionResource list operation. - 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 value: List of Role Definitions and their properties. + :ivar value: The TableRoleDefinitionResource items on this page. Required. :vartype value: list[~azure.mgmt.cosmosdb.models.TableRoleDefinitionResource] - :ivar next_link: The link used to get the next page of results. + :ivar next_link: The link to the next page of items. :vartype next_link: str """ _validation = { - "value": {"readonly": True}, - "next_link": {"readonly": True}, + "value": {"required": True}, } _attribute_map = { @@ -19536,11 +20174,18 @@ class TableRoleDefinitionListResult(_serialization.Model): "next_link": {"key": "nextLink", "type": "str"}, } - def __init__(self, **kwargs: Any) -> None: - """ """ + def __init__( + self, *, value: list["_models.TableRoleDefinitionResource"], next_link: Optional[str] = None, **kwargs: Any + ) -> None: + """ + :keyword value: The TableRoleDefinitionResource items on this page. Required. + :paramtype value: list[~azure.mgmt.cosmosdb.models.TableRoleDefinitionResource] + :keyword next_link: The link to the next page of items. + :paramtype next_link: str + """ super().__init__(**kwargs) - self.value: Optional[list["_models.TableRoleDefinitionResource"]] = None - self.next_link: Optional[str] = None + self.value = value + self.next_link = next_link class TableRoleDefinitionResource(ProxyResource): @@ -19710,57 +20355,6 @@ def __init__( self.increment_percent = increment_percent -class ThroughputPoolAccountCreateParameters(_serialization.Model): - """Parameters for creating a Azure Cosmos DB throughput pool account. - - :ivar tags: Tags are a list of key-value pairs that describe the resource. These tags can be - used in viewing and grouping this resource (across resource groups). A maximum of 15 tags can - be provided for a resource. Each tag must have a key no greater than 128 characters and value - no greater than 256 characters. For example, the default experience for a template type is set - with "defaultExperience": "Cassandra". Current "defaultExperience" values also include "Table", - "Graph", "DocumentDB", and "MongoDB". - :vartype tags: dict[str, str] - :ivar account_resource_identifier: The resource identifier of global database account in the - throughputPool. - :vartype account_resource_identifier: str - :ivar account_location: The location of global database account in the throughputPool. - :vartype account_location: str - """ - - _attribute_map = { - "tags": {"key": "tags", "type": "{str}"}, - "account_resource_identifier": {"key": "properties.accountResourceIdentifier", "type": "str"}, - "account_location": {"key": "properties.accountLocation", "type": "str"}, - } - - def __init__( - self, - *, - tags: Optional[dict[str, str]] = None, - account_resource_identifier: Optional[str] = None, - account_location: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword tags: Tags are a list of key-value pairs that describe the resource. These tags can be - used in viewing and grouping this resource (across resource groups). A maximum of 15 tags can - be provided for a resource. Each tag must have a key no greater than 128 characters and value - no greater than 256 characters. For example, the default experience for a template type is set - with "defaultExperience": "Cassandra". Current "defaultExperience" values also include "Table", - "Graph", "DocumentDB", and "MongoDB". - :paramtype tags: dict[str, str] - :keyword account_resource_identifier: The resource identifier of global database account in the - throughputPool. - :paramtype account_resource_identifier: str - :keyword account_location: The location of global database account in the throughputPool. - :paramtype account_location: str - """ - super().__init__(**kwargs) - self.tags = tags - self.account_resource_identifier = account_resource_identifier - self.account_location = account_location - - class ThroughputPoolAccountResource(ProxyResource): """An Azure Cosmos DB Throughputpool Account. @@ -19778,8 +20372,8 @@ class ThroughputPoolAccountResource(ProxyResource): information. :vartype system_data: ~azure.mgmt.cosmosdb.models.SystemData :ivar provisioning_state: A provisioning state of the ThroughputPool Account. Known values are: - "Uninitialized", "Initializing", "InternallyReady", "Online", "Deleting", "Creating", - "Succeeded", "Failed", "Canceled", and "Updating". + "Uninitialized", "Initializing", "InternallyReady", "Online", "Deleting", "Succeeded", + "Failed", "Canceled", "Updating", and "Creating". :vartype provisioning_state: str or ~azure.mgmt.cosmosdb.models.Status :ivar account_resource_identifier: The resource identifier of global database account in the throughputPool. @@ -19795,6 +20389,7 @@ class ThroughputPoolAccountResource(ProxyResource): "name": {"readonly": True}, "type": {"readonly": True}, "system_data": {"readonly": True}, + "provisioning_state": {"readonly": True}, "account_instance_id": {"readonly": True}, } @@ -19812,16 +20407,11 @@ class ThroughputPoolAccountResource(ProxyResource): def __init__( self, *, - provisioning_state: Optional[Union[str, "_models.Status"]] = None, account_resource_identifier: Optional[str] = None, account_location: Optional[str] = None, **kwargs: Any ) -> None: """ - :keyword provisioning_state: A provisioning state of the ThroughputPool Account. Known values - are: "Uninitialized", "Initializing", "InternallyReady", "Online", "Deleting", "Creating", - "Succeeded", "Failed", "Canceled", and "Updating". - :paramtype provisioning_state: str or ~azure.mgmt.cosmosdb.models.Status :keyword account_resource_identifier: The resource identifier of global database account in the throughputPool. :paramtype account_resource_identifier: str @@ -19829,26 +20419,25 @@ def __init__( :paramtype account_location: str """ super().__init__(**kwargs) - self.provisioning_state = provisioning_state + self.provisioning_state: Optional[Union[str, "_models.Status"]] = None self.account_resource_identifier = account_resource_identifier self.account_location = account_location self.account_instance_id: Optional[str] = None class ThroughputPoolAccountsListResult(_serialization.Model): - """The List operation response, that contains the global database accounts and their properties. + """The response of a ThroughputPoolAccountResource list operation. - 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 value: List of global database accounts in a throughput pool and their properties. + :ivar value: The ThroughputPoolAccountResource items on this page. Required. :vartype value: list[~azure.mgmt.cosmosdb.models.ThroughputPoolAccountResource] - :ivar next_link: The link used to get the next page of results. + :ivar next_link: The link to the next page of items. :vartype next_link: str """ _validation = { - "value": {"readonly": True}, - "next_link": {"readonly": True}, + "value": {"required": True}, } _attribute_map = { @@ -19856,68 +20445,21 @@ class ThroughputPoolAccountsListResult(_serialization.Model): "next_link": {"key": "nextLink", "type": "str"}, } - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.value: Optional[list["_models.ThroughputPoolAccountResource"]] = None - self.next_link: Optional[str] = None - - -class TrackedResourceAutoGenerated(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.cosmosdb.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: + def __init__( + self, *, value: list["_models.ThroughputPoolAccountResource"], next_link: Optional[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 value: The ThroughputPoolAccountResource items on this page. Required. + :paramtype value: list[~azure.mgmt.cosmosdb.models.ThroughputPoolAccountResource] + :keyword next_link: The link to the next page of items. + :paramtype next_link: str """ super().__init__(**kwargs) - self.tags = tags - self.location = location + self.value = value + self.next_link = next_link -class ThroughputPoolResource(TrackedResourceAutoGenerated): +class ThroughputPoolResource(TrackedResource): """An Azure Cosmos DB Throughputpool. Variables are only populated by the server, and will be ignored when sending a request. @@ -19940,8 +20482,8 @@ class ThroughputPoolResource(TrackedResourceAutoGenerated): :ivar location: The geo-location where the resource lives. Required. :vartype location: str :ivar provisioning_state: A provisioning state of the ThroughputPool. Known values are: - "Uninitialized", "Initializing", "InternallyReady", "Online", "Deleting", "Creating", - "Succeeded", "Failed", "Canceled", and "Updating". + "Uninitialized", "Initializing", "InternallyReady", "Online", "Deleting", "Succeeded", + "Failed", "Canceled", "Updating", and "Creating". :vartype provisioning_state: str or ~azure.mgmt.cosmosdb.models.Status :ivar max_throughput: Value for throughput to be shared among CosmosDB resources in the pool. :vartype max_throughput: int @@ -19981,8 +20523,8 @@ def __init__( :keyword location: The geo-location where the resource lives. Required. :paramtype location: str :keyword provisioning_state: A provisioning state of the ThroughputPool. Known values are: - "Uninitialized", "Initializing", "InternallyReady", "Online", "Deleting", "Creating", - "Succeeded", "Failed", "Canceled", and "Updating". + "Uninitialized", "Initializing", "InternallyReady", "Online", "Deleting", "Succeeded", + "Failed", "Canceled", "Updating", and "Creating". :paramtype provisioning_state: str or ~azure.mgmt.cosmosdb.models.Status :keyword max_throughput: Value for throughput to be shared among CosmosDB resources in the pool. @@ -19994,19 +20536,18 @@ def __init__( class ThroughputPoolsListResult(_serialization.Model): - """The List operation response, that contains the throughput pools and their properties. + """The response of a ThroughputPoolResource list operation. - 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 value: List of throughput pools and their properties. + :ivar value: The ThroughputPoolResource items on this page. Required. :vartype value: list[~azure.mgmt.cosmosdb.models.ThroughputPoolResource] - :ivar next_link: The link used to get the next page of results. + :ivar next_link: The link to the next page of items. :vartype next_link: str """ _validation = { - "value": {"readonly": True}, - "next_link": {"readonly": True}, + "value": {"required": True}, } _attribute_map = { @@ -20014,19 +20555,26 @@ class ThroughputPoolsListResult(_serialization.Model): "next_link": {"key": "nextLink", "type": "str"}, } - def __init__(self, **kwargs: Any) -> None: - """ """ + def __init__( + self, *, value: list["_models.ThroughputPoolResource"], next_link: Optional[str] = None, **kwargs: Any + ) -> None: + """ + :keyword value: The ThroughputPoolResource items on this page. Required. + :paramtype value: list[~azure.mgmt.cosmosdb.models.ThroughputPoolResource] + :keyword next_link: The link to the next page of items. + :paramtype next_link: str + """ super().__init__(**kwargs) - self.value: Optional[list["_models.ThroughputPoolResource"]] = None - self.next_link: Optional[str] = None + self.value = value + self.next_link = next_link class ThroughputPoolUpdate(_serialization.Model): """Represents a throughput pool resource for updates. :ivar provisioning_state: A provisioning state of the ThroughputPool. Known values are: - "Uninitialized", "Initializing", "InternallyReady", "Online", "Deleting", "Creating", - "Succeeded", "Failed", "Canceled", and "Updating". + "Uninitialized", "Initializing", "InternallyReady", "Online", "Deleting", "Succeeded", + "Failed", "Canceled", "Updating", and "Creating". :vartype provisioning_state: str or ~azure.mgmt.cosmosdb.models.Status :ivar max_throughput: Value for throughput to be shared among CosmosDB resources in the pool. :vartype max_throughput: int @@ -20046,8 +20594,8 @@ def __init__( ) -> None: """ :keyword provisioning_state: A provisioning state of the ThroughputPool. Known values are: - "Uninitialized", "Initializing", "InternallyReady", "Online", "Deleting", "Creating", - "Succeeded", "Failed", "Canceled", and "Updating". + "Uninitialized", "Initializing", "InternallyReady", "Online", "Deleting", "Succeeded", + "Failed", "Canceled", "Updating", and "Creating". :paramtype provisioning_state: str or ~azure.mgmt.cosmosdb.models.Status :keyword max_throughput: Value for throughput to be shared among CosmosDB resources in the pool. @@ -20131,18 +20679,11 @@ def __init__( self.throughput_buckets = throughput_buckets -class ThroughputSettingsGetPropertiesResource(ThroughputSettingsResource, ExtendedResourceProperties): +class ThroughputSettingsGetPropertiesResource(ThroughputSettingsResource): """ThroughputSettingsGetPropertiesResource. Variables are only populated by the server, and will be ignored when sending a request. - :ivar rid: A system generated property. A unique identifier. - :vartype rid: str - :ivar ts: A system generated property that denotes the last updated timestamp of the resource. - :vartype ts: float - :ivar etag: A system generated property representing the resource etag required for optimistic - concurrency control. - :vartype etag: str :ivar throughput: Value of the Cosmos DB resource throughput. Either throughput is required or autoscaleSettings is required, but not both. :vartype throughput: int @@ -20162,22 +20703,26 @@ class ThroughputSettingsGetPropertiesResource(ThroughputSettingsResource, Extend :ivar throughput_buckets: Array of throughput bucket limits to be applied to the Cosmos DB container. :vartype throughput_buckets: list[~azure.mgmt.cosmosdb.models.ThroughputBucketResource] + :ivar rid: A system generated property. A unique identifier. + :vartype rid: str + :ivar ts: A system generated property that denotes the last updated timestamp of the resource. + :vartype ts: float + :ivar etag: A system generated property representing the resource etag required for optimistic + concurrency control. + :vartype etag: str """ _validation = { - "rid": {"readonly": True}, - "ts": {"readonly": True}, - "etag": {"readonly": True}, "minimum_throughput": {"readonly": True}, "offer_replace_pending": {"readonly": True}, "instant_maximum_throughput": {"readonly": True}, "soft_allowed_maximum_throughput": {"readonly": True}, + "rid": {"readonly": True}, + "ts": {"readonly": True}, + "etag": {"readonly": True}, } _attribute_map = { - "rid": {"key": "_rid", "type": "str"}, - "ts": {"key": "_ts", "type": "float"}, - "etag": {"key": "_etag", "type": "str"}, "throughput": {"key": "throughput", "type": "int"}, "autoscale_settings": {"key": "autoscaleSettings", "type": "AutoscaleSettingsResource"}, "minimum_throughput": {"key": "minimumThroughput", "type": "str"}, @@ -20185,6 +20730,9 @@ class ThroughputSettingsGetPropertiesResource(ThroughputSettingsResource, Extend "instant_maximum_throughput": {"key": "instantMaximumThroughput", "type": "str"}, "soft_allowed_maximum_throughput": {"key": "softAllowedMaximumThroughput", "type": "str"}, "throughput_buckets": {"key": "throughputBuckets", "type": "[ThroughputBucketResource]"}, + "rid": {"key": "_rid", "type": "str"}, + "ts": {"key": "_ts", "type": "float"}, + "etag": {"key": "_etag", "type": "str"}, } def __init__( @@ -20215,35 +20763,28 @@ def __init__( self.rid: Optional[str] = None self.ts: Optional[float] = None self.etag: Optional[str] = None - self.throughput = throughput - self.autoscale_settings = autoscale_settings - self.minimum_throughput: Optional[str] = None - self.offer_replace_pending: Optional[str] = None - self.instant_maximum_throughput: Optional[str] = None - self.soft_allowed_maximum_throughput: Optional[str] = None - self.throughput_buckets = throughput_buckets -class ThroughputSettingsGetResults(ARMResourceProperties): +class ThroughputSettingsGetResults(Resource): """An Azure Cosmos DB resource throughput. Variables are only populated by the server, and will be ignored when sending a request. - :ivar id: The unique resource identifier of the ARM resource. + :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 ARM resource. + :ivar name: The name of the resource. :vartype name: str - :ivar type: The type of Azure resource. + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". :vartype type: str - :ivar location: The location of the resource group to which the resource belongs. - :vartype location: str - :ivar tags: Tags are a list of key-value pairs that describe the resource. These tags can be - used in viewing and grouping this resource (across resource groups). A maximum of 15 tags can - be provided for a resource. Each tag must have a key no greater than 128 characters and value - no greater than 256 characters. For example, the default experience for a template type is set - with "defaultExperience": "Cassandra". Current "defaultExperience" values also include "Table", - "Graph", "DocumentDB", and "MongoDB". + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.cosmosdb.models.SystemData + :ivar tags: Resource tags. :vartype tags: dict[str, str] + :ivar location: The geo-location where the resource lives. + :vartype location: str :ivar identity: Identity for the resource. :vartype identity: ~azure.mgmt.cosmosdb.models.ManagedServiceIdentity :ivar resource: @@ -20254,14 +20795,16 @@ class ThroughputSettingsGetResults(ARMResourceProperties): "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"}, - "location": {"key": "location", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, "tags": {"key": "tags", "type": "{str}"}, + "location": {"key": "location", "type": "str"}, "identity": {"key": "identity", "type": "ManagedServiceIdentity"}, "resource": {"key": "properties.resource", "type": "ThroughputSettingsGetPropertiesResource"}, } @@ -20269,28 +20812,26 @@ class ThroughputSettingsGetResults(ARMResourceProperties): def __init__( self, *, - location: Optional[str] = None, tags: Optional[dict[str, str]] = None, + location: Optional[str] = None, identity: Optional["_models.ManagedServiceIdentity"] = None, resource: Optional["_models.ThroughputSettingsGetPropertiesResource"] = None, **kwargs: Any ) -> None: """ - :keyword location: The location of the resource group to which the resource belongs. - :paramtype location: str - :keyword tags: Tags are a list of key-value pairs that describe the resource. These tags can be - used in viewing and grouping this resource (across resource groups). A maximum of 15 tags can - be provided for a resource. Each tag must have a key no greater than 128 characters and value - no greater than 256 characters. For example, the default experience for a template type is set - with "defaultExperience": "Cassandra". Current "defaultExperience" values also include "Table", - "Graph", "DocumentDB", and "MongoDB". + :keyword tags: Resource tags. :paramtype tags: dict[str, str] + :keyword location: The geo-location where the resource lives. + :paramtype location: str :keyword identity: Identity for the resource. :paramtype identity: ~azure.mgmt.cosmosdb.models.ManagedServiceIdentity :keyword resource: :paramtype resource: ~azure.mgmt.cosmosdb.models.ThroughputSettingsGetPropertiesResource """ - super().__init__(location=location, tags=tags, identity=identity, **kwargs) + super().__init__(**kwargs) + self.tags = tags + self.location = location + self.identity = identity self.resource = resource @@ -20418,6 +20959,8 @@ class UsagesResult(_serialization.Model): :ivar value: The list of usages for the database. A usage is a point in time metric. :vartype value: list[~azure.mgmt.cosmosdb.models.Usage] + :ivar next_link: + :vartype next_link: str """ _validation = { @@ -20426,12 +20969,17 @@ class UsagesResult(_serialization.Model): _attribute_map = { "value": {"key": "value", "type": "[Usage]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__(self, **kwargs: Any) -> None: - """ """ + def __init__(self, *, next_link: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword next_link: + :paramtype next_link: str + """ super().__init__(**kwargs) self.value: Optional[list["_models.Usage"]] = None + self.next_link = next_link class VectorEmbedding(_serialization.Model): diff --git a/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/models/_patch.py b/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/models/_patch.py index f7dd3251033..87676c65a8f 100644 --- a/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/models/_patch.py +++ b/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/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/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/operations/__init__.py b/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/operations/__init__.py index 295ed2a7e9f..06a3aa3ef61 100644 --- a/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/operations/__init__.py +++ b/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/operations/__init__.py @@ -13,55 +13,58 @@ if TYPE_CHECKING: from ._patch import * # pylint: disable=unused-wildcard-import +from ._database_accounts_operations import DatabaseAccountsOperations # type: ignore +from ._operations import Operations # type: ignore +from ._cassandra_clusters_operations import CassandraClustersOperations # type: ignore +from ._fleet_operations import FleetOperations # type: ignore +from ._garnet_clusters_operations import GarnetClustersOperations # type: ignore +from ._locations_operations import LocationsOperations # type: ignore +from ._restorable_database_accounts_operations import RestorableDatabaseAccountsOperations # type: ignore +from ._restorable_gremlin_graphs_operations import RestorableGremlinGraphsOperations # type: ignore +from ._restorable_gremlin_databases_operations import RestorableGremlinDatabasesOperations # type: ignore +from ._restorable_gremlin_resources_operations import RestorableGremlinResourcesOperations # type: ignore +from ._restorable_mongodb_collections_operations import RestorableMongodbCollectionsOperations # type: ignore +from ._restorable_mongodb_databases_operations import RestorableMongodbDatabasesOperations # type: ignore +from ._restorable_mongodb_resources_operations import RestorableMongodbResourcesOperations # type: ignore +from ._restorable_sql_containers_operations import RestorableSqlContainersOperations # type: ignore +from ._restorable_sql_databases_operations import RestorableSqlDatabasesOperations # type: ignore +from ._restorable_sql_resources_operations import RestorableSqlResourcesOperations # type: ignore +from ._restorable_table_resources_operations import RestorableTableResourcesOperations # type: ignore +from ._restorable_tables_operations import RestorableTablesOperations # type: ignore +from ._soft_deleted_database_accounts_operations import SoftDeletedDatabaseAccountsOperations # type: ignore +from ._throughput_pools_operations import ThroughputPoolsOperations # type: ignore +from ._cassandra_data_centers_operations import CassandraDataCentersOperations # type: ignore from ._cassandra_resources_operations import CassandraResourcesOperations # type: ignore from ._chaos_fault_operations import ChaosFaultOperations # type: ignore from ._copy_jobs_operations import CopyJobsOperations # type: ignore -from ._database_accounts_operations import DatabaseAccountsOperations # type: ignore -from ._operations import Operations # type: ignore -from ._database_operations import DatabaseOperations # type: ignore +from ._data_transfer_jobs_operations import DataTransferJobsOperations # type: ignore from ._collection_operations import CollectionOperations # type: ignore -from ._collection_region_operations import CollectionRegionOperations # type: ignore -from ._database_account_region_operations import DatabaseAccountRegionOperations # type: ignore -from ._percentile_source_target_operations import PercentileSourceTargetOperations # type: ignore -from ._percentile_target_operations import PercentileTargetOperations # type: ignore -from ._percentile_operations import PercentileOperations # type: ignore -from ._collection_partition_region_operations import CollectionPartitionRegionOperations # type: ignore -from ._collection_partition_operations import CollectionPartitionOperations # type: ignore from ._partition_key_range_id_operations import PartitionKeyRangeIdOperations # type: ignore -from ._partition_key_range_id_region_operations import PartitionKeyRangeIdRegionOperations # type: ignore +from ._collection_partition_operations import CollectionPartitionOperations # type: ignore +from ._database_operations import DatabaseOperations # type: ignore from ._graph_resources_operations import GraphResourcesOperations # type: ignore -from ._sql_resources_operations import SqlResourcesOperations # type: ignore -from ._mongo_db_resources_operations import MongoDBResourcesOperations # type: ignore -from ._table_resources_operations import TableResourcesOperations # type: ignore from ._gremlin_resources_operations import GremlinResourcesOperations # type: ignore -from ._locations_operations import LocationsOperations # type: ignore -from ._data_transfer_jobs_operations import DataTransferJobsOperations # type: ignore -from ._fleet_operations import FleetOperations # type: ignore -from ._fleet_analytics_operations import FleetAnalyticsOperations # type: ignore -from ._fleetspace_operations import FleetspaceOperations # type: ignore -from ._fleetspace_account_operations import FleetspaceAccountOperations # type: ignore -from ._garnet_clusters_operations import GarnetClustersOperations # type: ignore -from ._cassandra_clusters_operations import CassandraClustersOperations # type: ignore -from ._cassandra_data_centers_operations import CassandraDataCentersOperations # type: ignore from ._mongo_mi_resources_operations import MongoMIResourcesOperations # type: ignore +from ._mongo_db_resources_operations import MongoDBResourcesOperations # type: ignore from ._network_security_perimeter_configurations_operations import NetworkSecurityPerimeterConfigurationsOperations # type: ignore from ._notebook_workspaces_operations import NotebookWorkspacesOperations # type: ignore +from ._percentile_operations import PercentileOperations # type: ignore from ._private_endpoint_connections_operations import PrivateEndpointConnectionsOperations # type: ignore from ._private_link_resources_operations import PrivateLinkResourcesOperations # type: ignore -from ._restorable_database_accounts_operations import RestorableDatabaseAccountsOperations # type: ignore -from ._restorable_sql_databases_operations import RestorableSqlDatabasesOperations # type: ignore -from ._restorable_sql_containers_operations import RestorableSqlContainersOperations # type: ignore -from ._restorable_sql_resources_operations import RestorableSqlResourcesOperations # type: ignore -from ._restorable_mongodb_databases_operations import RestorableMongodbDatabasesOperations # type: ignore -from ._restorable_mongodb_collections_operations import RestorableMongodbCollectionsOperations # type: ignore -from ._restorable_mongodb_resources_operations import RestorableMongodbResourcesOperations # type: ignore -from ._restorable_gremlin_databases_operations import RestorableGremlinDatabasesOperations # type: ignore -from ._restorable_gremlin_graphs_operations import RestorableGremlinGraphsOperations # type: ignore -from ._restorable_gremlin_resources_operations import RestorableGremlinResourcesOperations # type: ignore -from ._restorable_tables_operations import RestorableTablesOperations # type: ignore -from ._restorable_table_resources_operations import RestorableTableResourcesOperations # type: ignore +from ._collection_region_operations import CollectionRegionOperations # type: ignore +from ._partition_key_range_id_region_operations import PartitionKeyRangeIdRegionOperations # type: ignore +from ._collection_partition_region_operations import CollectionPartitionRegionOperations # type: ignore +from ._database_account_region_operations import DatabaseAccountRegionOperations # type: ignore from ._service_operations import ServiceOperations # type: ignore -from ._throughput_pools_operations import ThroughputPoolsOperations # type: ignore +from ._percentile_source_target_operations import PercentileSourceTargetOperations # type: ignore +from ._sql_resources_operations import SqlResourcesOperations # type: ignore +from ._table_resources_operations import TableResourcesOperations # type: ignore +from ._percentile_target_operations import PercentileTargetOperations # type: ignore +from ._fleet_analytics_operations import FleetAnalyticsOperations # type: ignore +from ._fleetspace_operations import FleetspaceOperations # type: ignore +from ._fleetspace_account_operations import FleetspaceAccountOperations # type: ignore +from ._soft_deleted_sql_databases_operations import SoftDeletedSqlDatabasesOperations # type: ignore +from ._soft_deleted_sql_containers_operations import SoftDeletedSqlContainersOperations # type: ignore from ._throughput_pool_operations import ThroughputPoolOperations # type: ignore from ._throughput_pool_accounts_operations import ThroughputPoolAccountsOperations # type: ignore from ._throughput_pool_account_operations import ThroughputPoolAccountOperations # type: ignore @@ -71,55 +74,58 @@ from ._patch import patch_sdk as _patch_sdk __all__ = [ + "DatabaseAccountsOperations", + "Operations", + "CassandraClustersOperations", + "FleetOperations", + "GarnetClustersOperations", + "LocationsOperations", + "RestorableDatabaseAccountsOperations", + "RestorableGremlinGraphsOperations", + "RestorableGremlinDatabasesOperations", + "RestorableGremlinResourcesOperations", + "RestorableMongodbCollectionsOperations", + "RestorableMongodbDatabasesOperations", + "RestorableMongodbResourcesOperations", + "RestorableSqlContainersOperations", + "RestorableSqlDatabasesOperations", + "RestorableSqlResourcesOperations", + "RestorableTableResourcesOperations", + "RestorableTablesOperations", + "SoftDeletedDatabaseAccountsOperations", + "ThroughputPoolsOperations", + "CassandraDataCentersOperations", "CassandraResourcesOperations", "ChaosFaultOperations", "CopyJobsOperations", - "DatabaseAccountsOperations", - "Operations", - "DatabaseOperations", + "DataTransferJobsOperations", "CollectionOperations", - "CollectionRegionOperations", - "DatabaseAccountRegionOperations", - "PercentileSourceTargetOperations", - "PercentileTargetOperations", - "PercentileOperations", - "CollectionPartitionRegionOperations", - "CollectionPartitionOperations", "PartitionKeyRangeIdOperations", - "PartitionKeyRangeIdRegionOperations", + "CollectionPartitionOperations", + "DatabaseOperations", "GraphResourcesOperations", - "SqlResourcesOperations", - "MongoDBResourcesOperations", - "TableResourcesOperations", "GremlinResourcesOperations", - "LocationsOperations", - "DataTransferJobsOperations", - "FleetOperations", - "FleetAnalyticsOperations", - "FleetspaceOperations", - "FleetspaceAccountOperations", - "GarnetClustersOperations", - "CassandraClustersOperations", - "CassandraDataCentersOperations", "MongoMIResourcesOperations", + "MongoDBResourcesOperations", "NetworkSecurityPerimeterConfigurationsOperations", "NotebookWorkspacesOperations", + "PercentileOperations", "PrivateEndpointConnectionsOperations", "PrivateLinkResourcesOperations", - "RestorableDatabaseAccountsOperations", - "RestorableSqlDatabasesOperations", - "RestorableSqlContainersOperations", - "RestorableSqlResourcesOperations", - "RestorableMongodbDatabasesOperations", - "RestorableMongodbCollectionsOperations", - "RestorableMongodbResourcesOperations", - "RestorableGremlinDatabasesOperations", - "RestorableGremlinGraphsOperations", - "RestorableGremlinResourcesOperations", - "RestorableTablesOperations", - "RestorableTableResourcesOperations", + "CollectionRegionOperations", + "PartitionKeyRangeIdRegionOperations", + "CollectionPartitionRegionOperations", + "DatabaseAccountRegionOperations", "ServiceOperations", - "ThroughputPoolsOperations", + "PercentileSourceTargetOperations", + "SqlResourcesOperations", + "TableResourcesOperations", + "PercentileTargetOperations", + "FleetAnalyticsOperations", + "FleetspaceOperations", + "FleetspaceAccountOperations", + "SoftDeletedSqlDatabasesOperations", + "SoftDeletedSqlContainersOperations", "ThroughputPoolOperations", "ThroughputPoolAccountsOperations", "ThroughputPoolAccountOperations", diff --git a/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/operations/_cassandra_clusters_operations.py b/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/operations/_cassandra_clusters_operations.py index 8b814c9dabf..a980d36d246 100644 --- a/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/operations/_cassandra_clusters_operations.py +++ b/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/operations/_cassandra_clusters_operations.py @@ -47,7 +47,7 @@ def build_list_by_subscription_request(subscription_id: str, **kwargs: Any) -> H _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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -73,7 +73,7 @@ def build_list_by_resource_group_request(resource_group_name: str, subscription_ _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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -103,7 +103,7 @@ def build_get_request(resource_group_name: str, cluster_name: str, subscription_ _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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -132,13 +132,14 @@ def build_get_request(resource_group_name: str, cluster_name: str, subscription_ return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_delete_request( +def build_create_update_request( resource_group_name: str, cluster_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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -162,18 +163,20 @@ def build_delete_request( _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="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_update_request( +def build_update_request( resource_group_name: str, cluster_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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -202,17 +205,16 @@ def build_create_update_request( _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) + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) -def build_update_request( +def build_delete_request( resource_group_name: str, cluster_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-11-01-preview")) - 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-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -236,27 +238,24 @@ def build_update_request( _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) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) -def build_invoke_command_request( +def build_list_backups_request( resource_group_name: str, cluster_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-11-01-preview")) - 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-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/cassandraClusters/{clusterName}/invokeCommand", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/cassandraClusters/{clusterName}/backups", ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), @@ -274,27 +273,24 @@ def build_invoke_command_request( _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) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_invoke_command_async_request( - resource_group_name: str, cluster_name: str, subscription_id: str, **kwargs: Any +def build_get_backup_request( + resource_group_name: str, cluster_name: str, backup_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-11-01-preview")) - 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-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/cassandraClusters/{clusterName}/invokeCommandAsync", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/cassandraClusters/{clusterName}/backups/{backupId}", ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), @@ -304,6 +300,7 @@ def build_invoke_command_async_request( "clusterName": _SERIALIZER.url( "cluster_name", cluster_name, "str", max_length=100, min_length=1, pattern=r"^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*$" ), + "backupId": _SERIALIZER.url("backup_id", backup_id, "str", max_length=15, min_length=1, pattern=r"^[0-9]+$"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -312,11 +309,9 @@ def build_invoke_command_async_request( _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) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_list_command_request( @@ -325,7 +320,7 @@ def build_list_command_request( _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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -360,7 +355,7 @@ def build_get_command_async_request( _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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -392,19 +387,24 @@ def build_get_command_async_request( return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_backups_request( - resource_group_name: str, cluster_name: str, subscription_id: str, **kwargs: Any +def build_deallocate_request( + resource_group_name: str, + cluster_name: str, + subscription_id: str, + *, + x_ms_force_deallocate: Optional[str] = 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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/cassandraClusters/{clusterName}/backups", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/cassandraClusters/{clusterName}/deallocate", ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), @@ -422,24 +422,27 @@ def build_list_backups_request( _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers + if x_ms_force_deallocate is not None: + _headers["x-ms-force-deallocate"] = _SERIALIZER.header("x_ms_force_deallocate", x_ms_force_deallocate, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_get_backup_request( - resource_group_name: str, cluster_name: str, backup_id: str, subscription_id: str, **kwargs: Any +def build_invoke_command_request( + resource_group_name: str, cluster_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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) + 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.DocumentDB/cassandraClusters/{clusterName}/backups/{backupId}", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/cassandraClusters/{clusterName}/invokeCommand", ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), @@ -449,7 +452,6 @@ def build_get_backup_request( "clusterName": _SERIALIZER.url( "cluster_name", cluster_name, "str", max_length=100, min_length=1, pattern=r"^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*$" ), - "backupId": _SERIALIZER.url("backup_id", backup_id, "str", max_length=15, min_length=1, pattern=r"^[0-9]+$"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -458,29 +460,27 @@ def build_get_backup_request( _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="GET", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_deallocate_request( - resource_group_name: str, - cluster_name: str, - subscription_id: str, - *, - x_ms_force_deallocate: Optional[str] = None, - **kwargs: Any +def build_invoke_command_async_request( + resource_group_name: str, cluster_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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) + 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.DocumentDB/cassandraClusters/{clusterName}/deallocate", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/cassandraClusters/{clusterName}/invokeCommandAsync", ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), @@ -498,8 +498,8 @@ def build_deallocate_request( _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - if x_ms_force_deallocate is not None: - _headers["x-ms-force-deallocate"] = _SERIALIZER.header("x_ms_force_deallocate", x_ms_force_deallocate, "str") + 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) @@ -511,7 +511,7 @@ def build_start_request( _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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -546,7 +546,7 @@ def build_status_request( _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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -649,7 +649,7 @@ def extract_data(pipeline_response): list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore - return None, iter(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): _request = prepare_request(next_link) @@ -727,7 +727,7 @@ def extract_data(pipeline_response): list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore - return None, iter(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): _request = prepare_request(next_link) @@ -801,107 +801,6 @@ def get(self, resource_group_name: str, cluster_name: str, **kwargs: Any) -> _mo return deserialized # type: ignore - def _delete_initial(self, resource_group_name: str, cluster_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, - cluster_name=cluster_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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def begin_delete(self, resource_group_name: str, cluster_name: str, **kwargs: Any) -> LROPoller[None]: - """Deletes a managed Cassandra cluster. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param cluster_name: Managed Cassandra cluster name. Required. - :type cluster_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, - cluster_name=cluster_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, **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 _create_update_initial( self, resource_group_name: str, @@ -961,10 +860,15 @@ def _create_update_initial( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) + response_headers = {} + if response.status_code == 201: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @@ -1083,7 +987,9 @@ def get_long_running_output(pipeline_response): return deserialized if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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: @@ -1158,10 +1064,15 @@ def _update_initial( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @@ -1275,7 +1186,9 @@ def get_long_running_output(pipeline_response): return deserialized if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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: @@ -1291,13 +1204,7 @@ def get_long_running_output(pipeline_response): self._client, raw_result, get_long_running_output, polling_method # type: ignore ) - def _invoke_command_initial( - self, - resource_group_name: str, - cluster_name: str, - body: Union[_models.CommandPostBody, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: + def _delete_initial(self, resource_group_name: str, cluster_name: str, **kwargs: Any) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -1306,29 +1213,17 @@ def _invoke_command_initial( } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = case_insensitive_dict(kwargs.pop("headers", {}) 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)) - 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(body, (IOBase, bytes)): - _content = body - else: - _json = self._serialize.body(body, "CommandPostBody") - - _request = build_invoke_command_request( + _request = build_delete_request( resource_group_name=resource_group_name, cluster_name=cluster_name, subscription_id=self._config.subscription_id, api_version=api_version, - content_type=content_type, - json=_json, - content=_content, headers=_headers, params=_params, ) @@ -1342,7 +1237,7 @@ def _invoke_command_initial( response = pipeline_response.http_response - if response.status_code not in [202]: + if response.status_code not in [202, 204]: try: response.read() # Load the body in memory and close the socket except (StreamConsumedError, StreamClosedError): @@ -1350,108 +1245,44 @@ def _invoke_command_initial( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore - @overload - def begin_invoke_command( - self, - resource_group_name: str, - cluster_name: str, - body: _models.CommandPostBody, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.CommandOutput]: - """Invoke a command like nodetool for cassandra maintenance. + @distributed_trace + def begin_delete(self, resource_group_name: str, cluster_name: str, **kwargs: Any) -> LROPoller[None]: + """Deletes a managed Cassandra cluster. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param cluster_name: Managed Cassandra cluster name. Required. :type cluster_name: str - :param body: Specification which command to run where. Required. - :type body: ~azure.mgmt.cosmosdb.models.CommandPostBody - :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 CommandOutput or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.CommandOutput] + :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_invoke_command( - self, - resource_group_name: str, - cluster_name: str, - body: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.CommandOutput]: - """Invoke a command like nodetool for cassandra maintenance. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param cluster_name: Managed Cassandra cluster name. Required. - :type cluster_name: str - :param body: Specification which command to run where. Required. - :type body: 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 CommandOutput or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.CommandOutput] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_invoke_command( - self, - resource_group_name: str, - cluster_name: str, - body: Union[_models.CommandPostBody, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.CommandOutput]: - """Invoke a command like nodetool for cassandra maintenance. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param cluster_name: Managed Cassandra cluster name. Required. - :type cluster_name: str - :param body: Specification which command to run where. Is either a CommandPostBody type or a - IO[bytes] type. Required. - :type body: ~azure.mgmt.cosmosdb.models.CommandPostBody or IO[bytes] - :return: An instance of LROPoller that returns either CommandOutput or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.CommandOutput] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) 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)) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.CommandOutput] = kwargs.pop("cls", 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._invoke_command_initial( + raw_result = self._delete_initial( resource_group_name=resource_group_name, cluster_name=cluster_name, - body=body, api_version=api_version, - content_type=content_type, cls=lambda x, y, z: x, headers=_headers, params=_params, @@ -1460,36 +1291,48 @@ def begin_invoke_command( raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("CommandOutput", pipeline_response.http_response) + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return cls(pipeline_response, None, {}) # type: ignore if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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.CommandOutput].from_continuation_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[_models.CommandOutput]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + def list_backups( + self, resource_group_name: str, cluster_name: str, **kwargs: Any + ) -> ItemPaged["_models.BackupResource"]: + """List the backups of this cluster that are available to restore. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_name: Managed Cassandra cluster name. Required. + :type cluster_name: str + :return: An iterator like instance of either BackupResource or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cosmosdb.models.BackupResource] + :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.ListBackups] = kwargs.pop("cls", None) - def _invoke_command_async_initial( - self, - resource_group_name: str, - cluster_name: str, - body: Union[_models.CommandAsyncPostBody, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -1498,194 +1341,120 @@ def _invoke_command_async_initial( } 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(body, (IOBase, bytes)): - _content = body - else: - _json = self._serialize.body(body, "CommandAsyncPostBody") + def prepare_request(next_link=None): + if not next_link: - _request = build_invoke_command_async_request( - resource_group_name=resource_group_name, - cluster_name=cluster_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) + _request = build_list_backups_request( + resource_group_name=resource_group_name, + cluster_name=cluster_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 - ) + 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 - response = pipeline_response.http_response + def extract_data(pipeline_response): + deserialized = self._deserialize("ListBackups", 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) - 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) + def get_next(next_link=None): + _request = prepare_request(next_link) - response_headers = {} - if response.status_code == 202: - response_headers["azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("azure-AsyncOperation") + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs ) - response_headers["location"] = self._deserialize("str", response.headers.get("location")) - - 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_invoke_command_async( - self, - resource_group_name: str, - cluster_name: str, - body: _models.CommandAsyncPostBody, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.CommandPublicResource]: - """Invoke a command like nodetool for cassandra maintenance asynchronously. + response = pipeline_response.http_response - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param cluster_name: Managed Cassandra cluster name. Required. - :type cluster_name: str - :param body: Specification which command to run where. Required. - :type body: ~azure.mgmt.cosmosdb.models.CommandAsyncPostBody - :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 CommandPublicResource or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.CommandPublicResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - @overload - def begin_invoke_command_async( - self, - resource_group_name: str, - cluster_name: str, - body: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.CommandPublicResource]: - """Invoke a command like nodetool for cassandra maintenance asynchronously. + return pipeline_response - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param cluster_name: Managed Cassandra cluster name. Required. - :type cluster_name: str - :param body: Specification which command to run where. Required. - :type body: 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 CommandPublicResource or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.CommandPublicResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ + return ItemPaged(get_next, extract_data) @distributed_trace - def begin_invoke_command_async( - self, - resource_group_name: str, - cluster_name: str, - body: Union[_models.CommandAsyncPostBody, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.CommandPublicResource]: - """Invoke a command like nodetool for cassandra maintenance asynchronously. + def get_backup( + self, resource_group_name: str, cluster_name: str, backup_id: str, **kwargs: Any + ) -> _models.BackupResource: + """Get the properties of an individual backup of this cluster that is available to restore. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param cluster_name: Managed Cassandra cluster name. Required. :type cluster_name: str - :param body: Specification which command to run where. Is either a CommandAsyncPostBody type or - a IO[bytes] type. Required. - :type body: ~azure.mgmt.cosmosdb.models.CommandAsyncPostBody or IO[bytes] - :return: An instance of LROPoller that returns either CommandPublicResource or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.CommandPublicResource] + :param backup_id: Id of a restorable backup of a Cassandra cluster. Required. + :type backup_id: str + :return: BackupResource or the result of cls(response) + :rtype: ~azure.mgmt.cosmosdb.models.BackupResource :raises ~azure.core.exceptions.HttpResponseError: """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + 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)) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.CommandPublicResource] = 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._invoke_command_async_initial( - resource_group_name=resource_group_name, - cluster_name=cluster_name, - body=body, - 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) + cls: ClsType[_models.BackupResource] = kwargs.pop("cls", None) - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("CommandPublicResource", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + _request = build_get_backup_request( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + backup_id=backup_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) - if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[_models.CommandPublicResource].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.CommandPublicResource]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore + _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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("BackupResource", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + @distributed_trace def list_command( self, resource_group_name: str, cluster_name: str, **kwargs: Any @@ -1751,7 +1520,7 @@ def extract_data(pipeline_response): list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore - return None, iter(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): _request = prepare_request(next_link) @@ -1830,27 +1599,132 @@ def get_command_async( return deserialized # type: ignore + def _deallocate_initial( + self, resource_group_name: str, cluster_name: str, x_ms_force_deallocate: Optional[str] = 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 = 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_deallocate_request( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + subscription_id=self._config.subscription_id, + x_ms_force_deallocate=x_ms_force_deallocate, + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + 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 list_backups( - self, resource_group_name: str, cluster_name: str, **kwargs: Any - ) -> ItemPaged["_models.BackupResource"]: - """List the backups of this cluster that are available to restore. + def begin_deallocate( + self, resource_group_name: str, cluster_name: str, x_ms_force_deallocate: Optional[str] = None, **kwargs: Any + ) -> LROPoller[None]: + """Deallocate the Managed Cassandra Cluster and Associated Data Centers. Deallocation will + deallocate the host virtual machine of this cluster, and reserved the data disk. This won't do + anything on an already deallocated cluster. Use Start to restart the cluster. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param cluster_name: Managed Cassandra cluster name. Required. :type cluster_name: str - :return: An iterator like instance of either BackupResource or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cosmosdb.models.BackupResource] + :param x_ms_force_deallocate: Force to deallocate a cluster of Cluster Type Production. Force + to deallocate a cluster of Cluster Type Production might cause data loss. Default value is + None. + :type x_ms_force_deallocate: 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[_models.ListBackups] = kwargs.pop("cls", 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._deallocate_initial( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + x_ms_force_deallocate=x_ms_force_deallocate, + 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 _invoke_command_initial( + self, + resource_group_name: str, + cluster_name: str, + body: Union[_models.CommandPostBody, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -1859,122 +1733,196 @@ def list_backups( } error_map.update(kwargs.pop("error_map", {}) or {}) - def prepare_request(next_link=None): - if not next_link: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _request = build_list_backups_request( - resource_group_name=resource_group_name, - cluster_name=cluster_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) + 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) - 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 + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + _json = self._serialize.body(body, "CommandPostBody") - def extract_data(pipeline_response): - deserialized = self._deserialize("ListBackups", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return None, iter(list_of_elem) + _request = build_invoke_command_request( + resource_group_name=resource_group_name, + cluster_name=cluster_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) - def get_next(next_link=None): - _request = prepare_request(next_link) + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response + 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - return pipeline_response + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - return ItemPaged(get_next, extract_data) + 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_invoke_command( + self, + resource_group_name: str, + cluster_name: str, + body: _models.CommandPostBody, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.CommandOutput]: + """Invoke a command like nodetool for cassandra maintenance. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_name: Managed Cassandra cluster name. Required. + :type cluster_name: str + :param body: Specification which command to run where. Required. + :type body: ~azure.mgmt.cosmosdb.models.CommandPostBody + :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 CommandOutput or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.CommandOutput] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_invoke_command( + self, + resource_group_name: str, + cluster_name: str, + body: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.CommandOutput]: + """Invoke a command like nodetool for cassandra maintenance. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_name: Managed Cassandra cluster name. Required. + :type cluster_name: str + :param body: Specification which command to run where. Required. + :type body: 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 CommandOutput or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.CommandOutput] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace - def get_backup( - self, resource_group_name: str, cluster_name: str, backup_id: str, **kwargs: Any - ) -> _models.BackupResource: - """Get the properties of an individual backup of this cluster that is available to restore. + def begin_invoke_command( + self, + resource_group_name: str, + cluster_name: str, + body: Union[_models.CommandPostBody, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.CommandOutput]: + """Invoke a command like nodetool for cassandra maintenance. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param cluster_name: Managed Cassandra cluster name. Required. :type cluster_name: str - :param backup_id: Id of a restorable backup of a Cassandra cluster. Required. - :type backup_id: str - :return: BackupResource or the result of cls(response) - :rtype: ~azure.mgmt.cosmosdb.models.BackupResource + :param body: Specification which command to run where. Is either a CommandPostBody type or a + IO[bytes] type. Required. + :type body: ~azure.mgmt.cosmosdb.models.CommandPostBody or IO[bytes] + :return: An instance of LROPoller that returns either CommandOutput or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.CommandOutput] :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 {} + _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)) - cls: ClsType[_models.BackupResource] = kwargs.pop("cls", None) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.CommandOutput] = 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._invoke_command_initial( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + body=body, + 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) - _request = build_get_backup_request( - resource_group_name=resource_group_name, - cluster_name=cluster_name, - backup_id=backup_id, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("CommandOutput", pipeline_response.http_response) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs + 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.CommandOutput].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.CommandOutput]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore ) - 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("BackupResource", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - def _deallocate_initial( - self, resource_group_name: str, cluster_name: str, x_ms_force_deallocate: Optional[str] = None, **kwargs: Any + def _invoke_command_async_initial( + self, + resource_group_name: str, + cluster_name: str, + body: Union[_models.CommandAsyncPostBody, IO[bytes]], + **kwargs: Any ) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -1984,18 +1932,29 @@ def _deallocate_initial( } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) 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) - _request = build_deallocate_request( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + _json = self._serialize.body(body, "CommandAsyncPostBody") + + _request = build_invoke_command_async_request( resource_group_name=resource_group_name, cluster_name=cluster_name, subscription_id=self._config.subscription_id, - x_ms_force_deallocate=x_ms_force_deallocate, api_version=api_version, + content_type=content_type, + json=_json, + content=_content, headers=_headers, params=_params, ) @@ -2009,56 +1968,128 @@ def _deallocate_initial( response = pipeline_response.http_response - if response.status_code not in [202]: + 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + 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["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.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore + @overload + def begin_invoke_command_async( + self, + resource_group_name: str, + cluster_name: str, + body: _models.CommandAsyncPostBody, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.CommandPublicResource]: + """Invoke a command like nodetool for cassandra maintenance asynchronously. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_name: Managed Cassandra cluster name. Required. + :type cluster_name: str + :param body: Specification which command to run where. Required. + :type body: ~azure.mgmt.cosmosdb.models.CommandAsyncPostBody + :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 CommandPublicResource or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.CommandPublicResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_invoke_command_async( + self, + resource_group_name: str, + cluster_name: str, + body: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.CommandPublicResource]: + """Invoke a command like nodetool for cassandra maintenance asynchronously. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_name: Managed Cassandra cluster name. Required. + :type cluster_name: str + :param body: Specification which command to run where. Required. + :type body: 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 CommandPublicResource or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.CommandPublicResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + @distributed_trace - def begin_deallocate( - self, resource_group_name: str, cluster_name: str, x_ms_force_deallocate: Optional[str] = None, **kwargs: Any - ) -> LROPoller[None]: - """Deallocate the Managed Cassandra Cluster and Associated Data Centers. Deallocation will - deallocate the host virtual machine of this cluster, and reserved the data disk. This won't do - anything on an already deallocated cluster. Use Start to restart the cluster. + def begin_invoke_command_async( + self, + resource_group_name: str, + cluster_name: str, + body: Union[_models.CommandAsyncPostBody, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.CommandPublicResource]: + """Invoke a command like nodetool for cassandra maintenance asynchronously. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param cluster_name: Managed Cassandra cluster name. Required. :type cluster_name: str - :param x_ms_force_deallocate: Force to deallocate a cluster of Cluster Type Production. Force - to deallocate a cluster of Cluster Type Production might cause data loss. Default value is - None. - :type x_ms_force_deallocate: str - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] + :param body: Specification which command to run where. Is either a CommandAsyncPostBody type or + a IO[bytes] type. Required. + :type body: ~azure.mgmt.cosmosdb.models.CommandAsyncPostBody or IO[bytes] + :return: An instance of LROPoller that returns either CommandPublicResource or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.CommandPublicResource] :raises ~azure.core.exceptions.HttpResponseError: """ - _headers = kwargs.pop("headers", {}) 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)) - cls: ClsType[None] = kwargs.pop("cls", None) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.CommandPublicResource] = 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._deallocate_initial( + raw_result = self._invoke_command_async_initial( resource_group_name=resource_group_name, cluster_name=cluster_name, - x_ms_force_deallocate=x_ms_force_deallocate, + body=body, api_version=api_version, + content_type=content_type, cls=lambda x, y, z: x, headers=_headers, params=_params, @@ -2067,24 +2098,30 @@ def begin_deallocate( raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("CommandPublicResource", pipeline_response.http_response) if cls: - return cls(pipeline_response, None, {}) # type: ignore + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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( + return LROPoller[_models.CommandPublicResource].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 + return LROPoller[_models.CommandPublicResource]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) def _start_initial(self, resource_group_name: str, cluster_name: str, **kwargs: Any) -> Iterator[bytes]: error_map: MutableMapping = { @@ -2127,10 +2164,14 @@ def _start_initial(self, resource_group_name: str, cluster_name: str, **kwargs: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) + response_headers = {} + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @@ -2175,7 +2216,9 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- return cls(pipeline_response, None, {}) # type: ignore if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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: diff --git a/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/operations/_cassandra_data_centers_operations.py b/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/operations/_cassandra_data_centers_operations.py index 2a235353015..1b98b4aa67a 100644 --- a/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/operations/_cassandra_data_centers_operations.py +++ b/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/operations/_cassandra_data_centers_operations.py @@ -47,7 +47,7 @@ def build_list_request(resource_group_name: str, cluster_name: str, subscription _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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -82,7 +82,7 @@ def build_get_request( _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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -119,13 +119,14 @@ def build_get_request( return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_delete_request( +def build_create_update_request( resource_group_name: str, cluster_name: str, data_center_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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -157,18 +158,20 @@ def build_delete_request( _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="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_update_request( +def build_update_request( resource_group_name: str, cluster_name: str, data_center_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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -205,17 +208,16 @@ def build_create_update_request( _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) + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) -def build_update_request( +def build_delete_request( resource_group_name: str, cluster_name: str, data_center_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-11-01-preview")) - 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-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -247,11 +249,9 @@ def build_update_request( _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) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) class CassandraDataCentersOperations: @@ -337,7 +337,7 @@ def extract_data(pipeline_response): list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore - return None, iter(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): _request = prepare_request(next_link) @@ -416,115 +416,6 @@ def get( return deserialized # type: ignore - def _delete_initial( - self, resource_group_name: str, cluster_name: str, data_center_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, - cluster_name=cluster_name, - data_center_name=data_center_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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def begin_delete( - self, resource_group_name: str, cluster_name: str, data_center_name: str, **kwargs: Any - ) -> LROPoller[None]: - """Delete a managed Cassandra data center. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param cluster_name: Managed Cassandra cluster name. Required. - :type cluster_name: str - :param data_center_name: Data center name in a managed Cassandra cluster. Required. - :type data_center_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, - cluster_name=cluster_name, - data_center_name=data_center_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, **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 _create_update_initial( self, resource_group_name: str, @@ -586,10 +477,15 @@ def _create_update_initial( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) + response_headers = {} + if response.status_code == 201: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @@ -716,7 +612,9 @@ def get_long_running_output(pipeline_response): return deserialized if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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: @@ -793,10 +691,15 @@ def _update_initial( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @@ -920,7 +823,9 @@ def get_long_running_output(pipeline_response): return deserialized if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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: @@ -935,3 +840,119 @@ def get_long_running_output(pipeline_response): return LROPoller[_models.DataCenterResource]( self._client, raw_result, get_long_running_output, polling_method # type: ignore ) + + def _delete_initial( + self, resource_group_name: str, cluster_name: str, data_center_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, + cluster_name=cluster_name, + data_center_name=data_center_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + 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, cluster_name: str, data_center_name: str, **kwargs: Any + ) -> LROPoller[None]: + """Delete a managed Cassandra data center. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_name: Managed Cassandra cluster name. Required. + :type cluster_name: str + :param data_center_name: Data center name in a managed Cassandra cluster. Required. + :type data_center_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, + cluster_name=cluster_name, + data_center_name=data_center_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/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/operations/_cassandra_resources_operations.py b/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/operations/_cassandra_resources_operations.py index 95e149a782e..b51aca56b0d 100644 --- a/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/operations/_cassandra_resources_operations.py +++ b/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/operations/_cassandra_resources_operations.py @@ -43,19 +43,19 @@ _SERIALIZER.client_side_validation = False -def build_get_cassandra_role_definition_request( # pylint: disable=name-too-long - resource_group_name: str, account_name: str, role_definition_id: str, subscription_id: str, **kwargs: Any +def build_list_cassandra_keyspaces_request( + resource_group_name: str, account_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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraRoleDefinitions/{roleDefinitionId}", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces", ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), @@ -65,7 +65,6 @@ def build_get_cassandra_role_definition_request( # pylint: disable=name-too-lon "accountName": _SERIALIZER.url( "account_name", account_name, "str", max_length=50, min_length=3, pattern=r"^[a-z0-9]+(-[a-z0-9]+)*" ), - "roleDefinitionId": _SERIALIZER.url("role_definition_id", role_definition_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -79,20 +78,19 @@ def build_get_cassandra_role_definition_request( # pylint: disable=name-too-lon return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_update_cassandra_role_definition_request( # pylint: disable=name-too-long - resource_group_name: str, account_name: str, role_definition_id: str, subscription_id: str, **kwargs: Any +def build_get_cassandra_keyspace_request( + resource_group_name: str, account_name: str, keyspace_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-11-01-preview")) - 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-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraRoleDefinitions/{roleDefinitionId}", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}", ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), @@ -102,7 +100,7 @@ def build_create_update_cassandra_role_definition_request( # pylint: disable=na "accountName": _SERIALIZER.url( "account_name", account_name, "str", max_length=50, min_length=3, pattern=r"^[a-z0-9]+(-[a-z0-9]+)*" ), - "roleDefinitionId": _SERIALIZER.url("role_definition_id", role_definition_id, "str"), + "keyspaceName": _SERIALIZER.url("keyspace_name", keyspace_name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -111,26 +109,25 @@ def build_create_update_cassandra_role_definition_request( # pylint: disable=na _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) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_delete_cassandra_role_definition_request( # pylint: disable=name-too-long - resource_group_name: str, account_name: str, role_definition_id: str, subscription_id: str, **kwargs: Any +def build_create_update_cassandra_keyspace_request( # pylint: disable=name-too-long + resource_group_name: str, account_name: str, keyspace_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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) + 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.DocumentDB/databaseAccounts/{accountName}/cassandraRoleDefinitions/{roleDefinitionId}", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}", ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), @@ -140,7 +137,7 @@ def build_delete_cassandra_role_definition_request( # pylint: disable=name-too- "accountName": _SERIALIZER.url( "account_name", account_name, "str", max_length=50, min_length=3, pattern=r"^[a-z0-9]+(-[a-z0-9]+)*" ), - "roleDefinitionId": _SERIALIZER.url("role_definition_id", role_definition_id, "str"), + "keyspaceName": _SERIALIZER.url("keyspace_name", keyspace_name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -149,24 +146,26 @@ def build_delete_cassandra_role_definition_request( # pylint: disable=name-too- _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="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_cassandra_role_definitions_request( # pylint: disable=name-too-long - resource_group_name: str, account_name: str, subscription_id: str, **kwargs: Any +def build_delete_cassandra_keyspace_request( + resource_group_name: str, account_name: str, keyspace_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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraRoleDefinitions", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}", ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), @@ -176,6 +175,7 @@ def build_list_cassandra_role_definitions_request( # pylint: disable=name-too-l "accountName": _SERIALIZER.url( "account_name", account_name, "str", max_length=50, min_length=3, pattern=r"^[a-z0-9]+(-[a-z0-9]+)*" ), + "keyspaceName": _SERIALIZER.url("keyspace_name", keyspace_name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -186,22 +186,22 @@ def build_list_cassandra_role_definitions_request( # pylint: disable=name-too-l # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) -def build_get_cassandra_role_assignment_request( # pylint: disable=name-too-long - resource_group_name: str, account_name: str, role_assignment_id: str, subscription_id: str, **kwargs: Any +def build_list_cassandra_tables_request( + resource_group_name: str, account_name: str, keyspace_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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraRoleAssignments/{roleAssignmentId}", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}/tables", ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), @@ -211,7 +211,7 @@ def build_get_cassandra_role_assignment_request( # pylint: disable=name-too-lon "accountName": _SERIALIZER.url( "account_name", account_name, "str", max_length=50, min_length=3, pattern=r"^[a-z0-9]+(-[a-z0-9]+)*" ), - "roleAssignmentId": _SERIALIZER.url("role_assignment_id", role_assignment_id, "str"), + "keyspaceName": _SERIALIZER.url("keyspace_name", keyspace_name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -225,20 +225,24 @@ def build_get_cassandra_role_assignment_request( # pylint: disable=name-too-lon return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_update_cassandra_role_assignment_request( # pylint: disable=name-too-long - resource_group_name: str, account_name: str, role_assignment_id: str, subscription_id: str, **kwargs: Any +def build_get_cassandra_table_request( + resource_group_name: str, + account_name: str, + keyspace_name: str, + table_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-11-01-preview")) - 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-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraRoleAssignments/{roleAssignmentId}", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}/tables/{tableName}", ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), @@ -248,7 +252,8 @@ def build_create_update_cassandra_role_assignment_request( # pylint: disable=na "accountName": _SERIALIZER.url( "account_name", account_name, "str", max_length=50, min_length=3, pattern=r"^[a-z0-9]+(-[a-z0-9]+)*" ), - "roleAssignmentId": _SERIALIZER.url("role_assignment_id", role_assignment_id, "str"), + "keyspaceName": _SERIALIZER.url("keyspace_name", keyspace_name, "str"), + "tableName": _SERIALIZER.url("table_name", table_name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -257,26 +262,30 @@ def build_create_update_cassandra_role_assignment_request( # pylint: disable=na _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) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_delete_cassandra_role_assignment_request( # pylint: disable=name-too-long - resource_group_name: str, account_name: str, role_assignment_id: str, subscription_id: str, **kwargs: Any +def build_create_update_cassandra_table_request( # pylint: disable=name-too-long + resource_group_name: str, + account_name: str, + keyspace_name: str, + table_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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) + 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.DocumentDB/databaseAccounts/{accountName}/cassandraRoleAssignments/{roleAssignmentId}", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}/tables/{tableName}", ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), @@ -286,7 +295,8 @@ def build_delete_cassandra_role_assignment_request( # pylint: disable=name-too- "accountName": _SERIALIZER.url( "account_name", account_name, "str", max_length=50, min_length=3, pattern=r"^[a-z0-9]+(-[a-z0-9]+)*" ), - "roleAssignmentId": _SERIALIZER.url("role_assignment_id", role_assignment_id, "str"), + "keyspaceName": _SERIALIZER.url("keyspace_name", keyspace_name, "str"), + "tableName": _SERIALIZER.url("table_name", table_name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -295,24 +305,31 @@ def build_delete_cassandra_role_assignment_request( # pylint: disable=name-too- _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="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_cassandra_role_assignments_request( # pylint: disable=name-too-long - resource_group_name: str, account_name: str, subscription_id: str, **kwargs: Any +def build_delete_cassandra_table_request( + resource_group_name: str, + account_name: str, + keyspace_name: str, + table_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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraRoleAssignments", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}/tables/{tableName}", ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), @@ -322,6 +339,8 @@ def build_list_cassandra_role_assignments_request( # pylint: disable=name-too-l "accountName": _SERIALIZER.url( "account_name", account_name, "str", max_length=50, min_length=3, pattern=r"^[a-z0-9]+(-[a-z0-9]+)*" ), + "keyspaceName": _SERIALIZER.url("keyspace_name", keyspace_name, "str"), + "tableName": _SERIALIZER.url("table_name", table_name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -332,22 +351,27 @@ def build_list_cassandra_role_assignments_request( # pylint: disable=name-too-l # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_cassandra_keyspaces_request( - resource_group_name: str, account_name: str, subscription_id: str, **kwargs: Any +def build_get_cassandra_table_throughput_request( # pylint: disable=name-too-long + resource_group_name: str, + account_name: str, + keyspace_name: str, + table_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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}/tables/{tableName}/throughputSettings/default", ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), @@ -357,6 +381,8 @@ def build_list_cassandra_keyspaces_request( "accountName": _SERIALIZER.url( "account_name", account_name, "str", max_length=50, min_length=3, pattern=r"^[a-z0-9]+(-[a-z0-9]+)*" ), + "keyspaceName": _SERIALIZER.url("keyspace_name", keyspace_name, "str"), + "tableName": _SERIALIZER.url("table_name", table_name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -370,19 +396,25 @@ def build_list_cassandra_keyspaces_request( return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_get_cassandra_keyspace_request( - resource_group_name: str, account_name: str, keyspace_name: str, subscription_id: str, **kwargs: Any +def build_update_cassandra_table_throughput_request( # pylint: disable=name-too-long + resource_group_name: str, + account_name: str, + keyspace_name: str, + table_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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) + 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.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}/tables/{tableName}/throughputSettings/default", ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), @@ -393,6 +425,7 @@ def build_get_cassandra_keyspace_request( "account_name", account_name, "str", max_length=50, min_length=3, pattern=r"^[a-z0-9]+(-[a-z0-9]+)*" ), "keyspaceName": _SERIALIZER.url("keyspace_name", keyspace_name, "str"), + "tableName": _SERIALIZER.url("table_name", table_name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -401,25 +434,31 @@ def build_get_cassandra_keyspace_request( _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="GET", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_update_cassandra_keyspace_request( # pylint: disable=name-too-long - resource_group_name: str, account_name: str, keyspace_name: str, subscription_id: str, **kwargs: Any +def build_migrate_cassandra_table_to_autoscale_request( # pylint: disable=name-too-long + resource_group_name: str, + account_name: str, + keyspace_name: str, + table_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-11-01-preview")) - 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-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}/tables/{tableName}/throughputSettings/default/migrateToAutoscale", ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), @@ -430,6 +469,7 @@ def build_create_update_cassandra_keyspace_request( # pylint: disable=name-too- "account_name", account_name, "str", max_length=50, min_length=3, pattern=r"^[a-z0-9]+(-[a-z0-9]+)*" ), "keyspaceName": _SERIALIZER.url("keyspace_name", keyspace_name, "str"), + "tableName": _SERIALIZER.url("table_name", table_name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -438,23 +478,29 @@ def build_create_update_cassandra_keyspace_request( # pylint: disable=name-too- _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) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_delete_cassandra_keyspace_request( - resource_group_name: str, account_name: str, keyspace_name: str, subscription_id: str, **kwargs: Any +def build_migrate_cassandra_table_to_manual_throughput_request( # pylint: disable=name-too-long + resource_group_name: str, + account_name: str, + keyspace_name: str, + table_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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}/tables/{tableName}/throughputSettings/default/migrateToManualThroughput", ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), @@ -465,6 +511,7 @@ def build_delete_cassandra_keyspace_request( "account_name", account_name, "str", max_length=50, min_length=3, pattern=r"^[a-z0-9]+(-[a-z0-9]+)*" ), "keyspaceName": _SERIALIZER.url("keyspace_name", keyspace_name, "str"), + "tableName": _SERIALIZER.url("table_name", table_name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -472,7 +519,10 @@ def build_delete_cassandra_keyspace_request( # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_get_cassandra_keyspace_throughput_request( # pylint: disable=name-too-long @@ -481,7 +531,7 @@ def build_get_cassandra_keyspace_throughput_request( # pylint: disable=name-too _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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -517,7 +567,7 @@ def build_update_cassandra_keyspace_throughput_request( # pylint: disable=name- _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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -556,7 +606,7 @@ def build_migrate_cassandra_keyspace_to_autoscale_request( # pylint: disable=na _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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -592,7 +642,7 @@ def build_migrate_cassandra_keyspace_to_manual_throughput_request( # pylint: di _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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -622,19 +672,19 @@ def build_migrate_cassandra_keyspace_to_manual_throughput_request( # pylint: di return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_cassandra_tables_request( +def build_list_cassandra_views_request( resource_group_name: str, account_name: str, keyspace_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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}/tables", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}/views", ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), @@ -658,24 +708,19 @@ def build_list_cassandra_tables_request( return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_get_cassandra_table_request( - resource_group_name: str, - account_name: str, - keyspace_name: str, - table_name: str, - subscription_id: str, - **kwargs: Any +def build_get_cassandra_view_request( + resource_group_name: str, account_name: str, keyspace_name: str, view_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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}/tables/{tableName}", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}/views/{viewName}", ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), @@ -686,7 +731,7 @@ def build_get_cassandra_table_request( "account_name", account_name, "str", max_length=50, min_length=3, pattern=r"^[a-z0-9]+(-[a-z0-9]+)*" ), "keyspaceName": _SERIALIZER.url("keyspace_name", keyspace_name, "str"), - "tableName": _SERIALIZER.url("table_name", table_name, "str"), + "viewName": _SERIALIZER.url("view_name", view_name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -700,25 +745,20 @@ def build_get_cassandra_table_request( return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_update_cassandra_table_request( # pylint: disable=name-too-long - resource_group_name: str, - account_name: str, - keyspace_name: str, - table_name: str, - subscription_id: str, - **kwargs: Any +def build_create_update_cassandra_view_request( # pylint: disable=name-too-long + resource_group_name: str, account_name: str, keyspace_name: str, view_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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) 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.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}/tables/{tableName}", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}/views/{viewName}", ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), @@ -729,7 +769,7 @@ def build_create_update_cassandra_table_request( # pylint: disable=name-too-lon "account_name", account_name, "str", max_length=50, min_length=3, pattern=r"^[a-z0-9]+(-[a-z0-9]+)*" ), "keyspaceName": _SERIALIZER.url("keyspace_name", keyspace_name, "str"), - "tableName": _SERIALIZER.url("table_name", table_name, "str"), + "viewName": _SERIALIZER.url("view_name", view_name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -745,21 +785,19 @@ def build_create_update_cassandra_table_request( # pylint: disable=name-too-lon return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_delete_cassandra_table_request( - resource_group_name: str, - account_name: str, - keyspace_name: str, - table_name: str, - subscription_id: str, - **kwargs: Any +def build_delete_cassandra_view_request( + resource_group_name: str, account_name: str, keyspace_name: str, view_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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}/tables/{tableName}", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}/views/{viewName}", ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), @@ -770,7 +808,7 @@ def build_delete_cassandra_table_request( "account_name", account_name, "str", max_length=50, min_length=3, pattern=r"^[a-z0-9]+(-[a-z0-9]+)*" ), "keyspaceName": _SERIALIZER.url("keyspace_name", keyspace_name, "str"), - "tableName": _SERIALIZER.url("table_name", table_name, "str"), + "viewName": _SERIALIZER.url("view_name", view_name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -778,27 +816,25 @@ def build_delete_cassandra_table_request( # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) -def build_get_cassandra_table_throughput_request( # pylint: disable=name-too-long - resource_group_name: str, - account_name: str, - keyspace_name: str, - table_name: str, - subscription_id: str, - **kwargs: Any + +def build_get_cassandra_view_throughput_request( # pylint: disable=name-too-long + resource_group_name: str, account_name: str, keyspace_name: str, view_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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}/tables/{tableName}/throughputSettings/default", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}/views/{viewName}/throughputSettings/default", ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), @@ -809,7 +845,7 @@ def build_get_cassandra_table_throughput_request( # pylint: disable=name-too-lo "account_name", account_name, "str", max_length=50, min_length=3, pattern=r"^[a-z0-9]+(-[a-z0-9]+)*" ), "keyspaceName": _SERIALIZER.url("keyspace_name", keyspace_name, "str"), - "tableName": _SERIALIZER.url("table_name", table_name, "str"), + "viewName": _SERIALIZER.url("view_name", view_name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -823,25 +859,20 @@ def build_get_cassandra_table_throughput_request( # pylint: disable=name-too-lo return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_update_cassandra_table_throughput_request( # pylint: disable=name-too-long - resource_group_name: str, - account_name: str, - keyspace_name: str, - table_name: str, - subscription_id: str, - **kwargs: Any +def build_update_cassandra_view_throughput_request( # pylint: disable=name-too-long + resource_group_name: str, account_name: str, keyspace_name: str, view_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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) 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.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}/tables/{tableName}/throughputSettings/default", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}/views/{viewName}/throughputSettings/default", ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), @@ -852,7 +883,7 @@ def build_update_cassandra_table_throughput_request( # pylint: disable=name-too "account_name", account_name, "str", max_length=50, min_length=3, pattern=r"^[a-z0-9]+(-[a-z0-9]+)*" ), "keyspaceName": _SERIALIZER.url("keyspace_name", keyspace_name, "str"), - "tableName": _SERIALIZER.url("table_name", table_name, "str"), + "viewName": _SERIALIZER.url("view_name", view_name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -868,24 +899,19 @@ def build_update_cassandra_table_throughput_request( # pylint: disable=name-too return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_migrate_cassandra_table_to_autoscale_request( # pylint: disable=name-too-long - resource_group_name: str, - account_name: str, - keyspace_name: str, - table_name: str, - subscription_id: str, - **kwargs: Any +def build_migrate_cassandra_view_to_autoscale_request( # pylint: disable=name-too-long + resource_group_name: str, account_name: str, keyspace_name: str, view_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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}/tables/{tableName}/throughputSettings/default/migrateToAutoscale", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}/views/{viewName}/throughputSettings/default/migrateToAutoscale", ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), @@ -896,7 +922,7 @@ def build_migrate_cassandra_table_to_autoscale_request( # pylint: disable=name- "account_name", account_name, "str", max_length=50, min_length=3, pattern=r"^[a-z0-9]+(-[a-z0-9]+)*" ), "keyspaceName": _SERIALIZER.url("keyspace_name", keyspace_name, "str"), - "tableName": _SERIALIZER.url("table_name", table_name, "str"), + "viewName": _SERIALIZER.url("view_name", view_name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -910,24 +936,19 @@ def build_migrate_cassandra_table_to_autoscale_request( # pylint: disable=name- return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_migrate_cassandra_table_to_manual_throughput_request( # pylint: disable=name-too-long - resource_group_name: str, - account_name: str, - keyspace_name: str, - table_name: str, - subscription_id: str, - **kwargs: Any +def build_migrate_cassandra_view_to_manual_throughput_request( # pylint: disable=name-too-long + resource_group_name: str, account_name: str, keyspace_name: str, view_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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}/tables/{tableName}/throughputSettings/default/migrateToManualThroughput", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}/views/{viewName}/throughputSettings/default/migrateToManualThroughput", ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), @@ -938,7 +959,7 @@ def build_migrate_cassandra_table_to_manual_throughput_request( # pylint: disab "account_name", account_name, "str", max_length=50, min_length=3, pattern=r"^[a-z0-9]+(-[a-z0-9]+)*" ), "keyspaceName": _SERIALIZER.url("keyspace_name", keyspace_name, "str"), - "tableName": _SERIALIZER.url("table_name", table_name, "str"), + "viewName": _SERIALIZER.url("view_name", view_name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -952,19 +973,19 @@ def build_migrate_cassandra_table_to_manual_throughput_request( # pylint: disab return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_cassandra_views_request( - resource_group_name: str, account_name: str, keyspace_name: str, subscription_id: str, **kwargs: Any +def build_list_cassandra_role_assignments_request( # pylint: disable=name-too-long + resource_group_name: str, account_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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}/views", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraRoleAssignments", ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), @@ -974,7 +995,6 @@ def build_list_cassandra_views_request( "accountName": _SERIALIZER.url( "account_name", account_name, "str", max_length=50, min_length=3, pattern=r"^[a-z0-9]+(-[a-z0-9]+)*" ), - "keyspaceName": _SERIALIZER.url("keyspace_name", keyspace_name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -988,19 +1008,19 @@ def build_list_cassandra_views_request( return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_get_cassandra_view_request( - resource_group_name: str, account_name: str, keyspace_name: str, view_name: str, subscription_id: str, **kwargs: Any +def build_get_cassandra_role_assignment_request( # pylint: disable=name-too-long + resource_group_name: str, account_name: str, role_assignment_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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}/views/{viewName}", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraRoleAssignments/{roleAssignmentId}", ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), @@ -1010,8 +1030,7 @@ def build_get_cassandra_view_request( "accountName": _SERIALIZER.url( "account_name", account_name, "str", max_length=50, min_length=3, pattern=r"^[a-z0-9]+(-[a-z0-9]+)*" ), - "keyspaceName": _SERIALIZER.url("keyspace_name", keyspace_name, "str"), - "viewName": _SERIALIZER.url("view_name", view_name, "str"), + "roleAssignmentId": _SERIALIZER.url("role_assignment_id", role_assignment_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -1025,20 +1044,20 @@ def build_get_cassandra_view_request( return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_update_cassandra_view_request( # pylint: disable=name-too-long - resource_group_name: str, account_name: str, keyspace_name: str, view_name: str, subscription_id: str, **kwargs: Any +def build_create_update_cassandra_role_assignment_request( # pylint: disable=name-too-long + resource_group_name: str, account_name: str, role_assignment_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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) 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.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}/views/{viewName}", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraRoleAssignments/{roleAssignmentId}", ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), @@ -1048,8 +1067,7 @@ def build_create_update_cassandra_view_request( # pylint: disable=name-too-long "accountName": _SERIALIZER.url( "account_name", account_name, "str", max_length=50, min_length=3, pattern=r"^[a-z0-9]+(-[a-z0-9]+)*" ), - "keyspaceName": _SERIALIZER.url("keyspace_name", keyspace_name, "str"), - "viewName": _SERIALIZER.url("view_name", view_name, "str"), + "roleAssignmentId": _SERIALIZER.url("role_assignment_id", role_assignment_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -1065,16 +1083,19 @@ def build_create_update_cassandra_view_request( # pylint: disable=name-too-long return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_delete_cassandra_view_request( - resource_group_name: str, account_name: str, keyspace_name: str, view_name: str, subscription_id: str, **kwargs: Any +def build_delete_cassandra_role_assignment_request( # pylint: disable=name-too-long + resource_group_name: str, account_name: str, role_assignment_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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}/views/{viewName}", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraRoleAssignments/{roleAssignmentId}", ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), @@ -1084,8 +1105,7 @@ def build_delete_cassandra_view_request( "accountName": _SERIALIZER.url( "account_name", account_name, "str", max_length=50, min_length=3, pattern=r"^[a-z0-9]+(-[a-z0-9]+)*" ), - "keyspaceName": _SERIALIZER.url("keyspace_name", keyspace_name, "str"), - "viewName": _SERIALIZER.url("view_name", view_name, "str"), + "roleAssignmentId": _SERIALIZER.url("role_assignment_id", role_assignment_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -1093,22 +1113,25 @@ def build_delete_cassandra_view_request( # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) -def build_get_cassandra_view_throughput_request( # pylint: disable=name-too-long - resource_group_name: str, account_name: str, keyspace_name: str, view_name: str, subscription_id: str, **kwargs: Any + +def build_list_cassandra_role_definitions_request( # pylint: disable=name-too-long + resource_group_name: str, account_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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}/views/{viewName}/throughputSettings/default", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraRoleDefinitions", ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), @@ -1118,8 +1141,6 @@ def build_get_cassandra_view_throughput_request( # pylint: disable=name-too-lon "accountName": _SERIALIZER.url( "account_name", account_name, "str", max_length=50, min_length=3, pattern=r"^[a-z0-9]+(-[a-z0-9]+)*" ), - "keyspaceName": _SERIALIZER.url("keyspace_name", keyspace_name, "str"), - "viewName": _SERIALIZER.url("view_name", view_name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -1133,20 +1154,19 @@ def build_get_cassandra_view_throughput_request( # pylint: disable=name-too-lon return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_update_cassandra_view_throughput_request( # pylint: disable=name-too-long - resource_group_name: str, account_name: str, keyspace_name: str, view_name: str, subscription_id: str, **kwargs: Any +def build_get_cassandra_role_definition_request( # pylint: disable=name-too-long + resource_group_name: str, account_name: str, role_definition_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-11-01-preview")) - 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-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}/views/{viewName}/throughputSettings/default", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraRoleDefinitions/{roleDefinitionId}", ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), @@ -1156,8 +1176,7 @@ def build_update_cassandra_view_throughput_request( # pylint: disable=name-too- "accountName": _SERIALIZER.url( "account_name", account_name, "str", max_length=50, min_length=3, pattern=r"^[a-z0-9]+(-[a-z0-9]+)*" ), - "keyspaceName": _SERIALIZER.url("keyspace_name", keyspace_name, "str"), - "viewName": _SERIALIZER.url("view_name", view_name, "str"), + "roleDefinitionId": _SERIALIZER.url("role_definition_id", role_definition_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -1166,26 +1185,25 @@ def build_update_cassandra_view_throughput_request( # pylint: disable=name-too- _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) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_migrate_cassandra_view_to_autoscale_request( # pylint: disable=name-too-long - resource_group_name: str, account_name: str, keyspace_name: str, view_name: str, subscription_id: str, **kwargs: Any +def build_create_update_cassandra_role_definition_request( # pylint: disable=name-too-long + resource_group_name: str, account_name: str, role_definition_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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) + 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.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}/views/{viewName}/throughputSettings/default/migrateToAutoscale", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraRoleDefinitions/{roleDefinitionId}", ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), @@ -1195,8 +1213,7 @@ def build_migrate_cassandra_view_to_autoscale_request( # pylint: disable=name-t "accountName": _SERIALIZER.url( "account_name", account_name, "str", max_length=50, min_length=3, pattern=r"^[a-z0-9]+(-[a-z0-9]+)*" ), - "keyspaceName": _SERIALIZER.url("keyspace_name", keyspace_name, "str"), - "viewName": _SERIALIZER.url("view_name", view_name, "str"), + "roleDefinitionId": _SERIALIZER.url("role_definition_id", role_definition_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -1205,24 +1222,26 @@ def build_migrate_cassandra_view_to_autoscale_request( # pylint: disable=name-t _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) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_migrate_cassandra_view_to_manual_throughput_request( # pylint: disable=name-too-long - resource_group_name: str, account_name: str, keyspace_name: str, view_name: str, subscription_id: str, **kwargs: Any +def build_delete_cassandra_role_definition_request( # pylint: disable=name-too-long + resource_group_name: str, account_name: str, role_definition_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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}/views/{viewName}/throughputSettings/default/migrateToManualThroughput", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraRoleDefinitions/{roleDefinitionId}", ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), @@ -1232,8 +1251,7 @@ def build_migrate_cassandra_view_to_manual_throughput_request( # pylint: disabl "accountName": _SERIALIZER.url( "account_name", account_name, "str", max_length=50, min_length=3, pattern=r"^[a-z0-9]+(-[a-z0-9]+)*" ), - "keyspaceName": _SERIALIZER.url("keyspace_name", keyspace_name, "str"), - "viewName": _SERIALIZER.url("view_name", view_name, "str"), + "roleDefinitionId": _SERIALIZER.url("role_definition_id", role_definition_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -1244,7 +1262,7 @@ def build_migrate_cassandra_view_to_manual_throughput_request( # pylint: disabl # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) class CassandraResourcesOperations: # pylint: disable=too-many-public-methods @@ -1267,21 +1285,109 @@ def __init__(self, *args, **kwargs) -> None: self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def get_cassandra_role_definition( - self, resource_group_name: str, account_name: str, role_definition_id: str, **kwargs: Any - ) -> _models.CassandraRoleDefinitionResource: - """Retrieves the properties of an existing Azure Cosmos DB Cassandra Role Definition with the - given Id. + def list_cassandra_keyspaces( + self, resource_group_name: str, account_name: str, **kwargs: Any + ) -> ItemPaged["_models.CassandraKeyspaceGetResults"]: + """Lists the Cassandra keyspaces under an existing Azure Cosmos DB database account. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param role_definition_id: The GUID for the Role Definition. Required. - :type role_definition_id: str - :return: CassandraRoleDefinitionResource or the result of cls(response) - :rtype: ~azure.mgmt.cosmosdb.models.CassandraRoleDefinitionResource + :return: An iterator like instance of either CassandraKeyspaceGetResults or the result of + cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cosmosdb.models.CassandraKeyspaceGetResults] + :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.CassandraKeyspaceListResult] = 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_cassandra_keyspaces_request( + resource_group_name=resource_group_name, + account_name=account_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("CassandraKeyspaceListResult", 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_cassandra_keyspace( + self, resource_group_name: str, account_name: str, keyspace_name: str, **kwargs: Any + ) -> _models.CassandraKeyspaceGetResults: + """Gets the Cassandra keyspaces under an existing Azure Cosmos DB database account with the + provided name. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param keyspace_name: Cosmos DB keyspace name. Required. + :type keyspace_name: str + :return: CassandraKeyspaceGetResults or the result of cls(response) + :rtype: ~azure.mgmt.cosmosdb.models.CassandraKeyspaceGetResults :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -1296,12 +1402,12 @@ def get_cassandra_role_definition( _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.CassandraRoleDefinitionResource] = kwargs.pop("cls", None) + cls: ClsType[_models.CassandraKeyspaceGetResults] = kwargs.pop("cls", None) - _request = build_get_cassandra_role_definition_request( + _request = build_get_cassandra_keyspace_request( resource_group_name=resource_group_name, account_name=account_name, - role_definition_id=role_definition_id, + keyspace_name=keyspace_name, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, @@ -1324,19 +1430,19 @@ def get_cassandra_role_definition( ) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("CassandraRoleDefinitionResource", pipeline_response.http_response) + deserialized = self._deserialize("CassandraKeyspaceGetResults", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - def _create_update_cassandra_role_definition_initial( # pylint: disable=name-too-long + def _create_update_cassandra_keyspace_initial( # pylint: disable=name-too-long self, resource_group_name: str, account_name: str, - role_definition_id: str, - create_update_cassandra_role_definition_parameters: Union[_models.CassandraRoleDefinitionResource, IO[bytes]], + keyspace_name: str, + create_update_cassandra_keyspace_parameters: Union[_models.CassandraKeyspaceCreateUpdateParameters, IO[bytes]], **kwargs: Any ) -> Iterator[bytes]: error_map: MutableMapping = { @@ -1357,17 +1463,17 @@ def _create_update_cassandra_role_definition_initial( # pylint: disable=name-to content_type = content_type or "application/json" _json = None _content = None - if isinstance(create_update_cassandra_role_definition_parameters, (IOBase, bytes)): - _content = create_update_cassandra_role_definition_parameters + if isinstance(create_update_cassandra_keyspace_parameters, (IOBase, bytes)): + _content = create_update_cassandra_keyspace_parameters else: _json = self._serialize.body( - create_update_cassandra_role_definition_parameters, "CassandraRoleDefinitionResource" + create_update_cassandra_keyspace_parameters, "CassandraKeyspaceCreateUpdateParameters" ) - _request = build_create_update_cassandra_role_definition_request( + _request = build_create_update_cassandra_keyspace_request( resource_group_name=resource_group_name, account_name=account_name, - role_definition_id=role_definition_id, + keyspace_name=keyspace_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, @@ -1400,10 +1506,11 @@ def _create_update_cassandra_role_definition_initial( # pylint: disable=name-to response_headers = {} if response.status_code == 202: - response_headers["azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("azure-AsyncOperation") + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") ) - response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) @@ -1413,99 +1520,96 @@ def _create_update_cassandra_role_definition_initial( # pylint: disable=name-to return deserialized # type: ignore @overload - def begin_create_update_cassandra_role_definition( # pylint: disable=name-too-long + def begin_create_update_cassandra_keyspace( self, resource_group_name: str, account_name: str, - role_definition_id: str, - create_update_cassandra_role_definition_parameters: _models.CassandraRoleDefinitionResource, + keyspace_name: str, + create_update_cassandra_keyspace_parameters: _models.CassandraKeyspaceCreateUpdateParameters, *, content_type: str = "application/json", **kwargs: Any - ) -> LROPoller[_models.CassandraRoleDefinitionResource]: - """Creates or updates an Azure Cosmos DB Cassandra Role Definition. + ) -> LROPoller[_models.CassandraKeyspaceGetResults]: + """Create or update an Azure Cosmos DB Cassandra keyspace. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param role_definition_id: The GUID for the Role Definition. Required. - :type role_definition_id: str - :param create_update_cassandra_role_definition_parameters: The properties required to create or - update a Role Definition. Required. - :type create_update_cassandra_role_definition_parameters: - ~azure.mgmt.cosmosdb.models.CassandraRoleDefinitionResource + :param keyspace_name: Cosmos DB keyspace name. Required. + :type keyspace_name: str + :param create_update_cassandra_keyspace_parameters: The parameters to provide for the current + Cassandra keyspace. Required. + :type create_update_cassandra_keyspace_parameters: + ~azure.mgmt.cosmosdb.models.CassandraKeyspaceCreateUpdateParameters :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 CassandraRoleDefinitionResource or the - result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.CassandraRoleDefinitionResource] + :return: An instance of LROPoller that returns either CassandraKeyspaceGetResults or the result + of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.CassandraKeyspaceGetResults] :raises ~azure.core.exceptions.HttpResponseError: """ @overload - def begin_create_update_cassandra_role_definition( # pylint: disable=name-too-long + def begin_create_update_cassandra_keyspace( self, resource_group_name: str, account_name: str, - role_definition_id: str, - create_update_cassandra_role_definition_parameters: IO[bytes], + keyspace_name: str, + create_update_cassandra_keyspace_parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> LROPoller[_models.CassandraRoleDefinitionResource]: - """Creates or updates an Azure Cosmos DB Cassandra Role Definition. + ) -> LROPoller[_models.CassandraKeyspaceGetResults]: + """Create or update an Azure Cosmos DB Cassandra keyspace. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param role_definition_id: The GUID for the Role Definition. Required. - :type role_definition_id: str - :param create_update_cassandra_role_definition_parameters: The properties required to create or - update a Role Definition. Required. - :type create_update_cassandra_role_definition_parameters: IO[bytes] + :param keyspace_name: Cosmos DB keyspace name. Required. + :type keyspace_name: str + :param create_update_cassandra_keyspace_parameters: The parameters to provide for the current + Cassandra keyspace. Required. + :type create_update_cassandra_keyspace_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 CassandraRoleDefinitionResource or the - result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.CassandraRoleDefinitionResource] + :return: An instance of LROPoller that returns either CassandraKeyspaceGetResults or the result + of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.CassandraKeyspaceGetResults] :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace - def begin_create_update_cassandra_role_definition( # pylint: disable=name-too-long + def begin_create_update_cassandra_keyspace( self, resource_group_name: str, account_name: str, - role_definition_id: str, - create_update_cassandra_role_definition_parameters: Union[_models.CassandraRoleDefinitionResource, IO[bytes]], + keyspace_name: str, + create_update_cassandra_keyspace_parameters: Union[_models.CassandraKeyspaceCreateUpdateParameters, IO[bytes]], **kwargs: Any - ) -> LROPoller[_models.CassandraRoleDefinitionResource]: - """Creates or updates an Azure Cosmos DB Cassandra Role Definition. + ) -> LROPoller[_models.CassandraKeyspaceGetResults]: + """Create or update an Azure Cosmos DB Cassandra keyspace. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param role_definition_id: The GUID for the Role Definition. Required. - :type role_definition_id: str - :param create_update_cassandra_role_definition_parameters: The properties required to create or - update a Role Definition. Is either a CassandraRoleDefinitionResource type or a IO[bytes] type. - Required. - :type create_update_cassandra_role_definition_parameters: - ~azure.mgmt.cosmosdb.models.CassandraRoleDefinitionResource or IO[bytes] - :return: An instance of LROPoller that returns either CassandraRoleDefinitionResource or the - result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.CassandraRoleDefinitionResource] + :param keyspace_name: Cosmos DB keyspace name. Required. + :type keyspace_name: str + :param create_update_cassandra_keyspace_parameters: The parameters to provide for the current + Cassandra keyspace. Is either a CassandraKeyspaceCreateUpdateParameters type or a IO[bytes] + type. Required. + :type create_update_cassandra_keyspace_parameters: + ~azure.mgmt.cosmosdb.models.CassandraKeyspaceCreateUpdateParameters or IO[bytes] + :return: An instance of LROPoller that returns either CassandraKeyspaceGetResults or the result + of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.CassandraKeyspaceGetResults] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -1513,16 +1617,16 @@ def begin_create_update_cassandra_role_definition( # pylint: disable=name-too-l 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.CassandraRoleDefinitionResource] = kwargs.pop("cls", None) + cls: ClsType[_models.CassandraKeyspaceGetResults] = 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_update_cassandra_role_definition_initial( + raw_result = self._create_update_cassandra_keyspace_initial( resource_group_name=resource_group_name, account_name=account_name, - role_definition_id=role_definition_id, - create_update_cassandra_role_definition_parameters=create_update_cassandra_role_definition_parameters, + keyspace_name=keyspace_name, + create_update_cassandra_keyspace_parameters=create_update_cassandra_keyspace_parameters, api_version=api_version, content_type=content_type, cls=lambda x, y, z: x, @@ -1534,30 +1638,32 @@ def begin_create_update_cassandra_role_definition( # pylint: disable=name-too-l kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("CassandraRoleDefinitionResource", pipeline_response.http_response) + deserialized = self._deserialize("CassandraKeyspaceGetResults", 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, **kwargs)) + 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.CassandraRoleDefinitionResource].from_continuation_token( + return LROPoller[_models.CassandraKeyspaceGetResults].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller[_models.CassandraRoleDefinitionResource]( + return LROPoller[_models.CassandraKeyspaceGetResults]( self._client, raw_result, get_long_running_output, polling_method # type: ignore ) - def _delete_cassandra_role_definition_initial( # pylint: disable=name-too-long - self, resource_group_name: str, account_name: str, role_definition_id: str, **kwargs: Any + def _delete_cassandra_keyspace_initial( + self, resource_group_name: str, account_name: str, keyspace_name: str, **kwargs: Any ) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -1573,10 +1679,10 @@ def _delete_cassandra_role_definition_initial( # pylint: disable=name-too-long 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_cassandra_role_definition_request( + _request = build_delete_cassandra_keyspace_request( resource_group_name=resource_group_name, account_name=account_name, - role_definition_id=role_definition_id, + keyspace_name=keyspace_name, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, @@ -1592,7 +1698,7 @@ def _delete_cassandra_role_definition_initial( # pylint: disable=name-too-long response = pipeline_response.http_response - if response.status_code not in [200, 202, 204]: + if response.status_code not in [202, 204]: try: response.read() # Load the body in memory and close the socket except (StreamConsumedError, StreamClosedError): @@ -1606,10 +1712,10 @@ def _delete_cassandra_role_definition_initial( # pylint: disable=name-too-long response_headers = {} if response.status_code == 202: - response_headers["azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("azure-AsyncOperation") + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") ) - response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) @@ -1619,18 +1725,18 @@ def _delete_cassandra_role_definition_initial( # pylint: disable=name-too-long return deserialized # type: ignore @distributed_trace - def begin_delete_cassandra_role_definition( - self, resource_group_name: str, account_name: str, role_definition_id: str, **kwargs: Any + def begin_delete_cassandra_keyspace( + self, resource_group_name: str, account_name: str, keyspace_name: str, **kwargs: Any ) -> LROPoller[None]: - """Deletes an existing Azure Cosmos DB Cassandra Role Definition. + """Deletes an existing Azure Cosmos DB Cassandra keyspace. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param role_definition_id: The GUID for the Role Definition. Required. - :type role_definition_id: str + :param keyspace_name: Cosmos DB keyspace name. Required. + :type keyspace_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: @@ -1644,10 +1750,10 @@ def begin_delete_cassandra_role_definition( 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_cassandra_role_definition_initial( + raw_result = self._delete_cassandra_keyspace_initial( resource_group_name=resource_group_name, account_name=account_name, - role_definition_id=role_definition_id, + keyspace_name=keyspace_name, api_version=api_version, cls=lambda x, y, z: x, headers=_headers, @@ -1662,7 +1768,9 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- return cls(pipeline_response, None, {}) # type: ignore if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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: @@ -1677,27 +1785,28 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore @distributed_trace - def list_cassandra_role_definitions( - self, resource_group_name: str, account_name: str, **kwargs: Any - ) -> ItemPaged["_models.CassandraRoleDefinitionResource"]: - """Retrieves the list of all Azure Cosmos DB Cassandra Role Definitions. + def list_cassandra_tables( + self, resource_group_name: str, account_name: str, keyspace_name: str, **kwargs: Any + ) -> ItemPaged["_models.CassandraTableGetResults"]: + """Lists the Cassandra table under an existing Azure Cosmos DB database account. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param account_name: Cosmos DB database account name. Required. :type account_name: str - :return: An iterator like instance of either CassandraRoleDefinitionResource or the result of + :param keyspace_name: Cosmos DB keyspace name. Required. + :type keyspace_name: str + :return: An iterator like instance of either CassandraTableGetResults or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.cosmosdb.models.CassandraRoleDefinitionResource] + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cosmosdb.models.CassandraTableGetResults] :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.CassandraRoleDefinitionListResult] = kwargs.pop("cls", None) + cls: ClsType[_models.CassandraTableListResult] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -1710,9 +1819,10 @@ def list_cassandra_role_definitions( def prepare_request(next_link=None): if not next_link: - _request = build_list_cassandra_role_definitions_request( + _request = build_list_cassandra_tables_request( resource_group_name=resource_group_name, account_name=account_name, + keyspace_name=keyspace_name, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, @@ -1738,11 +1848,11 @@ def prepare_request(next_link=None): return _request def extract_data(pipeline_response): - deserialized = self._deserialize("CassandraRoleDefinitionListResult", pipeline_response) + deserialized = self._deserialize("CassandraTableListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore - return None, iter(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): _request = prepare_request(next_link) @@ -1766,21 +1876,22 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) @distributed_trace - def get_cassandra_role_assignment( - self, resource_group_name: str, account_name: str, role_assignment_id: str, **kwargs: Any - ) -> _models.CassandraRoleAssignmentResource: - """Retrieves the properties of an existing Azure Cosmos DB Cassandra Role Assignment with the - given Id. + def get_cassandra_table( + self, resource_group_name: str, account_name: str, keyspace_name: str, table_name: str, **kwargs: Any + ) -> _models.CassandraTableGetResults: + """Gets the Cassandra table under an existing Azure Cosmos DB database account. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param role_assignment_id: The GUID for the Role Assignment. Required. - :type role_assignment_id: str - :return: CassandraRoleAssignmentResource or the result of cls(response) - :rtype: ~azure.mgmt.cosmosdb.models.CassandraRoleAssignmentResource + :param keyspace_name: Cosmos DB keyspace name. Required. + :type keyspace_name: str + :param table_name: Cosmos DB table name. Required. + :type table_name: str + :return: CassandraTableGetResults or the result of cls(response) + :rtype: ~azure.mgmt.cosmosdb.models.CassandraTableGetResults :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -1795,12 +1906,13 @@ def get_cassandra_role_assignment( _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.CassandraRoleAssignmentResource] = kwargs.pop("cls", None) + cls: ClsType[_models.CassandraTableGetResults] = kwargs.pop("cls", None) - _request = build_get_cassandra_role_assignment_request( + _request = build_get_cassandra_table_request( resource_group_name=resource_group_name, account_name=account_name, - role_assignment_id=role_assignment_id, + keyspace_name=keyspace_name, + table_name=table_name, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, @@ -1823,19 +1935,20 @@ def get_cassandra_role_assignment( ) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("CassandraRoleAssignmentResource", pipeline_response.http_response) + deserialized = self._deserialize("CassandraTableGetResults", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - def _create_update_cassandra_role_assignment_initial( # pylint: disable=name-too-long + def _create_update_cassandra_table_initial( self, resource_group_name: str, account_name: str, - role_assignment_id: str, - create_update_cassandra_role_assignment_parameters: Union[_models.CassandraRoleAssignmentResource, IO[bytes]], + keyspace_name: str, + table_name: str, + create_update_cassandra_table_parameters: Union[_models.CassandraTableCreateUpdateParameters, IO[bytes]], **kwargs: Any ) -> Iterator[bytes]: error_map: MutableMapping = { @@ -1856,17 +1969,18 @@ def _create_update_cassandra_role_assignment_initial( # pylint: disable=name-to content_type = content_type or "application/json" _json = None _content = None - if isinstance(create_update_cassandra_role_assignment_parameters, (IOBase, bytes)): - _content = create_update_cassandra_role_assignment_parameters + if isinstance(create_update_cassandra_table_parameters, (IOBase, bytes)): + _content = create_update_cassandra_table_parameters else: _json = self._serialize.body( - create_update_cassandra_role_assignment_parameters, "CassandraRoleAssignmentResource" + create_update_cassandra_table_parameters, "CassandraTableCreateUpdateParameters" ) - _request = build_create_update_cassandra_role_assignment_request( + _request = build_create_update_cassandra_table_request( resource_group_name=resource_group_name, account_name=account_name, - role_assignment_id=role_assignment_id, + keyspace_name=keyspace_name, + table_name=table_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, @@ -1899,10 +2013,11 @@ def _create_update_cassandra_role_assignment_initial( # pylint: disable=name-to response_headers = {} if response.status_code == 202: - response_headers["azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("azure-AsyncOperation") + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") ) - response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) @@ -1912,99 +2027,105 @@ def _create_update_cassandra_role_assignment_initial( # pylint: disable=name-to return deserialized # type: ignore @overload - def begin_create_update_cassandra_role_assignment( # pylint: disable=name-too-long + def begin_create_update_cassandra_table( self, resource_group_name: str, account_name: str, - role_assignment_id: str, - create_update_cassandra_role_assignment_parameters: _models.CassandraRoleAssignmentResource, + keyspace_name: str, + table_name: str, + create_update_cassandra_table_parameters: _models.CassandraTableCreateUpdateParameters, *, content_type: str = "application/json", **kwargs: Any - ) -> LROPoller[_models.CassandraRoleAssignmentResource]: - """Creates or updates an Azure Cosmos DB Cassandra Role Assignment. + ) -> LROPoller[_models.CassandraTableGetResults]: + """Create or update an Azure Cosmos DB Cassandra Table. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param role_assignment_id: The GUID for the Role Assignment. Required. - :type role_assignment_id: str - :param create_update_cassandra_role_assignment_parameters: The properties required to create or - update a Role Assignment. Required. - :type create_update_cassandra_role_assignment_parameters: - ~azure.mgmt.cosmosdb.models.CassandraRoleAssignmentResource + :param keyspace_name: Cosmos DB keyspace name. Required. + :type keyspace_name: str + :param table_name: Cosmos DB table name. Required. + :type table_name: str + :param create_update_cassandra_table_parameters: The parameters to provide for the current + Cassandra Table. Required. + :type create_update_cassandra_table_parameters: + ~azure.mgmt.cosmosdb.models.CassandraTableCreateUpdateParameters :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 CassandraRoleAssignmentResource or the - result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.CassandraRoleAssignmentResource] + :return: An instance of LROPoller that returns either CassandraTableGetResults or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.CassandraTableGetResults] :raises ~azure.core.exceptions.HttpResponseError: """ @overload - def begin_create_update_cassandra_role_assignment( # pylint: disable=name-too-long + def begin_create_update_cassandra_table( self, resource_group_name: str, account_name: str, - role_assignment_id: str, - create_update_cassandra_role_assignment_parameters: IO[bytes], + keyspace_name: str, + table_name: str, + create_update_cassandra_table_parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> LROPoller[_models.CassandraRoleAssignmentResource]: - """Creates or updates an Azure Cosmos DB Cassandra Role Assignment. + ) -> LROPoller[_models.CassandraTableGetResults]: + """Create or update an Azure Cosmos DB Cassandra Table. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param role_assignment_id: The GUID for the Role Assignment. Required. - :type role_assignment_id: str - :param create_update_cassandra_role_assignment_parameters: The properties required to create or - update a Role Assignment. Required. - :type create_update_cassandra_role_assignment_parameters: IO[bytes] + :param keyspace_name: Cosmos DB keyspace name. Required. + :type keyspace_name: str + :param table_name: Cosmos DB table name. Required. + :type table_name: str + :param create_update_cassandra_table_parameters: The parameters to provide for the current + Cassandra Table. Required. + :type create_update_cassandra_table_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 CassandraRoleAssignmentResource or the - result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.CassandraRoleAssignmentResource] + :return: An instance of LROPoller that returns either CassandraTableGetResults or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.CassandraTableGetResults] :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace - def begin_create_update_cassandra_role_assignment( # pylint: disable=name-too-long + def begin_create_update_cassandra_table( self, resource_group_name: str, account_name: str, - role_assignment_id: str, - create_update_cassandra_role_assignment_parameters: Union[_models.CassandraRoleAssignmentResource, IO[bytes]], + keyspace_name: str, + table_name: str, + create_update_cassandra_table_parameters: Union[_models.CassandraTableCreateUpdateParameters, IO[bytes]], **kwargs: Any - ) -> LROPoller[_models.CassandraRoleAssignmentResource]: - """Creates or updates an Azure Cosmos DB Cassandra Role Assignment. + ) -> LROPoller[_models.CassandraTableGetResults]: + """Create or update an Azure Cosmos DB Cassandra Table. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param role_assignment_id: The GUID for the Role Assignment. Required. - :type role_assignment_id: str - :param create_update_cassandra_role_assignment_parameters: The properties required to create or - update a Role Assignment. Is either a CassandraRoleAssignmentResource type or a IO[bytes] type. + :param keyspace_name: Cosmos DB keyspace name. Required. + :type keyspace_name: str + :param table_name: Cosmos DB table name. Required. + :type table_name: str + :param create_update_cassandra_table_parameters: The parameters to provide for the current + Cassandra Table. Is either a CassandraTableCreateUpdateParameters type or a IO[bytes] type. Required. - :type create_update_cassandra_role_assignment_parameters: - ~azure.mgmt.cosmosdb.models.CassandraRoleAssignmentResource or IO[bytes] - :return: An instance of LROPoller that returns either CassandraRoleAssignmentResource or the - result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.CassandraRoleAssignmentResource] + :type create_update_cassandra_table_parameters: + ~azure.mgmt.cosmosdb.models.CassandraTableCreateUpdateParameters or IO[bytes] + :return: An instance of LROPoller that returns either CassandraTableGetResults or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.CassandraTableGetResults] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -2012,16 +2133,17 @@ def begin_create_update_cassandra_role_assignment( # pylint: disable=name-too-l 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.CassandraRoleAssignmentResource] = kwargs.pop("cls", None) + cls: ClsType[_models.CassandraTableGetResults] = 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_update_cassandra_role_assignment_initial( + raw_result = self._create_update_cassandra_table_initial( resource_group_name=resource_group_name, account_name=account_name, - role_assignment_id=role_assignment_id, - create_update_cassandra_role_assignment_parameters=create_update_cassandra_role_assignment_parameters, + keyspace_name=keyspace_name, + table_name=table_name, + create_update_cassandra_table_parameters=create_update_cassandra_table_parameters, api_version=api_version, content_type=content_type, cls=lambda x, y, z: x, @@ -2033,30 +2155,32 @@ def begin_create_update_cassandra_role_assignment( # pylint: disable=name-too-l kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("CassandraRoleAssignmentResource", pipeline_response.http_response) + deserialized = self._deserialize("CassandraTableGetResults", 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, **kwargs)) + 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.CassandraRoleAssignmentResource].from_continuation_token( + return LROPoller[_models.CassandraTableGetResults].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller[_models.CassandraRoleAssignmentResource]( + return LROPoller[_models.CassandraTableGetResults]( self._client, raw_result, get_long_running_output, polling_method # type: ignore ) - def _delete_cassandra_role_assignment_initial( # pylint: disable=name-too-long - self, resource_group_name: str, account_name: str, role_assignment_id: str, **kwargs: Any + def _delete_cassandra_table_initial( + self, resource_group_name: str, account_name: str, keyspace_name: str, table_name: str, **kwargs: Any ) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -2072,10 +2196,11 @@ def _delete_cassandra_role_assignment_initial( # pylint: disable=name-too-long 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_cassandra_role_assignment_request( + _request = build_delete_cassandra_table_request( resource_group_name=resource_group_name, account_name=account_name, - role_assignment_id=role_assignment_id, + keyspace_name=keyspace_name, + table_name=table_name, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, @@ -2091,7 +2216,7 @@ def _delete_cassandra_role_assignment_initial( # pylint: disable=name-too-long response = pipeline_response.http_response - if response.status_code not in [200, 202, 204]: + if response.status_code not in [202, 204]: try: response.read() # Load the body in memory and close the socket except (StreamConsumedError, StreamClosedError): @@ -2105,10 +2230,10 @@ def _delete_cassandra_role_assignment_initial( # pylint: disable=name-too-long response_headers = {} if response.status_code == 202: - response_headers["azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("azure-AsyncOperation") + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") ) - response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) @@ -2118,18 +2243,20 @@ def _delete_cassandra_role_assignment_initial( # pylint: disable=name-too-long return deserialized # type: ignore @distributed_trace - def begin_delete_cassandra_role_assignment( - self, resource_group_name: str, account_name: str, role_assignment_id: str, **kwargs: Any + def begin_delete_cassandra_table( + self, resource_group_name: str, account_name: str, keyspace_name: str, table_name: str, **kwargs: Any ) -> LROPoller[None]: - """Deletes an existing Azure Cosmos DB Cassandra Role Assignment. + """Deletes an existing Azure Cosmos DB Cassandra table. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param role_assignment_id: The GUID for the Role Assignment. Required. - :type role_assignment_id: str + :param keyspace_name: Cosmos DB keyspace name. Required. + :type keyspace_name: str + :param table_name: Cosmos DB table name. Required. + :type table_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: @@ -2143,10 +2270,11 @@ def begin_delete_cassandra_role_assignment( 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_cassandra_role_assignment_initial( + raw_result = self._delete_cassandra_table_initial( resource_group_name=resource_group_name, account_name=account_name, - role_assignment_id=role_assignment_id, + keyspace_name=keyspace_name, + table_name=table_name, api_version=api_version, cls=lambda x, y, z: x, headers=_headers, @@ -2161,7 +2289,9 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- return cls(pipeline_response, None, {}) # type: ignore if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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: @@ -2176,184 +2306,11 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore @distributed_trace - def list_cassandra_role_assignments( - self, resource_group_name: str, account_name: str, **kwargs: Any - ) -> ItemPaged["_models.CassandraRoleAssignmentResource"]: - """Retrieves the list of all Azure Cosmos DB Cassandra Role Assignments. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param account_name: Cosmos DB database account name. Required. - :type account_name: str - :return: An iterator like instance of either CassandraRoleAssignmentResource or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.cosmosdb.models.CassandraRoleAssignmentResource] - :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.CassandraRoleAssignmentListResult] = 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_cassandra_role_assignments_request( - resource_group_name=resource_group_name, - account_name=account_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("CassandraRoleAssignmentListResult", 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) - - @distributed_trace - def list_cassandra_keyspaces( - self, resource_group_name: str, account_name: str, **kwargs: Any - ) -> ItemPaged["_models.CassandraKeyspaceGetResults"]: - """Lists the Cassandra keyspaces under an existing Azure Cosmos DB database account. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param account_name: Cosmos DB database account name. Required. - :type account_name: str - :return: An iterator like instance of either CassandraKeyspaceGetResults or the result of - cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cosmosdb.models.CassandraKeyspaceGetResults] - :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.CassandraKeyspaceListResult] = 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_cassandra_keyspaces_request( - resource_group_name=resource_group_name, - account_name=account_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("CassandraKeyspaceListResult", 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def get_cassandra_keyspace( - self, resource_group_name: str, account_name: str, keyspace_name: str, **kwargs: Any - ) -> _models.CassandraKeyspaceGetResults: - """Gets the Cassandra keyspaces under an existing Azure Cosmos DB database account with the - provided name. + def get_cassandra_table_throughput( + self, resource_group_name: str, account_name: str, keyspace_name: str, table_name: str, **kwargs: Any + ) -> _models.ThroughputSettingsGetResults: + """Gets the RUs per second of the Cassandra table under an existing Azure Cosmos DB database + account with the provided name. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -2362,8 +2319,10 @@ def get_cassandra_keyspace( :type account_name: str :param keyspace_name: Cosmos DB keyspace name. Required. :type keyspace_name: str - :return: CassandraKeyspaceGetResults or the result of cls(response) - :rtype: ~azure.mgmt.cosmosdb.models.CassandraKeyspaceGetResults + :param table_name: Cosmos DB table name. Required. + :type table_name: str + :return: ThroughputSettingsGetResults or the result of cls(response) + :rtype: ~azure.mgmt.cosmosdb.models.ThroughputSettingsGetResults :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -2378,12 +2337,13 @@ def get_cassandra_keyspace( _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.CassandraKeyspaceGetResults] = kwargs.pop("cls", None) + cls: ClsType[_models.ThroughputSettingsGetResults] = kwargs.pop("cls", None) - _request = build_get_cassandra_keyspace_request( + _request = build_get_cassandra_table_throughput_request( resource_group_name=resource_group_name, account_name=account_name, keyspace_name=keyspace_name, + table_name=table_name, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, @@ -2400,21 +2360,26 @@ def get_cassandra_keyspace( if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("CassandraKeyspaceGetResults", pipeline_response.http_response) + deserialized = self._deserialize("ThroughputSettingsGetResults", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - def _create_update_cassandra_keyspace_initial( # pylint: disable=name-too-long + def _update_cassandra_table_throughput_initial( # pylint: disable=name-too-long self, resource_group_name: str, account_name: str, keyspace_name: str, - create_update_cassandra_keyspace_parameters: Union[_models.CassandraKeyspaceCreateUpdateParameters, IO[bytes]], + table_name: str, + update_throughput_parameters: Union[_models.ThroughputSettingsUpdateParameters, IO[bytes]], **kwargs: Any ) -> Iterator[bytes]: error_map: MutableMapping = { @@ -2435,17 +2400,16 @@ def _create_update_cassandra_keyspace_initial( # pylint: disable=name-too-long content_type = content_type or "application/json" _json = None _content = None - if isinstance(create_update_cassandra_keyspace_parameters, (IOBase, bytes)): - _content = create_update_cassandra_keyspace_parameters + if isinstance(update_throughput_parameters, (IOBase, bytes)): + _content = update_throughput_parameters else: - _json = self._serialize.body( - create_update_cassandra_keyspace_parameters, "CassandraKeyspaceCreateUpdateParameters" - ) + _json = self._serialize.body(update_throughput_parameters, "ThroughputSettingsUpdateParameters") - _request = build_create_update_cassandra_keyspace_request( + _request = build_update_cassandra_table_throughput_request( resource_group_name=resource_group_name, account_name=account_name, keyspace_name=keyspace_name, + table_name=table_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, @@ -2470,14 +2434,19 @@ def _create_update_cassandra_keyspace_initial( # pylint: disable=name-too-long except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + 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["azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("azure-AsyncOperation") + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") ) - response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) @@ -2487,17 +2456,18 @@ def _create_update_cassandra_keyspace_initial( # pylint: disable=name-too-long return deserialized # type: ignore @overload - def begin_create_update_cassandra_keyspace( + def begin_update_cassandra_table_throughput( self, resource_group_name: str, account_name: str, keyspace_name: str, - create_update_cassandra_keyspace_parameters: _models.CassandraKeyspaceCreateUpdateParameters, + table_name: str, + update_throughput_parameters: _models.ThroughputSettingsUpdateParameters, *, content_type: str = "application/json", **kwargs: Any - ) -> LROPoller[_models.CassandraKeyspaceGetResults]: - """Create or update an Azure Cosmos DB Cassandra keyspace. + ) -> LROPoller[_models.ThroughputSettingsGetResults]: + """Update RUs per second of an Azure Cosmos DB Cassandra table. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -2506,31 +2476,34 @@ def begin_create_update_cassandra_keyspace( :type account_name: str :param keyspace_name: Cosmos DB keyspace name. Required. :type keyspace_name: str - :param create_update_cassandra_keyspace_parameters: The parameters to provide for the current - Cassandra keyspace. Required. - :type create_update_cassandra_keyspace_parameters: - ~azure.mgmt.cosmosdb.models.CassandraKeyspaceCreateUpdateParameters + :param table_name: Cosmos DB table name. Required. + :type table_name: str + :param update_throughput_parameters: The RUs per second of the parameters to provide for the + current Cassandra table. Required. + :type update_throughput_parameters: + ~azure.mgmt.cosmosdb.models.ThroughputSettingsUpdateParameters :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 CassandraKeyspaceGetResults or the result - of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.CassandraKeyspaceGetResults] + :return: An instance of LROPoller that returns either ThroughputSettingsGetResults or the + result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.ThroughputSettingsGetResults] :raises ~azure.core.exceptions.HttpResponseError: """ @overload - def begin_create_update_cassandra_keyspace( + def begin_update_cassandra_table_throughput( self, resource_group_name: str, account_name: str, keyspace_name: str, - create_update_cassandra_keyspace_parameters: IO[bytes], + table_name: str, + update_throughput_parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> LROPoller[_models.CassandraKeyspaceGetResults]: - """Create or update an Azure Cosmos DB Cassandra keyspace. + ) -> LROPoller[_models.ThroughputSettingsGetResults]: + """Update RUs per second of an Azure Cosmos DB Cassandra table. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -2539,28 +2512,31 @@ def begin_create_update_cassandra_keyspace( :type account_name: str :param keyspace_name: Cosmos DB keyspace name. Required. :type keyspace_name: str - :param create_update_cassandra_keyspace_parameters: The parameters to provide for the current - Cassandra keyspace. Required. - :type create_update_cassandra_keyspace_parameters: IO[bytes] + :param table_name: Cosmos DB table name. Required. + :type table_name: str + :param update_throughput_parameters: The RUs per second of the parameters to provide for the + current Cassandra table. Required. + :type update_throughput_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 CassandraKeyspaceGetResults or the result - of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.CassandraKeyspaceGetResults] + :return: An instance of LROPoller that returns either ThroughputSettingsGetResults or the + result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.ThroughputSettingsGetResults] :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace - def begin_create_update_cassandra_keyspace( + def begin_update_cassandra_table_throughput( self, resource_group_name: str, account_name: str, keyspace_name: str, - create_update_cassandra_keyspace_parameters: Union[_models.CassandraKeyspaceCreateUpdateParameters, IO[bytes]], + table_name: str, + update_throughput_parameters: Union[_models.ThroughputSettingsUpdateParameters, IO[bytes]], **kwargs: Any - ) -> LROPoller[_models.CassandraKeyspaceGetResults]: - """Create or update an Azure Cosmos DB Cassandra keyspace. + ) -> LROPoller[_models.ThroughputSettingsGetResults]: + """Update RUs per second of an Azure Cosmos DB Cassandra table. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -2569,14 +2545,16 @@ def begin_create_update_cassandra_keyspace( :type account_name: str :param keyspace_name: Cosmos DB keyspace name. Required. :type keyspace_name: str - :param create_update_cassandra_keyspace_parameters: The parameters to provide for the current - Cassandra keyspace. Is either a CassandraKeyspaceCreateUpdateParameters type or a IO[bytes] + :param table_name: Cosmos DB table name. Required. + :type table_name: str + :param update_throughput_parameters: The RUs per second of the parameters to provide for the + current Cassandra table. Is either a ThroughputSettingsUpdateParameters type or a IO[bytes] type. Required. - :type create_update_cassandra_keyspace_parameters: - ~azure.mgmt.cosmosdb.models.CassandraKeyspaceCreateUpdateParameters or IO[bytes] - :return: An instance of LROPoller that returns either CassandraKeyspaceGetResults or the result - of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.CassandraKeyspaceGetResults] + :type update_throughput_parameters: + ~azure.mgmt.cosmosdb.models.ThroughputSettingsUpdateParameters or IO[bytes] + :return: An instance of LROPoller that returns either ThroughputSettingsGetResults or the + result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.ThroughputSettingsGetResults] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -2584,16 +2562,17 @@ def begin_create_update_cassandra_keyspace( 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.CassandraKeyspaceGetResults] = kwargs.pop("cls", None) + cls: ClsType[_models.ThroughputSettingsGetResults] = 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_update_cassandra_keyspace_initial( + raw_result = self._update_cassandra_table_throughput_initial( resource_group_name=resource_group_name, account_name=account_name, keyspace_name=keyspace_name, - create_update_cassandra_keyspace_parameters=create_update_cassandra_keyspace_parameters, + table_name=table_name, + update_throughput_parameters=update_throughput_parameters, api_version=api_version, content_type=content_type, cls=lambda x, y, z: x, @@ -2605,30 +2584,32 @@ def begin_create_update_cassandra_keyspace( kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("CassandraKeyspaceGetResults", pipeline_response.http_response) + deserialized = self._deserialize("ThroughputSettingsGetResults", 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, **kwargs)) + 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.CassandraKeyspaceGetResults].from_continuation_token( + return LROPoller[_models.ThroughputSettingsGetResults].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller[_models.CassandraKeyspaceGetResults]( + return LROPoller[_models.ThroughputSettingsGetResults]( self._client, raw_result, get_long_running_output, polling_method # type: ignore ) - def _delete_cassandra_keyspace_initial( - self, resource_group_name: str, account_name: str, keyspace_name: str, **kwargs: Any + def _migrate_cassandra_table_to_autoscale_initial( # pylint: disable=name-too-long + self, resource_group_name: str, account_name: str, keyspace_name: str, table_name: str, **kwargs: Any ) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -2644,10 +2625,11 @@ def _delete_cassandra_keyspace_initial( 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_cassandra_keyspace_request( + _request = build_migrate_cassandra_table_to_autoscale_request( resource_group_name=resource_group_name, account_name=account_name, keyspace_name=keyspace_name, + table_name=table_name, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, @@ -2663,7 +2645,7 @@ def _delete_cassandra_keyspace_initial( response = pipeline_response.http_response - if response.status_code not in [202, 204]: + if response.status_code not in [200, 202]: try: response.read() # Load the body in memory and close the socket except (StreamConsumedError, StreamClosedError): @@ -2673,10 +2655,11 @@ def _delete_cassandra_keyspace_initial( response_headers = {} if response.status_code == 202: - response_headers["azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("azure-AsyncOperation") + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") ) - response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) @@ -2686,10 +2669,10 @@ def _delete_cassandra_keyspace_initial( return deserialized # type: ignore @distributed_trace - def begin_delete_cassandra_keyspace( - self, resource_group_name: str, account_name: str, keyspace_name: str, **kwargs: Any - ) -> LROPoller[None]: - """Deletes an existing Azure Cosmos DB Cassandra keyspace. + def begin_migrate_cassandra_table_to_autoscale( # pylint: disable=name-too-long + self, resource_group_name: str, account_name: str, keyspace_name: str, table_name: str, **kwargs: Any + ) -> LROPoller[_models.ThroughputSettingsGetResults]: + """Migrate an Azure Cosmos DB Cassandra table from manual throughput to autoscale. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -2698,23 +2681,27 @@ def begin_delete_cassandra_keyspace( :type account_name: str :param keyspace_name: Cosmos DB keyspace name. Required. :type keyspace_name: str - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] + :param table_name: Cosmos DB table name. Required. + :type table_name: str + :return: An instance of LROPoller that returns either ThroughputSettingsGetResults or the + result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.ThroughputSettingsGetResults] :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) + cls: ClsType[_models.ThroughputSettingsGetResults] = 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_cassandra_keyspace_initial( + raw_result = self._migrate_cassandra_table_to_autoscale_initial( resource_group_name=resource_group_name, account_name=account_name, keyspace_name=keyspace_name, + table_name=table_name, api_version=api_version, cls=lambda x, y, z: x, headers=_headers, @@ -2724,93 +2711,33 @@ def begin_delete_cassandra_keyspace( raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("ThroughputSettingsGetResults", pipeline_response.http_response) if cls: - return cls(pipeline_response, None, {}) # type: ignore + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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( + return LROPoller[_models.ThroughputSettingsGetResults].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_cassandra_keyspace_throughput( - self, resource_group_name: str, account_name: str, keyspace_name: str, **kwargs: Any - ) -> _models.ThroughputSettingsGetResults: - """Gets the RUs per second of the Cassandra Keyspace under an existing Azure Cosmos DB database - account with the provided name. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param account_name: Cosmos DB database account name. Required. - :type account_name: str - :param keyspace_name: Cosmos DB keyspace name. Required. - :type keyspace_name: str - :return: ThroughputSettingsGetResults or the result of cls(response) - :rtype: ~azure.mgmt.cosmosdb.models.ThroughputSettingsGetResults - :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.ThroughputSettingsGetResults] = kwargs.pop("cls", None) - - _request = build_get_cassandra_keyspace_throughput_request( - resource_group_name=resource_group_name, - account_name=account_name, - keyspace_name=keyspace_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 + return LROPoller[_models.ThroughputSettingsGetResults]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore ) - 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("ThroughputSettingsGetResults", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - def _update_cassandra_keyspace_throughput_initial( # pylint: disable=name-too-long - self, - resource_group_name: str, - account_name: str, - keyspace_name: str, - update_throughput_parameters: Union[_models.ThroughputSettingsUpdateParameters, IO[bytes]], - **kwargs: Any + def _migrate_cassandra_table_to_manual_throughput_initial( # pylint: disable=name-too-long + self, resource_group_name: str, account_name: str, keyspace_name: str, table_name: str, **kwargs: Any ) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -2820,30 +2747,19 @@ def _update_cassandra_keyspace_throughput_initial( # pylint: disable=name-too-l } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = case_insensitive_dict(kwargs.pop("headers", {}) 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)) - 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(update_throughput_parameters, (IOBase, bytes)): - _content = update_throughput_parameters - else: - _json = self._serialize.body(update_throughput_parameters, "ThroughputSettingsUpdateParameters") - - _request = build_update_cassandra_keyspace_throughput_request( + _request = build_migrate_cassandra_table_to_manual_throughput_request( resource_group_name=resource_group_name, account_name=account_name, keyspace_name=keyspace_name, + table_name=table_name, subscription_id=self._config.subscription_id, api_version=api_version, - content_type=content_type, - json=_json, - content=_content, headers=_headers, params=_params, ) @@ -2867,10 +2783,11 @@ def _update_cassandra_keyspace_throughput_initial( # pylint: disable=name-too-l response_headers = {} if response.status_code == 202: - response_headers["azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("azure-AsyncOperation") + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") ) - response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) @@ -2879,18 +2796,11 @@ def _update_cassandra_keyspace_throughput_initial( # pylint: disable=name-too-l return deserialized # type: ignore - @overload - def begin_update_cassandra_keyspace_throughput( # pylint: disable=name-too-long - self, - resource_group_name: str, - account_name: str, - keyspace_name: str, - update_throughput_parameters: _models.ThroughputSettingsUpdateParameters, - *, - content_type: str = "application/json", - **kwargs: Any + @distributed_trace + def begin_migrate_cassandra_table_to_manual_throughput( # pylint: disable=name-too-long + self, resource_group_name: str, account_name: str, keyspace_name: str, table_name: str, **kwargs: Any ) -> LROPoller[_models.ThroughputSettingsGetResults]: - """Update RUs per second of an Azure Cosmos DB Cassandra Keyspace. + """Migrate an Azure Cosmos DB Cassandra table from autoscale to manual throughput. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -2899,14 +2809,234 @@ def begin_update_cassandra_keyspace_throughput( # pylint: disable=name-too-long :type account_name: str :param keyspace_name: Cosmos DB keyspace name. Required. :type keyspace_name: str - :param update_throughput_parameters: The RUs per second of the parameters to provide for the - current Cassandra Keyspace. Required. - :type update_throughput_parameters: - ~azure.mgmt.cosmosdb.models.ThroughputSettingsUpdateParameters - :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 ThroughputSettingsGetResults or the + :param table_name: Cosmos DB table name. Required. + :type table_name: str + :return: An instance of LROPoller that returns either ThroughputSettingsGetResults or the + result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.ThroughputSettingsGetResults] + :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.ThroughputSettingsGetResults] = 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_cassandra_table_to_manual_throughput_initial( + resource_group_name=resource_group_name, + account_name=account_name, + keyspace_name=keyspace_name, + table_name=table_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("ThroughputSettingsGetResults", 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": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.ThroughputSettingsGetResults].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.ThroughputSettingsGetResults]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + @distributed_trace + def get_cassandra_keyspace_throughput( + self, resource_group_name: str, account_name: str, keyspace_name: str, **kwargs: Any + ) -> _models.ThroughputSettingsGetResults: + """Gets the RUs per second of the Cassandra Keyspace under an existing Azure Cosmos DB database + account with the provided name. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param keyspace_name: Cosmos DB keyspace name. Required. + :type keyspace_name: str + :return: ThroughputSettingsGetResults or the result of cls(response) + :rtype: ~azure.mgmt.cosmosdb.models.ThroughputSettingsGetResults + :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.ThroughputSettingsGetResults] = kwargs.pop("cls", None) + + _request = build_get_cassandra_keyspace_throughput_request( + resource_group_name=resource_group_name, + account_name=account_name, + keyspace_name=keyspace_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("ThroughputSettingsGetResults", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + def _update_cassandra_keyspace_throughput_initial( # pylint: disable=name-too-long + self, + resource_group_name: str, + account_name: str, + keyspace_name: str, + update_throughput_parameters: Union[_models.ThroughputSettingsUpdateParameters, 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(update_throughput_parameters, (IOBase, bytes)): + _content = update_throughput_parameters + else: + _json = self._serialize.body(update_throughput_parameters, "ThroughputSettingsUpdateParameters") + + _request = build_update_cassandra_keyspace_throughput_request( + resource_group_name=resource_group_name, + account_name=account_name, + keyspace_name=keyspace_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["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.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_cassandra_keyspace_throughput( # pylint: disable=name-too-long + self, + resource_group_name: str, + account_name: str, + keyspace_name: str, + update_throughput_parameters: _models.ThroughputSettingsUpdateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ThroughputSettingsGetResults]: + """Update RUs per second of an Azure Cosmos DB Cassandra Keyspace. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param keyspace_name: Cosmos DB keyspace name. Required. + :type keyspace_name: str + :param update_throughput_parameters: The RUs per second of the parameters to provide for the + current Cassandra Keyspace. Required. + :type update_throughput_parameters: + ~azure.mgmt.cosmosdb.models.ThroughputSettingsUpdateParameters + :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 ThroughputSettingsGetResults or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.ThroughputSettingsGetResults] :raises ~azure.core.exceptions.HttpResponseError: @@ -3004,7 +3134,9 @@ def get_long_running_output(pipeline_response): return deserialized if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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: @@ -3066,10 +3198,11 @@ def _migrate_cassandra_keyspace_to_autoscale_initial( # pylint: disable=name-to response_headers = {} if response.status_code == 202: - response_headers["azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("azure-AsyncOperation") + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") ) - response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) @@ -3125,7 +3258,9 @@ def get_long_running_output(pipeline_response): return deserialized if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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: @@ -3187,10 +3322,11 @@ def _migrate_cassandra_keyspace_to_manual_throughput_initial( # pylint: disable response_headers = {} if response.status_code == 202: - response_headers["azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("azure-AsyncOperation") + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") ) - response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) @@ -3246,7 +3382,9 @@ def get_long_running_output(pipeline_response): return deserialized if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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: @@ -3263,10 +3401,10 @@ def get_long_running_output(pipeline_response): ) @distributed_trace - def list_cassandra_tables( + def list_cassandra_views( self, resource_group_name: str, account_name: str, keyspace_name: str, **kwargs: Any - ) -> ItemPaged["_models.CassandraTableGetResults"]: - """Lists the Cassandra table under an existing Azure Cosmos DB database account. + ) -> ItemPaged["_models.CassandraViewGetResults"]: + """Lists the Cassandra materialized views under an existing Azure Cosmos DB database account. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -3275,16 +3413,16 @@ def list_cassandra_tables( :type account_name: str :param keyspace_name: Cosmos DB keyspace name. Required. :type keyspace_name: str - :return: An iterator like instance of either CassandraTableGetResults or the result of + :return: An iterator like instance of either CassandraViewGetResults or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cosmosdb.models.CassandraTableGetResults] + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cosmosdb.models.CassandraViewGetResults] :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.CassandraTableListResult] = kwargs.pop("cls", None) + cls: ClsType[_models.CassandraViewListResult] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -3297,7 +3435,7 @@ def list_cassandra_tables( def prepare_request(next_link=None): if not next_link: - _request = build_list_cassandra_tables_request( + _request = build_list_cassandra_views_request( resource_group_name=resource_group_name, account_name=account_name, keyspace_name=keyspace_name, @@ -3326,11 +3464,11 @@ def prepare_request(next_link=None): return _request def extract_data(pipeline_response): - deserialized = self._deserialize("CassandraTableListResult", pipeline_response) + deserialized = self._deserialize("CassandraViewListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore - return None, iter(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): _request = prepare_request(next_link) @@ -3343,17 +3481,21 @@ 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + 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_cassandra_table( - self, resource_group_name: str, account_name: str, keyspace_name: str, table_name: str, **kwargs: Any - ) -> _models.CassandraTableGetResults: - """Gets the Cassandra table under an existing Azure Cosmos DB database account. + def get_cassandra_view( + self, resource_group_name: str, account_name: str, keyspace_name: str, view_name: str, **kwargs: Any + ) -> _models.CassandraViewGetResults: + """Gets the Cassandra view under an existing Azure Cosmos DB database account. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -3362,10 +3504,10 @@ def get_cassandra_table( :type account_name: str :param keyspace_name: Cosmos DB keyspace name. Required. :type keyspace_name: str - :param table_name: Cosmos DB table name. Required. - :type table_name: str - :return: CassandraTableGetResults or the result of cls(response) - :rtype: ~azure.mgmt.cosmosdb.models.CassandraTableGetResults + :param view_name: Cosmos DB view name. Required. + :type view_name: str + :return: CassandraViewGetResults or the result of cls(response) + :rtype: ~azure.mgmt.cosmosdb.models.CassandraViewGetResults :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -3380,13 +3522,13 @@ def get_cassandra_table( _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.CassandraTableGetResults] = kwargs.pop("cls", None) + cls: ClsType[_models.CassandraViewGetResults] = kwargs.pop("cls", None) - _request = build_get_cassandra_table_request( + _request = build_get_cassandra_view_request( resource_group_name=resource_group_name, account_name=account_name, keyspace_name=keyspace_name, - table_name=table_name, + view_name=view_name, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, @@ -3403,22 +3545,26 @@ def get_cassandra_table( if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("CassandraTableGetResults", pipeline_response.http_response) + deserialized = self._deserialize("CassandraViewGetResults", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - def _create_update_cassandra_table_initial( + def _create_update_cassandra_view_initial( self, resource_group_name: str, account_name: str, keyspace_name: str, - table_name: str, - create_update_cassandra_table_parameters: Union[_models.CassandraTableCreateUpdateParameters, IO[bytes]], + view_name: str, + create_update_cassandra_view_parameters: Union[_models.CassandraViewCreateUpdateParameters, IO[bytes]], **kwargs: Any ) -> Iterator[bytes]: error_map: MutableMapping = { @@ -3439,18 +3585,16 @@ def _create_update_cassandra_table_initial( content_type = content_type or "application/json" _json = None _content = None - if isinstance(create_update_cassandra_table_parameters, (IOBase, bytes)): - _content = create_update_cassandra_table_parameters + if isinstance(create_update_cassandra_view_parameters, (IOBase, bytes)): + _content = create_update_cassandra_view_parameters else: - _json = self._serialize.body( - create_update_cassandra_table_parameters, "CassandraTableCreateUpdateParameters" - ) + _json = self._serialize.body(create_update_cassandra_view_parameters, "CassandraViewCreateUpdateParameters") - _request = build_create_update_cassandra_table_request( + _request = build_create_update_cassandra_view_request( resource_group_name=resource_group_name, account_name=account_name, keyspace_name=keyspace_name, - table_name=table_name, + view_name=view_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, @@ -3475,14 +3619,19 @@ def _create_update_cassandra_table_initial( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + 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["azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("azure-AsyncOperation") + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") ) - response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) @@ -3492,18 +3641,18 @@ def _create_update_cassandra_table_initial( return deserialized # type: ignore @overload - def begin_create_update_cassandra_table( + def begin_create_update_cassandra_view( self, resource_group_name: str, account_name: str, keyspace_name: str, - table_name: str, - create_update_cassandra_table_parameters: _models.CassandraTableCreateUpdateParameters, + view_name: str, + create_update_cassandra_view_parameters: _models.CassandraViewCreateUpdateParameters, *, content_type: str = "application/json", **kwargs: Any - ) -> LROPoller[_models.CassandraTableGetResults]: - """Create or update an Azure Cosmos DB Cassandra Table. + ) -> LROPoller[_models.CassandraViewGetResults]: + """Create or update an Azure Cosmos DB Cassandra View. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -3512,34 +3661,34 @@ def begin_create_update_cassandra_table( :type account_name: str :param keyspace_name: Cosmos DB keyspace name. Required. :type keyspace_name: str - :param table_name: Cosmos DB table name. Required. - :type table_name: str - :param create_update_cassandra_table_parameters: The parameters to provide for the current - Cassandra Table. Required. - :type create_update_cassandra_table_parameters: - ~azure.mgmt.cosmosdb.models.CassandraTableCreateUpdateParameters + :param view_name: Cosmos DB view name. Required. + :type view_name: str + :param create_update_cassandra_view_parameters: The parameters to provide for the current + Cassandra View. Required. + :type create_update_cassandra_view_parameters: + ~azure.mgmt.cosmosdb.models.CassandraViewCreateUpdateParameters :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 CassandraTableGetResults or the result of + :return: An instance of LROPoller that returns either CassandraViewGetResults or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.CassandraTableGetResults] + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.CassandraViewGetResults] :raises ~azure.core.exceptions.HttpResponseError: """ @overload - def begin_create_update_cassandra_table( + def begin_create_update_cassandra_view( self, resource_group_name: str, account_name: str, keyspace_name: str, - table_name: str, - create_update_cassandra_table_parameters: IO[bytes], + view_name: str, + create_update_cassandra_view_parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> LROPoller[_models.CassandraTableGetResults]: - """Create or update an Azure Cosmos DB Cassandra Table. + ) -> LROPoller[_models.CassandraViewGetResults]: + """Create or update an Azure Cosmos DB Cassandra View. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -3548,31 +3697,31 @@ def begin_create_update_cassandra_table( :type account_name: str :param keyspace_name: Cosmos DB keyspace name. Required. :type keyspace_name: str - :param table_name: Cosmos DB table name. Required. - :type table_name: str - :param create_update_cassandra_table_parameters: The parameters to provide for the current - Cassandra Table. Required. - :type create_update_cassandra_table_parameters: IO[bytes] + :param view_name: Cosmos DB view name. Required. + :type view_name: str + :param create_update_cassandra_view_parameters: The parameters to provide for the current + Cassandra View. Required. + :type create_update_cassandra_view_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 CassandraTableGetResults or the result of + :return: An instance of LROPoller that returns either CassandraViewGetResults or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.CassandraTableGetResults] + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.CassandraViewGetResults] :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace - def begin_create_update_cassandra_table( + def begin_create_update_cassandra_view( self, resource_group_name: str, account_name: str, keyspace_name: str, - table_name: str, - create_update_cassandra_table_parameters: Union[_models.CassandraTableCreateUpdateParameters, IO[bytes]], + view_name: str, + create_update_cassandra_view_parameters: Union[_models.CassandraViewCreateUpdateParameters, IO[bytes]], **kwargs: Any - ) -> LROPoller[_models.CassandraTableGetResults]: - """Create or update an Azure Cosmos DB Cassandra Table. + ) -> LROPoller[_models.CassandraViewGetResults]: + """Create or update an Azure Cosmos DB Cassandra View. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -3581,16 +3730,16 @@ def begin_create_update_cassandra_table( :type account_name: str :param keyspace_name: Cosmos DB keyspace name. Required. :type keyspace_name: str - :param table_name: Cosmos DB table name. Required. - :type table_name: str - :param create_update_cassandra_table_parameters: The parameters to provide for the current - Cassandra Table. Is either a CassandraTableCreateUpdateParameters type or a IO[bytes] type. + :param view_name: Cosmos DB view name. Required. + :type view_name: str + :param create_update_cassandra_view_parameters: The parameters to provide for the current + Cassandra View. Is either a CassandraViewCreateUpdateParameters type or a IO[bytes] type. Required. - :type create_update_cassandra_table_parameters: - ~azure.mgmt.cosmosdb.models.CassandraTableCreateUpdateParameters or IO[bytes] - :return: An instance of LROPoller that returns either CassandraTableGetResults or the result of + :type create_update_cassandra_view_parameters: + ~azure.mgmt.cosmosdb.models.CassandraViewCreateUpdateParameters or IO[bytes] + :return: An instance of LROPoller that returns either CassandraViewGetResults or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.CassandraTableGetResults] + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.CassandraViewGetResults] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -3598,17 +3747,17 @@ def begin_create_update_cassandra_table( 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.CassandraTableGetResults] = kwargs.pop("cls", None) + cls: ClsType[_models.CassandraViewGetResults] = 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_update_cassandra_table_initial( + raw_result = self._create_update_cassandra_view_initial( resource_group_name=resource_group_name, account_name=account_name, keyspace_name=keyspace_name, - table_name=table_name, - create_update_cassandra_table_parameters=create_update_cassandra_table_parameters, + view_name=view_name, + create_update_cassandra_view_parameters=create_update_cassandra_view_parameters, api_version=api_version, content_type=content_type, cls=lambda x, y, z: x, @@ -3620,30 +3769,32 @@ def begin_create_update_cassandra_table( kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("CassandraTableGetResults", pipeline_response.http_response) + deserialized = self._deserialize("CassandraViewGetResults", 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, **kwargs)) + 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.CassandraTableGetResults].from_continuation_token( + return LROPoller[_models.CassandraViewGetResults].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller[_models.CassandraTableGetResults]( + return LROPoller[_models.CassandraViewGetResults]( self._client, raw_result, get_long_running_output, polling_method # type: ignore ) - def _delete_cassandra_table_initial( - self, resource_group_name: str, account_name: str, keyspace_name: str, table_name: str, **kwargs: Any + def _delete_cassandra_view_initial( + self, resource_group_name: str, account_name: str, keyspace_name: str, view_name: str, **kwargs: Any ) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -3659,11 +3810,11 @@ def _delete_cassandra_table_initial( 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_cassandra_table_request( + _request = build_delete_cassandra_view_request( resource_group_name=resource_group_name, account_name=account_name, keyspace_name=keyspace_name, - table_name=table_name, + view_name=view_name, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, @@ -3679,20 +3830,25 @@ def _delete_cassandra_table_initial( response = pipeline_response.http_response - if response.status_code not in [202, 204]: + if response.status_code not in [200, 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + 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["azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("azure-AsyncOperation") + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") ) - response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) @@ -3702,10 +3858,10 @@ def _delete_cassandra_table_initial( return deserialized # type: ignore @distributed_trace - def begin_delete_cassandra_table( - self, resource_group_name: str, account_name: str, keyspace_name: str, table_name: str, **kwargs: Any + def begin_delete_cassandra_view( + self, resource_group_name: str, account_name: str, keyspace_name: str, view_name: str, **kwargs: Any ) -> LROPoller[None]: - """Deletes an existing Azure Cosmos DB Cassandra table. + """Deletes an existing Azure Cosmos DB Cassandra view. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -3714,8 +3870,8 @@ def begin_delete_cassandra_table( :type account_name: str :param keyspace_name: Cosmos DB keyspace name. Required. :type keyspace_name: str - :param table_name: Cosmos DB table name. Required. - :type table_name: str + :param view_name: Cosmos DB view name. Required. + :type view_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: @@ -3729,11 +3885,11 @@ def begin_delete_cassandra_table( 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_cassandra_table_initial( + raw_result = self._delete_cassandra_view_initial( resource_group_name=resource_group_name, account_name=account_name, keyspace_name=keyspace_name, - table_name=table_name, + view_name=view_name, api_version=api_version, cls=lambda x, y, z: x, headers=_headers, @@ -3748,7 +3904,9 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- return cls(pipeline_response, None, {}) # type: ignore if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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: @@ -3763,10 +3921,10 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore @distributed_trace - def get_cassandra_table_throughput( - self, resource_group_name: str, account_name: str, keyspace_name: str, table_name: str, **kwargs: Any + def get_cassandra_view_throughput( + self, resource_group_name: str, account_name: str, keyspace_name: str, view_name: str, **kwargs: Any ) -> _models.ThroughputSettingsGetResults: - """Gets the RUs per second of the Cassandra table under an existing Azure Cosmos DB database + """Gets the RUs per second of the Cassandra view under an existing Azure Cosmos DB database account with the provided name. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -3776,8 +3934,8 @@ def get_cassandra_table_throughput( :type account_name: str :param keyspace_name: Cosmos DB keyspace name. Required. :type keyspace_name: str - :param table_name: Cosmos DB table name. Required. - :type table_name: str + :param view_name: Cosmos DB view name. Required. + :type view_name: str :return: ThroughputSettingsGetResults or the result of cls(response) :rtype: ~azure.mgmt.cosmosdb.models.ThroughputSettingsGetResults :raises ~azure.core.exceptions.HttpResponseError: @@ -3796,11 +3954,11 @@ def get_cassandra_table_throughput( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ThroughputSettingsGetResults] = kwargs.pop("cls", None) - _request = build_get_cassandra_table_throughput_request( + _request = build_get_cassandra_view_throughput_request( resource_group_name=resource_group_name, account_name=account_name, keyspace_name=keyspace_name, - table_name=table_name, + view_name=view_name, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, @@ -3817,7 +3975,11 @@ def get_cassandra_table_throughput( if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("ThroughputSettingsGetResults", pipeline_response.http_response) @@ -3826,12 +3988,12 @@ def get_cassandra_table_throughput( return deserialized # type: ignore - def _update_cassandra_table_throughput_initial( # pylint: disable=name-too-long + def _update_cassandra_view_throughput_initial( # pylint: disable=name-too-long self, resource_group_name: str, account_name: str, keyspace_name: str, - table_name: str, + view_name: str, update_throughput_parameters: Union[_models.ThroughputSettingsUpdateParameters, IO[bytes]], **kwargs: Any ) -> Iterator[bytes]: @@ -3858,11 +4020,11 @@ def _update_cassandra_table_throughput_initial( # pylint: disable=name-too-long else: _json = self._serialize.body(update_throughput_parameters, "ThroughputSettingsUpdateParameters") - _request = build_update_cassandra_table_throughput_request( + _request = build_update_cassandra_view_throughput_request( resource_group_name=resource_group_name, account_name=account_name, keyspace_name=keyspace_name, - table_name=table_name, + view_name=view_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, @@ -3887,14 +4049,19 @@ def _update_cassandra_table_throughput_initial( # pylint: disable=name-too-long except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + 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["azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("azure-AsyncOperation") + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") ) - response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) @@ -3904,18 +4071,18 @@ def _update_cassandra_table_throughput_initial( # pylint: disable=name-too-long return deserialized # type: ignore @overload - def begin_update_cassandra_table_throughput( + def begin_update_cassandra_view_throughput( self, resource_group_name: str, account_name: str, keyspace_name: str, - table_name: str, + view_name: str, update_throughput_parameters: _models.ThroughputSettingsUpdateParameters, *, content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.ThroughputSettingsGetResults]: - """Update RUs per second of an Azure Cosmos DB Cassandra table. + """Update RUs per second of an Azure Cosmos DB Cassandra view. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -3924,10 +4091,10 @@ def begin_update_cassandra_table_throughput( :type account_name: str :param keyspace_name: Cosmos DB keyspace name. Required. :type keyspace_name: str - :param table_name: Cosmos DB table name. Required. - :type table_name: str + :param view_name: Cosmos DB view name. Required. + :type view_name: str :param update_throughput_parameters: The RUs per second of the parameters to provide for the - current Cassandra table. Required. + current Cassandra view. Required. :type update_throughput_parameters: ~azure.mgmt.cosmosdb.models.ThroughputSettingsUpdateParameters :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. @@ -3940,18 +4107,18 @@ def begin_update_cassandra_table_throughput( """ @overload - def begin_update_cassandra_table_throughput( + def begin_update_cassandra_view_throughput( self, resource_group_name: str, account_name: str, keyspace_name: str, - table_name: str, + view_name: str, update_throughput_parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.ThroughputSettingsGetResults]: - """Update RUs per second of an Azure Cosmos DB Cassandra table. + """Update RUs per second of an Azure Cosmos DB Cassandra view. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -3960,10 +4127,10 @@ def begin_update_cassandra_table_throughput( :type account_name: str :param keyspace_name: Cosmos DB keyspace name. Required. :type keyspace_name: str - :param table_name: Cosmos DB table name. Required. - :type table_name: str + :param view_name: Cosmos DB view name. Required. + :type view_name: str :param update_throughput_parameters: The RUs per second of the parameters to provide for the - current Cassandra table. Required. + current Cassandra view. Required. :type update_throughput_parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". @@ -3975,16 +4142,16 @@ def begin_update_cassandra_table_throughput( """ @distributed_trace - def begin_update_cassandra_table_throughput( + def begin_update_cassandra_view_throughput( self, resource_group_name: str, account_name: str, keyspace_name: str, - table_name: str, + view_name: str, update_throughput_parameters: Union[_models.ThroughputSettingsUpdateParameters, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.ThroughputSettingsGetResults]: - """Update RUs per second of an Azure Cosmos DB Cassandra table. + """Update RUs per second of an Azure Cosmos DB Cassandra view. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -3993,10 +4160,10 @@ def begin_update_cassandra_table_throughput( :type account_name: str :param keyspace_name: Cosmos DB keyspace name. Required. :type keyspace_name: str - :param table_name: Cosmos DB table name. Required. - :type table_name: str + :param view_name: Cosmos DB view name. Required. + :type view_name: str :param update_throughput_parameters: The RUs per second of the parameters to provide for the - current Cassandra table. Is either a ThroughputSettingsUpdateParameters type or a IO[bytes] + current Cassandra view. Is either a ThroughputSettingsUpdateParameters type or a IO[bytes] type. Required. :type update_throughput_parameters: ~azure.mgmt.cosmosdb.models.ThroughputSettingsUpdateParameters or IO[bytes] @@ -4015,11 +4182,11 @@ def begin_update_cassandra_table_throughput( 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_cassandra_table_throughput_initial( + raw_result = self._update_cassandra_view_throughput_initial( resource_group_name=resource_group_name, account_name=account_name, keyspace_name=keyspace_name, - table_name=table_name, + view_name=view_name, update_throughput_parameters=update_throughput_parameters, api_version=api_version, content_type=content_type, @@ -4038,7 +4205,9 @@ def get_long_running_output(pipeline_response): return deserialized if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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: @@ -4054,8 +4223,8 @@ def get_long_running_output(pipeline_response): self._client, raw_result, get_long_running_output, polling_method # type: ignore ) - def _migrate_cassandra_table_to_autoscale_initial( # pylint: disable=name-too-long - self, resource_group_name: str, account_name: str, keyspace_name: str, table_name: str, **kwargs: Any + def _migrate_cassandra_view_to_autoscale_initial( # pylint: disable=name-too-long + self, resource_group_name: str, account_name: str, keyspace_name: str, view_name: str, **kwargs: Any ) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -4071,11 +4240,11 @@ def _migrate_cassandra_table_to_autoscale_initial( # pylint: disable=name-too-l 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_migrate_cassandra_table_to_autoscale_request( + _request = build_migrate_cassandra_view_to_autoscale_request( resource_group_name=resource_group_name, account_name=account_name, keyspace_name=keyspace_name, - table_name=table_name, + view_name=view_name, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, @@ -4101,10 +4270,11 @@ def _migrate_cassandra_table_to_autoscale_initial( # pylint: disable=name-too-l response_headers = {} if response.status_code == 202: - response_headers["azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("azure-AsyncOperation") + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") ) - response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) @@ -4114,10 +4284,10 @@ def _migrate_cassandra_table_to_autoscale_initial( # pylint: disable=name-too-l return deserialized # type: ignore @distributed_trace - def begin_migrate_cassandra_table_to_autoscale( # pylint: disable=name-too-long - self, resource_group_name: str, account_name: str, keyspace_name: str, table_name: str, **kwargs: Any + def begin_migrate_cassandra_view_to_autoscale( # pylint: disable=name-too-long + self, resource_group_name: str, account_name: str, keyspace_name: str, view_name: str, **kwargs: Any ) -> LROPoller[_models.ThroughputSettingsGetResults]: - """Migrate an Azure Cosmos DB Cassandra table from manual throughput to autoscale. + """Migrate an Azure Cosmos DB Cassandra view from manual throughput to autoscale. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -4126,8 +4296,8 @@ def begin_migrate_cassandra_table_to_autoscale( # pylint: disable=name-too-long :type account_name: str :param keyspace_name: Cosmos DB keyspace name. Required. :type keyspace_name: str - :param table_name: Cosmos DB table name. Required. - :type table_name: str + :param view_name: Cosmos DB view name. Required. + :type view_name: str :return: An instance of LROPoller that returns either ThroughputSettingsGetResults or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.ThroughputSettingsGetResults] @@ -4142,11 +4312,11 @@ def begin_migrate_cassandra_table_to_autoscale( # pylint: disable=name-too-long 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_cassandra_table_to_autoscale_initial( + raw_result = self._migrate_cassandra_view_to_autoscale_initial( resource_group_name=resource_group_name, account_name=account_name, keyspace_name=keyspace_name, - table_name=table_name, + view_name=view_name, api_version=api_version, cls=lambda x, y, z: x, headers=_headers, @@ -4163,7 +4333,9 @@ def get_long_running_output(pipeline_response): return deserialized if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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: @@ -4179,8 +4351,8 @@ def get_long_running_output(pipeline_response): self._client, raw_result, get_long_running_output, polling_method # type: ignore ) - def _migrate_cassandra_table_to_manual_throughput_initial( # pylint: disable=name-too-long - self, resource_group_name: str, account_name: str, keyspace_name: str, table_name: str, **kwargs: Any + def _migrate_cassandra_view_to_manual_throughput_initial( # pylint: disable=name-too-long + self, resource_group_name: str, account_name: str, keyspace_name: str, view_name: str, **kwargs: Any ) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -4196,11 +4368,11 @@ def _migrate_cassandra_table_to_manual_throughput_initial( # pylint: disable=na 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_migrate_cassandra_table_to_manual_throughput_request( + _request = build_migrate_cassandra_view_to_manual_throughput_request( resource_group_name=resource_group_name, account_name=account_name, keyspace_name=keyspace_name, - table_name=table_name, + view_name=view_name, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, @@ -4226,10 +4398,11 @@ def _migrate_cassandra_table_to_manual_throughput_initial( # pylint: disable=na response_headers = {} if response.status_code == 202: - response_headers["azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("azure-AsyncOperation") + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") ) - response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) @@ -4239,10 +4412,10 @@ def _migrate_cassandra_table_to_manual_throughput_initial( # pylint: disable=na return deserialized # type: ignore @distributed_trace - def begin_migrate_cassandra_table_to_manual_throughput( # pylint: disable=name-too-long - self, resource_group_name: str, account_name: str, keyspace_name: str, table_name: str, **kwargs: Any + def begin_migrate_cassandra_view_to_manual_throughput( # pylint: disable=name-too-long + self, resource_group_name: str, account_name: str, keyspace_name: str, view_name: str, **kwargs: Any ) -> LROPoller[_models.ThroughputSettingsGetResults]: - """Migrate an Azure Cosmos DB Cassandra table from autoscale to manual throughput. + """Migrate an Azure Cosmos DB Cassandra view from autoscale to manual throughput. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -4251,8 +4424,8 @@ def begin_migrate_cassandra_table_to_manual_throughput( # pylint: disable=name- :type account_name: str :param keyspace_name: Cosmos DB keyspace name. Required. :type keyspace_name: str - :param table_name: Cosmos DB table name. Required. - :type table_name: str + :param view_name: Cosmos DB view name. Required. + :type view_name: str :return: An instance of LROPoller that returns either ThroughputSettingsGetResults or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.ThroughputSettingsGetResults] @@ -4267,11 +4440,11 @@ def begin_migrate_cassandra_table_to_manual_throughput( # pylint: disable=name- 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_cassandra_table_to_manual_throughput_initial( + raw_result = self._migrate_cassandra_view_to_manual_throughput_initial( resource_group_name=resource_group_name, account_name=account_name, keyspace_name=keyspace_name, - table_name=table_name, + view_name=view_name, api_version=api_version, cls=lambda x, y, z: x, headers=_headers, @@ -4288,7 +4461,9 @@ def get_long_running_output(pipeline_response): return deserialized if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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: @@ -4305,28 +4480,27 @@ def get_long_running_output(pipeline_response): ) @distributed_trace - def list_cassandra_views( - self, resource_group_name: str, account_name: str, keyspace_name: str, **kwargs: Any - ) -> ItemPaged["_models.CassandraViewGetResults"]: - """Lists the Cassandra materialized views under an existing Azure Cosmos DB database account. + def list_cassandra_role_assignments( + self, resource_group_name: str, account_name: str, **kwargs: Any + ) -> ItemPaged["_models.CassandraRoleAssignmentResource"]: + """Retrieves the list of all Azure Cosmos DB Cassandra Role Assignments. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param keyspace_name: Cosmos DB keyspace name. Required. - :type keyspace_name: str - :return: An iterator like instance of either CassandraViewGetResults or the result of + :return: An iterator like instance of either CassandraRoleAssignmentResource or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cosmosdb.models.CassandraViewGetResults] + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.cosmosdb.models.CassandraRoleAssignmentResource] :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.CassandraViewListResult] = kwargs.pop("cls", None) + cls: ClsType[_models.CassandraRoleAssignmentListResult] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -4339,10 +4513,9 @@ def list_cassandra_views( def prepare_request(next_link=None): if not next_link: - _request = build_list_cassandra_views_request( + _request = build_list_cassandra_role_assignments_request( resource_group_name=resource_group_name, account_name=account_name, - keyspace_name=keyspace_name, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, @@ -4368,11 +4541,11 @@ def prepare_request(next_link=None): return _request def extract_data(pipeline_response): - deserialized = self._deserialize("CassandraViewListResult", pipeline_response) + deserialized = self._deserialize("CassandraRoleAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore - return None, iter(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): _request = prepare_request(next_link) @@ -4385,29 +4558,32 @@ 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + 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_cassandra_view( - self, resource_group_name: str, account_name: str, keyspace_name: str, view_name: str, **kwargs: Any - ) -> _models.CassandraViewGetResults: - """Gets the Cassandra view under an existing Azure Cosmos DB database account. + def get_cassandra_role_assignment( + self, resource_group_name: str, account_name: str, role_assignment_id: str, **kwargs: Any + ) -> _models.CassandraRoleAssignmentResource: + """Retrieves the properties of an existing Azure Cosmos DB Cassandra Role Assignment with the + given Id. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param keyspace_name: Cosmos DB keyspace name. Required. - :type keyspace_name: str - :param view_name: Cosmos DB view name. Required. - :type view_name: str - :return: CassandraViewGetResults or the result of cls(response) - :rtype: ~azure.mgmt.cosmosdb.models.CassandraViewGetResults + :param role_assignment_id: The GUID for the Role Assignment. Required. + :type role_assignment_id: str + :return: CassandraRoleAssignmentResource or the result of cls(response) + :rtype: ~azure.mgmt.cosmosdb.models.CassandraRoleAssignmentResource :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -4422,13 +4598,12 @@ def get_cassandra_view( _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.CassandraViewGetResults] = kwargs.pop("cls", None) + cls: ClsType[_models.CassandraRoleAssignmentResource] = kwargs.pop("cls", None) - _request = build_get_cassandra_view_request( + _request = build_get_cassandra_role_assignment_request( resource_group_name=resource_group_name, account_name=account_name, - keyspace_name=keyspace_name, - view_name=view_name, + role_assignment_id=role_assignment_id, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, @@ -4445,22 +4620,25 @@ def get_cassandra_view( if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("CassandraViewGetResults", pipeline_response.http_response) + deserialized = self._deserialize("CassandraRoleAssignmentResource", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - def _create_update_cassandra_view_initial( + def _create_update_cassandra_role_assignment_initial( # pylint: disable=name-too-long self, resource_group_name: str, account_name: str, - keyspace_name: str, - view_name: str, - create_update_cassandra_view_parameters: Union[_models.CassandraViewCreateUpdateParameters, IO[bytes]], + role_assignment_id: str, + create_update_cassandra_role_assignment_parameters: Union[_models.CassandraRoleAssignmentResource, IO[bytes]], **kwargs: Any ) -> Iterator[bytes]: error_map: MutableMapping = { @@ -4481,16 +4659,17 @@ def _create_update_cassandra_view_initial( content_type = content_type or "application/json" _json = None _content = None - if isinstance(create_update_cassandra_view_parameters, (IOBase, bytes)): - _content = create_update_cassandra_view_parameters + if isinstance(create_update_cassandra_role_assignment_parameters, (IOBase, bytes)): + _content = create_update_cassandra_role_assignment_parameters else: - _json = self._serialize.body(create_update_cassandra_view_parameters, "CassandraViewCreateUpdateParameters") + _json = self._serialize.body( + create_update_cassandra_role_assignment_parameters, "CassandraRoleAssignmentResource" + ) - _request = build_create_update_cassandra_view_request( + _request = build_create_update_cassandra_role_assignment_request( resource_group_name=resource_group_name, account_name=account_name, - keyspace_name=keyspace_name, - view_name=view_name, + role_assignment_id=role_assignment_id, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, @@ -4515,14 +4694,19 @@ def _create_update_cassandra_view_initial( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + 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["azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("azure-AsyncOperation") + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") ) - response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) @@ -4532,105 +4716,99 @@ def _create_update_cassandra_view_initial( return deserialized # type: ignore @overload - def begin_create_update_cassandra_view( + def begin_create_update_cassandra_role_assignment( # pylint: disable=name-too-long self, resource_group_name: str, account_name: str, - keyspace_name: str, - view_name: str, - create_update_cassandra_view_parameters: _models.CassandraViewCreateUpdateParameters, + role_assignment_id: str, + create_update_cassandra_role_assignment_parameters: _models.CassandraRoleAssignmentResource, *, content_type: str = "application/json", **kwargs: Any - ) -> LROPoller[_models.CassandraViewGetResults]: - """Create or update an Azure Cosmos DB Cassandra View. + ) -> LROPoller[_models.CassandraRoleAssignmentResource]: + """Creates or updates an Azure Cosmos DB Cassandra Role Assignment. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param keyspace_name: Cosmos DB keyspace name. Required. - :type keyspace_name: str - :param view_name: Cosmos DB view name. Required. - :type view_name: str - :param create_update_cassandra_view_parameters: The parameters to provide for the current - Cassandra View. Required. - :type create_update_cassandra_view_parameters: - ~azure.mgmt.cosmosdb.models.CassandraViewCreateUpdateParameters + :param role_assignment_id: The GUID for the Role Assignment. Required. + :type role_assignment_id: str + :param create_update_cassandra_role_assignment_parameters: The properties required to create or + update a Role Assignment. Required. + :type create_update_cassandra_role_assignment_parameters: + ~azure.mgmt.cosmosdb.models.CassandraRoleAssignmentResource :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 CassandraViewGetResults or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.CassandraViewGetResults] + :return: An instance of LROPoller that returns either CassandraRoleAssignmentResource or the + result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.CassandraRoleAssignmentResource] :raises ~azure.core.exceptions.HttpResponseError: """ @overload - def begin_create_update_cassandra_view( + def begin_create_update_cassandra_role_assignment( # pylint: disable=name-too-long self, resource_group_name: str, account_name: str, - keyspace_name: str, - view_name: str, - create_update_cassandra_view_parameters: IO[bytes], + role_assignment_id: str, + create_update_cassandra_role_assignment_parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> LROPoller[_models.CassandraViewGetResults]: - """Create or update an Azure Cosmos DB Cassandra View. + ) -> LROPoller[_models.CassandraRoleAssignmentResource]: + """Creates or updates an Azure Cosmos DB Cassandra Role Assignment. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param keyspace_name: Cosmos DB keyspace name. Required. - :type keyspace_name: str - :param view_name: Cosmos DB view name. Required. - :type view_name: str - :param create_update_cassandra_view_parameters: The parameters to provide for the current - Cassandra View. Required. - :type create_update_cassandra_view_parameters: IO[bytes] + :param role_assignment_id: The GUID for the Role Assignment. Required. + :type role_assignment_id: str + :param create_update_cassandra_role_assignment_parameters: The properties required to create or + update a Role Assignment. Required. + :type create_update_cassandra_role_assignment_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 CassandraViewGetResults or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.CassandraViewGetResults] + :return: An instance of LROPoller that returns either CassandraRoleAssignmentResource or the + result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.CassandraRoleAssignmentResource] :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace - def begin_create_update_cassandra_view( + def begin_create_update_cassandra_role_assignment( # pylint: disable=name-too-long self, resource_group_name: str, account_name: str, - keyspace_name: str, - view_name: str, - create_update_cassandra_view_parameters: Union[_models.CassandraViewCreateUpdateParameters, IO[bytes]], + role_assignment_id: str, + create_update_cassandra_role_assignment_parameters: Union[_models.CassandraRoleAssignmentResource, IO[bytes]], **kwargs: Any - ) -> LROPoller[_models.CassandraViewGetResults]: - """Create or update an Azure Cosmos DB Cassandra View. + ) -> LROPoller[_models.CassandraRoleAssignmentResource]: + """Creates or updates an Azure Cosmos DB Cassandra Role Assignment. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param keyspace_name: Cosmos DB keyspace name. Required. - :type keyspace_name: str - :param view_name: Cosmos DB view name. Required. - :type view_name: str - :param create_update_cassandra_view_parameters: The parameters to provide for the current - Cassandra View. Is either a CassandraViewCreateUpdateParameters type or a IO[bytes] type. + :param role_assignment_id: The GUID for the Role Assignment. Required. + :type role_assignment_id: str + :param create_update_cassandra_role_assignment_parameters: The properties required to create or + update a Role Assignment. Is either a CassandraRoleAssignmentResource type or a IO[bytes] type. Required. - :type create_update_cassandra_view_parameters: - ~azure.mgmt.cosmosdb.models.CassandraViewCreateUpdateParameters or IO[bytes] - :return: An instance of LROPoller that returns either CassandraViewGetResults or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.CassandraViewGetResults] + :type create_update_cassandra_role_assignment_parameters: + ~azure.mgmt.cosmosdb.models.CassandraRoleAssignmentResource or IO[bytes] + :return: An instance of LROPoller that returns either CassandraRoleAssignmentResource or the + result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.CassandraRoleAssignmentResource] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -4638,17 +4816,16 @@ def begin_create_update_cassandra_view( 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.CassandraViewGetResults] = kwargs.pop("cls", None) + cls: ClsType[_models.CassandraRoleAssignmentResource] = 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_update_cassandra_view_initial( + raw_result = self._create_update_cassandra_role_assignment_initial( resource_group_name=resource_group_name, account_name=account_name, - keyspace_name=keyspace_name, - view_name=view_name, - create_update_cassandra_view_parameters=create_update_cassandra_view_parameters, + role_assignment_id=role_assignment_id, + create_update_cassandra_role_assignment_parameters=create_update_cassandra_role_assignment_parameters, api_version=api_version, content_type=content_type, cls=lambda x, y, z: x, @@ -4660,30 +4837,32 @@ def begin_create_update_cassandra_view( kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("CassandraViewGetResults", pipeline_response.http_response) + deserialized = self._deserialize("CassandraRoleAssignmentResource", 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, **kwargs)) + 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.CassandraViewGetResults].from_continuation_token( + return LROPoller[_models.CassandraRoleAssignmentResource].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller[_models.CassandraViewGetResults]( + return LROPoller[_models.CassandraRoleAssignmentResource]( self._client, raw_result, get_long_running_output, polling_method # type: ignore ) - def _delete_cassandra_view_initial( - self, resource_group_name: str, account_name: str, keyspace_name: str, view_name: str, **kwargs: Any + def _delete_cassandra_role_assignment_initial( # pylint: disable=name-too-long + self, resource_group_name: str, account_name: str, role_assignment_id: str, **kwargs: Any ) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -4699,11 +4878,10 @@ def _delete_cassandra_view_initial( 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_cassandra_view_request( + _request = build_delete_cassandra_role_assignment_request( resource_group_name=resource_group_name, account_name=account_name, - keyspace_name=keyspace_name, - view_name=view_name, + role_assignment_id=role_assignment_id, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, @@ -4725,14 +4903,18 @@ def _delete_cassandra_view_initial( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + 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["azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("azure-AsyncOperation") + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") ) - response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) @@ -4742,20 +4924,18 @@ def _delete_cassandra_view_initial( return deserialized # type: ignore @distributed_trace - def begin_delete_cassandra_view( - self, resource_group_name: str, account_name: str, keyspace_name: str, view_name: str, **kwargs: Any + def begin_delete_cassandra_role_assignment( + self, resource_group_name: str, account_name: str, role_assignment_id: str, **kwargs: Any ) -> LROPoller[None]: - """Deletes an existing Azure Cosmos DB Cassandra view. + """Deletes an existing Azure Cosmos DB Cassandra Role Assignment. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param keyspace_name: Cosmos DB keyspace name. Required. - :type keyspace_name: str - :param view_name: Cosmos DB view name. Required. - :type view_name: str + :param role_assignment_id: The GUID for the Role Assignment. Required. + :type role_assignment_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: @@ -4769,11 +4949,10 @@ def begin_delete_cassandra_view( 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_cassandra_view_initial( + raw_result = self._delete_cassandra_role_assignment_initial( resource_group_name=resource_group_name, account_name=account_name, - keyspace_name=keyspace_name, - view_name=view_name, + role_assignment_id=role_assignment_id, api_version=api_version, cls=lambda x, y, z: x, headers=_headers, @@ -4788,7 +4967,9 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- return cls(pipeline_response, None, {}) # type: ignore if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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: @@ -4803,23 +4984,110 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore @distributed_trace - def get_cassandra_view_throughput( - self, resource_group_name: str, account_name: str, keyspace_name: str, view_name: str, **kwargs: Any - ) -> _models.ThroughputSettingsGetResults: - """Gets the RUs per second of the Cassandra view under an existing Azure Cosmos DB database - account with the provided name. + def list_cassandra_role_definitions( + self, resource_group_name: str, account_name: str, **kwargs: Any + ) -> ItemPaged["_models.CassandraRoleDefinitionResource"]: + """Retrieves the list of all Azure Cosmos DB Cassandra Role Definitions. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param keyspace_name: Cosmos DB keyspace name. Required. - :type keyspace_name: str - :param view_name: Cosmos DB view name. Required. - :type view_name: str - :return: ThroughputSettingsGetResults or the result of cls(response) - :rtype: ~azure.mgmt.cosmosdb.models.ThroughputSettingsGetResults + :return: An iterator like instance of either CassandraRoleDefinitionResource or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.cosmosdb.models.CassandraRoleDefinitionResource] + :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.CassandraRoleDefinitionListResult] = 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_cassandra_role_definitions_request( + resource_group_name=resource_group_name, + account_name=account_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("CassandraRoleDefinitionListResult", 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_cassandra_role_definition( + self, resource_group_name: str, account_name: str, role_definition_id: str, **kwargs: Any + ) -> _models.CassandraRoleDefinitionResource: + """Retrieves the properties of an existing Azure Cosmos DB Cassandra Role Definition with the + given Id. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param role_definition_id: The GUID for the Role Definition. Required. + :type role_definition_id: str + :return: CassandraRoleDefinitionResource or the result of cls(response) + :rtype: ~azure.mgmt.cosmosdb.models.CassandraRoleDefinitionResource :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -4834,13 +5102,12 @@ def get_cassandra_view_throughput( _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.ThroughputSettingsGetResults] = kwargs.pop("cls", None) + cls: ClsType[_models.CassandraRoleDefinitionResource] = kwargs.pop("cls", None) - _request = build_get_cassandra_view_throughput_request( + _request = build_get_cassandra_role_definition_request( resource_group_name=resource_group_name, account_name=account_name, - keyspace_name=keyspace_name, - view_name=view_name, + role_definition_id=role_definition_id, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, @@ -4857,22 +5124,25 @@ def get_cassandra_view_throughput( if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("ThroughputSettingsGetResults", pipeline_response.http_response) + deserialized = self._deserialize("CassandraRoleDefinitionResource", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - def _update_cassandra_view_throughput_initial( # pylint: disable=name-too-long + def _create_update_cassandra_role_definition_initial( # pylint: disable=name-too-long self, resource_group_name: str, account_name: str, - keyspace_name: str, - view_name: str, - update_throughput_parameters: Union[_models.ThroughputSettingsUpdateParameters, IO[bytes]], + role_definition_id: str, + create_update_cassandra_role_definition_parameters: Union[_models.CassandraRoleDefinitionResource, IO[bytes]], **kwargs: Any ) -> Iterator[bytes]: error_map: MutableMapping = { @@ -4893,16 +5163,17 @@ def _update_cassandra_view_throughput_initial( # pylint: disable=name-too-long content_type = content_type or "application/json" _json = None _content = None - if isinstance(update_throughput_parameters, (IOBase, bytes)): - _content = update_throughput_parameters + if isinstance(create_update_cassandra_role_definition_parameters, (IOBase, bytes)): + _content = create_update_cassandra_role_definition_parameters else: - _json = self._serialize.body(update_throughput_parameters, "ThroughputSettingsUpdateParameters") + _json = self._serialize.body( + create_update_cassandra_role_definition_parameters, "CassandraRoleDefinitionResource" + ) - _request = build_update_cassandra_view_throughput_request( + _request = build_create_update_cassandra_role_definition_request( resource_group_name=resource_group_name, account_name=account_name, - keyspace_name=keyspace_name, - view_name=view_name, + role_definition_id=role_definition_id, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, @@ -4927,14 +5198,19 @@ def _update_cassandra_view_throughput_initial( # pylint: disable=name-too-long except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + 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["azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("azure-AsyncOperation") + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") ) - response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) @@ -4944,105 +5220,99 @@ def _update_cassandra_view_throughput_initial( # pylint: disable=name-too-long return deserialized # type: ignore @overload - def begin_update_cassandra_view_throughput( + def begin_create_update_cassandra_role_definition( # pylint: disable=name-too-long self, resource_group_name: str, account_name: str, - keyspace_name: str, - view_name: str, - update_throughput_parameters: _models.ThroughputSettingsUpdateParameters, + role_definition_id: str, + create_update_cassandra_role_definition_parameters: _models.CassandraRoleDefinitionResource, *, content_type: str = "application/json", **kwargs: Any - ) -> LROPoller[_models.ThroughputSettingsGetResults]: - """Update RUs per second of an Azure Cosmos DB Cassandra view. + ) -> LROPoller[_models.CassandraRoleDefinitionResource]: + """Creates or updates an Azure Cosmos DB Cassandra Role Definition. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param keyspace_name: Cosmos DB keyspace name. Required. - :type keyspace_name: str - :param view_name: Cosmos DB view name. Required. - :type view_name: str - :param update_throughput_parameters: The RUs per second of the parameters to provide for the - current Cassandra view. Required. - :type update_throughput_parameters: - ~azure.mgmt.cosmosdb.models.ThroughputSettingsUpdateParameters + :param role_definition_id: The GUID for the Role Definition. Required. + :type role_definition_id: str + :param create_update_cassandra_role_definition_parameters: The properties required to create or + update a Role Definition. Required. + :type create_update_cassandra_role_definition_parameters: + ~azure.mgmt.cosmosdb.models.CassandraRoleDefinitionResource :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 ThroughputSettingsGetResults or the + :return: An instance of LROPoller that returns either CassandraRoleDefinitionResource or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.ThroughputSettingsGetResults] + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.CassandraRoleDefinitionResource] :raises ~azure.core.exceptions.HttpResponseError: """ @overload - def begin_update_cassandra_view_throughput( + def begin_create_update_cassandra_role_definition( # pylint: disable=name-too-long self, resource_group_name: str, account_name: str, - keyspace_name: str, - view_name: str, - update_throughput_parameters: IO[bytes], + role_definition_id: str, + create_update_cassandra_role_definition_parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> LROPoller[_models.ThroughputSettingsGetResults]: - """Update RUs per second of an Azure Cosmos DB Cassandra view. + ) -> LROPoller[_models.CassandraRoleDefinitionResource]: + """Creates or updates an Azure Cosmos DB Cassandra Role Definition. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param keyspace_name: Cosmos DB keyspace name. Required. - :type keyspace_name: str - :param view_name: Cosmos DB view name. Required. - :type view_name: str - :param update_throughput_parameters: The RUs per second of the parameters to provide for the - current Cassandra view. Required. - :type update_throughput_parameters: IO[bytes] + :param role_definition_id: The GUID for the Role Definition. Required. + :type role_definition_id: str + :param create_update_cassandra_role_definition_parameters: The properties required to create or + update a Role Definition. Required. + :type create_update_cassandra_role_definition_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 ThroughputSettingsGetResults or the + :return: An instance of LROPoller that returns either CassandraRoleDefinitionResource or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.ThroughputSettingsGetResults] + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.CassandraRoleDefinitionResource] :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace - def begin_update_cassandra_view_throughput( + def begin_create_update_cassandra_role_definition( # pylint: disable=name-too-long self, resource_group_name: str, account_name: str, - keyspace_name: str, - view_name: str, - update_throughput_parameters: Union[_models.ThroughputSettingsUpdateParameters, IO[bytes]], + role_definition_id: str, + create_update_cassandra_role_definition_parameters: Union[_models.CassandraRoleDefinitionResource, IO[bytes]], **kwargs: Any - ) -> LROPoller[_models.ThroughputSettingsGetResults]: - """Update RUs per second of an Azure Cosmos DB Cassandra view. + ) -> LROPoller[_models.CassandraRoleDefinitionResource]: + """Creates or updates an Azure Cosmos DB Cassandra Role Definition. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param keyspace_name: Cosmos DB keyspace name. Required. - :type keyspace_name: str - :param view_name: Cosmos DB view name. Required. - :type view_name: str - :param update_throughput_parameters: The RUs per second of the parameters to provide for the - current Cassandra view. Is either a ThroughputSettingsUpdateParameters type or a IO[bytes] - type. Required. - :type update_throughput_parameters: - ~azure.mgmt.cosmosdb.models.ThroughputSettingsUpdateParameters or IO[bytes] - :return: An instance of LROPoller that returns either ThroughputSettingsGetResults or the + :param role_definition_id: The GUID for the Role Definition. Required. + :type role_definition_id: str + :param create_update_cassandra_role_definition_parameters: The properties required to create or + update a Role Definition. Is either a CassandraRoleDefinitionResource type or a IO[bytes] type. + Required. + :type create_update_cassandra_role_definition_parameters: + ~azure.mgmt.cosmosdb.models.CassandraRoleDefinitionResource or IO[bytes] + :return: An instance of LROPoller that returns either CassandraRoleDefinitionResource or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.ThroughputSettingsGetResults] + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.CassandraRoleDefinitionResource] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -5050,17 +5320,16 @@ def begin_update_cassandra_view_throughput( 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.ThroughputSettingsGetResults] = kwargs.pop("cls", None) + cls: ClsType[_models.CassandraRoleDefinitionResource] = 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_cassandra_view_throughput_initial( + raw_result = self._create_update_cassandra_role_definition_initial( resource_group_name=resource_group_name, account_name=account_name, - keyspace_name=keyspace_name, - view_name=view_name, - update_throughput_parameters=update_throughput_parameters, + role_definition_id=role_definition_id, + create_update_cassandra_role_definition_parameters=create_update_cassandra_role_definition_parameters, api_version=api_version, content_type=content_type, cls=lambda x, y, z: x, @@ -5072,155 +5341,32 @@ def begin_update_cassandra_view_throughput( kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ThroughputSettingsGetResults", pipeline_response.http_response) + deserialized = self._deserialize("CassandraRoleDefinitionResource", 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, **kwargs)) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[_models.ThroughputSettingsGetResults].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) ) - return LROPoller[_models.ThroughputSettingsGetResults]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _migrate_cassandra_view_to_autoscale_initial( # pylint: disable=name-too-long - self, resource_group_name: str, account_name: str, keyspace_name: str, view_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_migrate_cassandra_view_to_autoscale_request( - resource_group_name=resource_group_name, - account_name=account_name, - keyspace_name=keyspace_name, - view_name=view_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) - raise HttpResponseError(response=response, 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")) - - 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_migrate_cassandra_view_to_autoscale( # pylint: disable=name-too-long - self, resource_group_name: str, account_name: str, keyspace_name: str, view_name: str, **kwargs: Any - ) -> LROPoller[_models.ThroughputSettingsGetResults]: - """Migrate an Azure Cosmos DB Cassandra view from manual throughput to autoscale. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param account_name: Cosmos DB database account name. Required. - :type account_name: str - :param keyspace_name: Cosmos DB keyspace name. Required. - :type keyspace_name: str - :param view_name: Cosmos DB view name. Required. - :type view_name: str - :return: An instance of LROPoller that returns either ThroughputSettingsGetResults or the - result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.ThroughputSettingsGetResults] - :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.ThroughputSettingsGetResults] = 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_cassandra_view_to_autoscale_initial( - resource_group_name=resource_group_name, - account_name=account_name, - keyspace_name=keyspace_name, - view_name=view_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("ThroughputSettingsGetResults", 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, **kwargs)) elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: - return LROPoller[_models.ThroughputSettingsGetResults].from_continuation_token( + return LROPoller[_models.CassandraRoleDefinitionResource].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller[_models.ThroughputSettingsGetResults]( + return LROPoller[_models.CassandraRoleDefinitionResource]( self._client, raw_result, get_long_running_output, polling_method # type: ignore ) - def _migrate_cassandra_view_to_manual_throughput_initial( # pylint: disable=name-too-long - self, resource_group_name: str, account_name: str, keyspace_name: str, view_name: str, **kwargs: Any + def _delete_cassandra_role_definition_initial( # pylint: disable=name-too-long + self, resource_group_name: str, account_name: str, role_definition_id: str, **kwargs: Any ) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -5236,11 +5382,10 @@ def _migrate_cassandra_view_to_manual_throughput_initial( # pylint: disable=nam 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_migrate_cassandra_view_to_manual_throughput_request( + _request = build_delete_cassandra_role_definition_request( resource_group_name=resource_group_name, account_name=account_name, - keyspace_name=keyspace_name, - view_name=view_name, + role_definition_id=role_definition_id, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, @@ -5256,20 +5401,24 @@ def _migrate_cassandra_view_to_manual_throughput_initial( # pylint: disable=nam response = pipeline_response.http_response - if response.status_code not in [200, 202]: + if response.status_code not in [200, 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + 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["azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("azure-AsyncOperation") + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") ) - response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) @@ -5279,39 +5428,35 @@ def _migrate_cassandra_view_to_manual_throughput_initial( # pylint: disable=nam return deserialized # type: ignore @distributed_trace - def begin_migrate_cassandra_view_to_manual_throughput( # pylint: disable=name-too-long - self, resource_group_name: str, account_name: str, keyspace_name: str, view_name: str, **kwargs: Any - ) -> LROPoller[_models.ThroughputSettingsGetResults]: - """Migrate an Azure Cosmos DB Cassandra view from autoscale to manual throughput. + def begin_delete_cassandra_role_definition( + self, resource_group_name: str, account_name: str, role_definition_id: str, **kwargs: Any + ) -> LROPoller[None]: + """Deletes an existing Azure Cosmos DB Cassandra Role Definition. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param keyspace_name: Cosmos DB keyspace name. Required. - :type keyspace_name: str - :param view_name: Cosmos DB view name. Required. - :type view_name: str - :return: An instance of LROPoller that returns either ThroughputSettingsGetResults or the - result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.ThroughputSettingsGetResults] + :param role_definition_id: The GUID for the Role Definition. Required. + :type role_definition_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[_models.ThroughputSettingsGetResults] = kwargs.pop("cls", 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._migrate_cassandra_view_to_manual_throughput_initial( + raw_result = self._delete_cassandra_role_definition_initial( resource_group_name=resource_group_name, account_name=account_name, - keyspace_name=keyspace_name, - view_name=view_name, + role_definition_id=role_definition_id, api_version=api_version, cls=lambda x, y, z: x, headers=_headers, @@ -5321,25 +5466,23 @@ def begin_migrate_cassandra_view_to_manual_throughput( # pylint: disable=name-t raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ThroughputSettingsGetResults", pipeline_response.http_response) + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return cls(pipeline_response, None, {}) # type: ignore if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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.ThroughputSettingsGetResults].from_continuation_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[_models.ThroughputSettingsGetResults]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/operations/_chaos_fault_operations.py b/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/operations/_chaos_fault_operations.py index a91cfe84b55..87c22800fed 100644 --- a/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/operations/_chaos_fault_operations.py +++ b/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/operations/_chaos_fault_operations.py @@ -47,7 +47,7 @@ def build_list_request(resource_group_name: str, account_name: str, subscription _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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -76,14 +76,13 @@ def build_list_request(resource_group_name: str, account_name: str, subscription return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_enable_disable_request( +def build_get_request( resource_group_name: str, account_name: str, chaos_fault: 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-11-01-preview")) - 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-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -108,20 +107,19 @@ def build_enable_disable_request( _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) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_get_request( +def build_enable_disable_request( resource_group_name: str, account_name: str, chaos_fault: 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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -146,9 +144,11 @@ def build_get_request( _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="GET", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) class ChaosFaultOperations: @@ -257,6 +257,70 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) + @distributed_trace + def get( + self, resource_group_name: str, account_name: str, chaos_fault: str, **kwargs: Any + ) -> _models.ChaosFaultResource: + """Get Chaos Fault for a CosmosdB account for a particular Chaos Fault. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param chaos_fault: The name of the ChaosFault. Required. + :type chaos_fault: str + :return: ChaosFaultResource or the result of cls(response) + :rtype: ~azure.mgmt.cosmosdb.models.ChaosFaultResource + :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.ChaosFaultResource] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + account_name=account_name, + chaos_fault=chaos_fault, + 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("ChaosFaultResource", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + def _enable_disable_initial( self, resource_group_name: str, @@ -322,10 +386,15 @@ def _enable_disable_initial( ) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + response_headers = {} + if response.status_code == 201: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @@ -466,67 +535,3 @@ def get_long_running_output(pipeline_response): return LROPoller[_models.ChaosFaultResource]( self._client, raw_result, get_long_running_output, polling_method # type: ignore ) - - @distributed_trace - def get( - self, resource_group_name: str, account_name: str, chaos_fault: str, **kwargs: Any - ) -> _models.ChaosFaultResource: - """Get Chaos Fault for a CosmosdB account for a particular Chaos Fault. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param account_name: Cosmos DB database account name. Required. - :type account_name: str - :param chaos_fault: The name of the ChaosFault. Required. - :type chaos_fault: str - :return: ChaosFaultResource or the result of cls(response) - :rtype: ~azure.mgmt.cosmosdb.models.ChaosFaultResource - :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.ChaosFaultResource] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - account_name=account_name, - chaos_fault=chaos_fault, - 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("ChaosFaultResource", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/operations/_collection_operations.py b/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/operations/_collection_operations.py index d68ca0778b7..8273528069a 100644 --- a/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/operations/_collection_operations.py +++ b/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/operations/_collection_operations.py @@ -38,26 +38,24 @@ _SERIALIZER.client_side_validation = False -def build_list_metrics_request( +def build_list_metric_definitions_request( resource_group_name: str, account_name: str, database_rid: str, collection_rid: str, subscription_id: str, - *, - filter: 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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/databases/{databaseRid}/collections/{collectionRid}/metrics", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/databases/{databaseRid}/collections/{collectionRid}/metricDefinitions", ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), @@ -75,7 +73,6 @@ def build_list_metrics_request( # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - _params["$filter"] = _SERIALIZER.query("filter", filter, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") @@ -83,26 +80,26 @@ def build_list_metrics_request( return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_usages_request( +def build_list_metrics_request( resource_group_name: str, account_name: str, database_rid: str, collection_rid: str, subscription_id: str, *, - filter: Optional[str] = None, + filter: 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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/databases/{databaseRid}/collections/{collectionRid}/usages", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/databases/{databaseRid}/collections/{collectionRid}/metrics", ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), @@ -120,8 +117,7 @@ def build_list_usages_request( # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - if filter is not None: - _params["$filter"] = _SERIALIZER.query("filter", filter, "str") + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") @@ -129,24 +125,26 @@ def build_list_usages_request( return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_metric_definitions_request( +def build_list_usages_request( resource_group_name: str, account_name: str, database_rid: str, collection_rid: str, subscription_id: str, + *, + filter: Optional[str] = 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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/databases/{databaseRid}/collections/{collectionRid}/metricDefinitions", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/databases/{databaseRid}/collections/{collectionRid}/usages", ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), @@ -164,6 +162,8 @@ def build_list_metric_definitions_request( # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if filter is not None: + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") @@ -191,17 +191,10 @@ def __init__(self, *args, **kwargs) -> None: self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def list_metrics( - self, - resource_group_name: str, - account_name: str, - database_rid: str, - collection_rid: str, - filter: str, - **kwargs: Any - ) -> ItemPaged["_models.Metric"]: - """Retrieves the metrics determined by the given filter for the given database account and - collection. + def list_metric_definitions( + self, resource_group_name: str, account_name: str, database_rid: str, collection_rid: str, **kwargs: Any + ) -> ItemPaged["_models.MetricDefinition"]: + """Retrieves metric definitions for the given collection. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -212,19 +205,15 @@ def list_metrics( :type database_rid: str :param collection_rid: Cosmos DB collection rid. Required. :type collection_rid: str - :param filter: An OData filter expression that describes a subset of metrics to return. The - parameters that can be filtered are name.value (name of the metric, can have an or of multiple - names), startTime, endTime, and timeGrain. The supported operator is eq. Required. - :type filter: str - :return: An iterator like instance of either Metric or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cosmosdb.models.Metric] + :return: An iterator like instance of either MetricDefinition or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cosmosdb.models.MetricDefinition] :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.MetricListResult] = kwargs.pop("cls", None) + cls: ClsType[_models.MetricDefinitionsListResult] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -237,13 +226,12 @@ def list_metrics( def prepare_request(next_link=None): if not next_link: - _request = build_list_metrics_request( + _request = build_list_metric_definitions_request( resource_group_name=resource_group_name, account_name=account_name, database_rid=database_rid, collection_rid=collection_rid, subscription_id=self._config.subscription_id, - filter=filter, api_version=api_version, headers=_headers, params=_params, @@ -268,11 +256,11 @@ def prepare_request(next_link=None): return _request def extract_data(pipeline_response): - deserialized = self._deserialize("MetricListResult", pipeline_response) + deserialized = self._deserialize("MetricDefinitionsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore - return None, iter(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): _request = prepare_request(next_link) @@ -285,23 +273,28 @@ 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + 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_usages( + def list_metrics( self, resource_group_name: str, account_name: str, database_rid: str, collection_rid: str, - filter: Optional[str] = None, + filter: str, **kwargs: Any - ) -> ItemPaged["_models.Usage"]: - """Retrieves the usages (most recent storage data) for the given collection. + ) -> ItemPaged["_models.Metric"]: + """Retrieves the metrics determined by the given filter for the given database account and + collection. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -312,19 +305,19 @@ def list_usages( :type database_rid: str :param collection_rid: Cosmos DB collection rid. Required. :type collection_rid: str - :param filter: An OData filter expression that describes a subset of usages to return. The - supported parameter is name.value (name of the metric, can have an or of multiple names). - Default value is None. + :param filter: An OData filter expression that describes a subset of metrics to return. The + parameters that can be filtered are name.value (name of the metric, can have an or of multiple + names), startTime, endTime, and timeGrain. The supported operator is eq. Required. :type filter: str - :return: An iterator like instance of either Usage or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cosmosdb.models.Usage] + :return: An iterator like instance of either Metric or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cosmosdb.models.Metric] :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.UsagesResult] = kwargs.pop("cls", None) + cls: ClsType[_models.MetricListResult] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -337,7 +330,7 @@ def list_usages( def prepare_request(next_link=None): if not next_link: - _request = build_list_usages_request( + _request = build_list_metrics_request( resource_group_name=resource_group_name, account_name=account_name, database_rid=database_rid, @@ -368,11 +361,11 @@ def prepare_request(next_link=None): return _request def extract_data(pipeline_response): - deserialized = self._deserialize("UsagesResult", pipeline_response) + deserialized = self._deserialize("MetricListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore - return None, iter(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): _request = prepare_request(next_link) @@ -385,17 +378,27 @@ 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + 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_metric_definitions( - self, resource_group_name: str, account_name: str, database_rid: str, collection_rid: str, **kwargs: Any - ) -> ItemPaged["_models.MetricDefinition"]: - """Retrieves metric definitions for the given collection. + def list_usages( + self, + resource_group_name: str, + account_name: str, + database_rid: str, + collection_rid: str, + filter: Optional[str] = None, + **kwargs: Any + ) -> ItemPaged["_models.Usage"]: + """Retrieves the usages (most recent storage data) for the given collection. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -406,15 +409,19 @@ def list_metric_definitions( :type database_rid: str :param collection_rid: Cosmos DB collection rid. Required. :type collection_rid: str - :return: An iterator like instance of either MetricDefinition or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cosmosdb.models.MetricDefinition] + :param filter: An OData filter expression that describes a subset of usages to return. The + supported parameter is name.value (name of the metric, can have an or of multiple names). + Default value is None. + :type filter: str + :return: An iterator like instance of either Usage or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cosmosdb.models.Usage] :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.MetricDefinitionsListResult] = kwargs.pop("cls", None) + cls: ClsType[_models.UsagesResult] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -427,12 +434,13 @@ def list_metric_definitions( def prepare_request(next_link=None): if not next_link: - _request = build_list_metric_definitions_request( + _request = build_list_usages_request( resource_group_name=resource_group_name, account_name=account_name, database_rid=database_rid, collection_rid=collection_rid, subscription_id=self._config.subscription_id, + filter=filter, api_version=api_version, headers=_headers, params=_params, @@ -457,11 +465,11 @@ def prepare_request(next_link=None): return _request def extract_data(pipeline_response): - deserialized = self._deserialize("MetricDefinitionsListResult", pipeline_response) + deserialized = self._deserialize("UsagesResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore - return None, iter(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): _request = prepare_request(next_link) @@ -474,7 +482,11 @@ 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response diff --git a/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/operations/_collection_partition_operations.py b/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/operations/_collection_partition_operations.py index 60e0f438994..667c389eb9a 100644 --- a/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/operations/_collection_partition_operations.py +++ b/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/operations/_collection_partition_operations.py @@ -51,7 +51,7 @@ def build_list_metrics_request( _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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -96,7 +96,7 @@ def build_list_usages_request( _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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -230,7 +230,7 @@ def extract_data(pipeline_response): list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore - return None, iter(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): _request = prepare_request(next_link) @@ -243,7 +243,11 @@ 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response @@ -330,7 +334,7 @@ def extract_data(pipeline_response): list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore - return None, iter(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): _request = prepare_request(next_link) @@ -343,7 +347,11 @@ 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response diff --git a/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/operations/_collection_partition_region_operations.py b/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/operations/_collection_partition_region_operations.py index eb573375986..5b9c9a7b405 100644 --- a/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/operations/_collection_partition_region_operations.py +++ b/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/operations/_collection_partition_region_operations.py @@ -52,7 +52,7 @@ def build_list_metrics_request( _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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -190,7 +190,7 @@ def extract_data(pipeline_response): list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore - return None, iter(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): _request = prepare_request(next_link) @@ -203,7 +203,11 @@ 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response diff --git a/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/operations/_collection_region_operations.py b/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/operations/_collection_region_operations.py index 052e4c87dc5..bfcbf4cead9 100644 --- a/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/operations/_collection_region_operations.py +++ b/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/operations/_collection_region_operations.py @@ -52,7 +52,7 @@ def build_list_metrics_request( _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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -190,7 +190,7 @@ def extract_data(pipeline_response): list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore - return None, iter(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): _request = prepare_request(next_link) @@ -203,7 +203,11 @@ 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response diff --git a/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/operations/_copy_jobs_operations.py b/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/operations/_copy_jobs_operations.py index 6a17fc43c9b..3d4a4b03be7 100644 --- a/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/operations/_copy_jobs_operations.py +++ b/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/operations/_copy_jobs_operations.py @@ -39,20 +39,19 @@ _SERIALIZER.client_side_validation = False -def build_create_request( - resource_group_name: str, account_name: str, job_name: str, subscription_id: str, **kwargs: Any +def build_list_by_database_account_request( + resource_group_name: str, account_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-11-01-preview")) - 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-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/copyJobs/{jobName}", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/copyJobs", ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), @@ -62,7 +61,6 @@ def build_create_request( "accountName": _SERIALIZER.url( "account_name", account_name, "str", max_length=50, min_length=3, pattern=r"^[a-z0-9]+(-[a-z0-9]+)*" ), - "jobName": _SERIALIZER.url("job_name", job_name, "str", pattern=r"^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*$"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -71,11 +69,9 @@ def build_create_request( _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) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( @@ -84,7 +80,7 @@ def build_get_request( _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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -114,19 +110,20 @@ def build_get_request( return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_pause_request( +def build_create_request( resource_group_name: str, account_name: str, job_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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) + 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.DocumentDB/databaseAccounts/{accountName}/copyJobs/{jobName}/pause", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/copyJobs/{jobName}", ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), @@ -145,24 +142,26 @@ def build_pause_request( _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) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_resume_request( +def build_cancel_request( resource_group_name: str, account_name: str, job_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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/copyJobs/{jobName}/resume", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/copyJobs/{jobName}/cancel", ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), @@ -186,19 +185,19 @@ def build_resume_request( return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_cancel_request( +def build_complete_request( resource_group_name: str, account_name: str, job_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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/copyJobs/{jobName}/cancel", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/copyJobs/{jobName}/complete", ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), @@ -222,19 +221,19 @@ def build_cancel_request( return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_complete_request( +def build_pause_request( resource_group_name: str, account_name: str, job_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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/copyJobs/{jobName}/complete", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/copyJobs/{jobName}/pause", ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), @@ -258,19 +257,19 @@ def build_complete_request( return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_by_database_account_request( - resource_group_name: str, account_name: str, subscription_id: str, **kwargs: Any +def build_resume_request( + resource_group_name: str, account_name: str, job_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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/copyJobs", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/copyJobs/{jobName}/resume", ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), @@ -280,6 +279,7 @@ def build_list_by_database_account_request( "accountName": _SERIALIZER.url( "account_name", account_name, "str", max_length=50, min_length=3, pattern=r"^[a-z0-9]+(-[a-z0-9]+)*" ), + "jobName": _SERIALIZER.url("job_name", job_name, "str", pattern=r"^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*$"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -290,7 +290,7 @@ def build_list_by_database_account_request( # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) class CopyJobsOperations: @@ -312,6 +312,149 @@ def __init__(self, *args, **kwargs) -> None: 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_database_account( + self, resource_group_name: str, account_name: str, **kwargs: Any + ) -> ItemPaged["_models.CopyJobGetResults"]: + """Get a list of Copy jobs. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :return: An iterator like instance of either CopyJobGetResults or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cosmosdb.models.CopyJobGetResults] + :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.CopyJobFeedResults] = 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_database_account_request( + resource_group_name=resource_group_name, + account_name=account_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("CopyJobFeedResults", 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def get( + self, resource_group_name: str, account_name: str, job_name: str, **kwargs: Any + ) -> _models.CopyJobGetResults: + """Get a Copy Job. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param job_name: Name of the Copy Job. Required. + :type job_name: str + :return: CopyJobGetResults or the result of cls(response) + :rtype: ~azure.mgmt.cosmosdb.models.CopyJobGetResults + :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.CopyJobGetResults] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + account_name=account_name, + job_name=job_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("CopyJobGetResults", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + @overload def create( self, @@ -452,70 +595,10 @@ def create( return deserialized # type: ignore @distributed_trace - def get( - self, resource_group_name: str, account_name: str, job_name: str, **kwargs: Any - ) -> _models.CopyJobGetResults: - """Get a Copy Job. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param account_name: Cosmos DB database account name. Required. - :type account_name: str - :param job_name: Name of the Copy Job. Required. - :type job_name: str - :return: CopyJobGetResults or the result of cls(response) - :rtype: ~azure.mgmt.cosmosdb.models.CopyJobGetResults - :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.CopyJobGetResults] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - account_name=account_name, - job_name=job_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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("CopyJobGetResults", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def pause( + def cancel( self, resource_group_name: str, account_name: str, job_name: str, **kwargs: Any ) -> _models.CopyJobGetResults: - """Pause a Copy Job. + """Cancels a Copy Job. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -542,7 +625,7 @@ def pause( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.CopyJobGetResults] = kwargs.pop("cls", None) - _request = build_pause_request( + _request = build_cancel_request( resource_group_name=resource_group_name, account_name=account_name, job_name=job_name, @@ -572,10 +655,10 @@ def pause( return deserialized # type: ignore @distributed_trace - def resume( + def complete( self, resource_group_name: str, account_name: str, job_name: str, **kwargs: Any ) -> _models.CopyJobGetResults: - """Resumes a Copy Job. + """Completes an Online Copy Job. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -602,7 +685,7 @@ def resume( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.CopyJobGetResults] = kwargs.pop("cls", None) - _request = build_resume_request( + _request = build_complete_request( resource_group_name=resource_group_name, account_name=account_name, job_name=job_name, @@ -632,10 +715,10 @@ def resume( return deserialized # type: ignore @distributed_trace - def cancel( + def pause( self, resource_group_name: str, account_name: str, job_name: str, **kwargs: Any ) -> _models.CopyJobGetResults: - """Cancels a Copy Job. + """Pause a Copy Job. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -662,7 +745,7 @@ def cancel( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.CopyJobGetResults] = kwargs.pop("cls", None) - _request = build_cancel_request( + _request = build_pause_request( resource_group_name=resource_group_name, account_name=account_name, job_name=job_name, @@ -692,10 +775,10 @@ def cancel( return deserialized # type: ignore @distributed_trace - def complete( + def resume( self, resource_group_name: str, account_name: str, job_name: str, **kwargs: Any ) -> _models.CopyJobGetResults: - """Completes an Online Copy Job. + """Resumes a Copy Job. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -722,7 +805,7 @@ def complete( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.CopyJobGetResults] = kwargs.pop("cls", None) - _request = build_complete_request( + _request = build_resume_request( resource_group_name=resource_group_name, account_name=account_name, job_name=job_name, @@ -750,86 +833,3 @@ def complete( return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - - @distributed_trace - def list_by_database_account( - self, resource_group_name: str, account_name: str, **kwargs: Any - ) -> ItemPaged["_models.CopyJobGetResults"]: - """Get a list of Copy jobs. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param account_name: Cosmos DB database account name. Required. - :type account_name: str - :return: An iterator like instance of either CopyJobGetResults or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cosmosdb.models.CopyJobGetResults] - :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.CopyJobFeedResults] = 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_database_account_request( - resource_group_name=resource_group_name, - account_name=account_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("CopyJobFeedResults", 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) diff --git a/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/operations/_data_transfer_jobs_operations.py b/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/operations/_data_transfer_jobs_operations.py index a07d9b4395d..2e1f8923fda 100644 --- a/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/operations/_data_transfer_jobs_operations.py +++ b/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/operations/_data_transfer_jobs_operations.py @@ -39,20 +39,19 @@ _SERIALIZER.client_side_validation = False -def build_create_request( - resource_group_name: str, account_name: str, job_name: str, subscription_id: str, **kwargs: Any +def build_list_by_database_account_request( + resource_group_name: str, account_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-11-01-preview")) - 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-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/dataTransferJobs/{jobName}", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/dataTransferJobs", ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), @@ -62,7 +61,6 @@ def build_create_request( "accountName": _SERIALIZER.url( "account_name", account_name, "str", max_length=50, min_length=3, pattern=r"^[a-z0-9]+(-[a-z0-9]+)*" ), - "jobName": _SERIALIZER.url("job_name", job_name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -71,11 +69,9 @@ def build_create_request( _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) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( @@ -84,7 +80,7 @@ def build_get_request( _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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -100,7 +96,7 @@ def build_get_request( "accountName": _SERIALIZER.url( "account_name", account_name, "str", max_length=50, min_length=3, pattern=r"^[a-z0-9]+(-[a-z0-9]+)*" ), - "jobName": _SERIALIZER.url("job_name", job_name, "str"), + "jobName": _SERIALIZER.url("job_name", job_name, "str", pattern=r"^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*$"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -114,19 +110,20 @@ def build_get_request( return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_pause_request( +def build_create_request( resource_group_name: str, account_name: str, job_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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) + 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.DocumentDB/databaseAccounts/{accountName}/dataTransferJobs/{jobName}/pause", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/dataTransferJobs/{jobName}", ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), @@ -136,7 +133,7 @@ def build_pause_request( "accountName": _SERIALIZER.url( "account_name", account_name, "str", max_length=50, min_length=3, pattern=r"^[a-z0-9]+(-[a-z0-9]+)*" ), - "jobName": _SERIALIZER.url("job_name", job_name, "str"), + "jobName": _SERIALIZER.url("job_name", job_name, "str", pattern=r"^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*$"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -145,24 +142,26 @@ def build_pause_request( _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) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_resume_request( +def build_cancel_request( resource_group_name: str, account_name: str, job_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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/dataTransferJobs/{jobName}/resume", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/dataTransferJobs/{jobName}/cancel", ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), @@ -172,7 +171,7 @@ def build_resume_request( "accountName": _SERIALIZER.url( "account_name", account_name, "str", max_length=50, min_length=3, pattern=r"^[a-z0-9]+(-[a-z0-9]+)*" ), - "jobName": _SERIALIZER.url("job_name", job_name, "str"), + "jobName": _SERIALIZER.url("job_name", job_name, "str", pattern=r"^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*$"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -186,19 +185,19 @@ def build_resume_request( return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_cancel_request( +def build_complete_request( resource_group_name: str, account_name: str, job_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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/dataTransferJobs/{jobName}/cancel", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/dataTransferJobs/{jobName}/complete", ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), @@ -208,7 +207,7 @@ def build_cancel_request( "accountName": _SERIALIZER.url( "account_name", account_name, "str", max_length=50, min_length=3, pattern=r"^[a-z0-9]+(-[a-z0-9]+)*" ), - "jobName": _SERIALIZER.url("job_name", job_name, "str"), + "jobName": _SERIALIZER.url("job_name", job_name, "str", pattern=r"^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*$"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -222,19 +221,19 @@ def build_cancel_request( return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_complete_request( +def build_pause_request( resource_group_name: str, account_name: str, job_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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/dataTransferJobs/{jobName}/complete", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/dataTransferJobs/{jobName}/pause", ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), @@ -244,7 +243,7 @@ def build_complete_request( "accountName": _SERIALIZER.url( "account_name", account_name, "str", max_length=50, min_length=3, pattern=r"^[a-z0-9]+(-[a-z0-9]+)*" ), - "jobName": _SERIALIZER.url("job_name", job_name, "str"), + "jobName": _SERIALIZER.url("job_name", job_name, "str", pattern=r"^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*$"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -258,19 +257,19 @@ def build_complete_request( return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_by_database_account_request( - resource_group_name: str, account_name: str, subscription_id: str, **kwargs: Any +def build_resume_request( + resource_group_name: str, account_name: str, job_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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/dataTransferJobs", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/dataTransferJobs/{jobName}/resume", ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), @@ -280,6 +279,7 @@ def build_list_by_database_account_request( "accountName": _SERIALIZER.url( "account_name", account_name, "str", max_length=50, min_length=3, pattern=r"^[a-z0-9]+(-[a-z0-9]+)*" ), + "jobName": _SERIALIZER.url("job_name", job_name, "str", pattern=r"^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*$"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -290,7 +290,7 @@ def build_list_by_database_account_request( # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) class DataTransferJobsOperations: @@ -312,6 +312,150 @@ def __init__(self, *args, **kwargs) -> None: 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_database_account( + self, resource_group_name: str, account_name: str, **kwargs: Any + ) -> ItemPaged["_models.DataTransferJobGetResults"]: + """Get a list of Data Transfer jobs. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :return: An iterator like instance of either DataTransferJobGetResults or the result of + cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cosmosdb.models.DataTransferJobGetResults] + :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.DataTransferJobFeedResults] = 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_database_account_request( + resource_group_name=resource_group_name, + account_name=account_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("DataTransferJobFeedResults", 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def get( + self, resource_group_name: str, account_name: str, job_name: str, **kwargs: Any + ) -> _models.DataTransferJobGetResults: + """Get a Data Transfer Job. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param job_name: Name of the Data Transfer Job. Required. + :type job_name: str + :return: DataTransferJobGetResults or the result of cls(response) + :rtype: ~azure.mgmt.cosmosdb.models.DataTransferJobGetResults + :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.DataTransferJobGetResults] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + account_name=account_name, + job_name=job_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("DataTransferJobGetResults", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + @overload def create( self, @@ -452,70 +596,10 @@ def create( return deserialized # type: ignore @distributed_trace - def get( - self, resource_group_name: str, account_name: str, job_name: str, **kwargs: Any - ) -> _models.DataTransferJobGetResults: - """Get a Data Transfer Job. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param account_name: Cosmos DB database account name. Required. - :type account_name: str - :param job_name: Name of the Data Transfer Job. Required. - :type job_name: str - :return: DataTransferJobGetResults or the result of cls(response) - :rtype: ~azure.mgmt.cosmosdb.models.DataTransferJobGetResults - :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.DataTransferJobGetResults] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - account_name=account_name, - job_name=job_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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("DataTransferJobGetResults", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def pause( + def cancel( self, resource_group_name: str, account_name: str, job_name: str, **kwargs: Any ) -> _models.DataTransferJobGetResults: - """Pause a Data Transfer Job. + """Cancels a Data Transfer Job. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -542,7 +626,7 @@ def pause( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.DataTransferJobGetResults] = kwargs.pop("cls", None) - _request = build_pause_request( + _request = build_cancel_request( resource_group_name=resource_group_name, account_name=account_name, job_name=job_name, @@ -572,10 +656,10 @@ def pause( return deserialized # type: ignore @distributed_trace - def resume( + def complete( self, resource_group_name: str, account_name: str, job_name: str, **kwargs: Any ) -> _models.DataTransferJobGetResults: - """Resumes a Data Transfer Job. + """Completes a Data Transfer Online Job. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -602,7 +686,7 @@ def resume( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.DataTransferJobGetResults] = kwargs.pop("cls", None) - _request = build_resume_request( + _request = build_complete_request( resource_group_name=resource_group_name, account_name=account_name, job_name=job_name, @@ -632,10 +716,10 @@ def resume( return deserialized # type: ignore @distributed_trace - def cancel( + def pause( self, resource_group_name: str, account_name: str, job_name: str, **kwargs: Any ) -> _models.DataTransferJobGetResults: - """Cancels a Data Transfer Job. + """Pause a Data Transfer Job. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -662,7 +746,7 @@ def cancel( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.DataTransferJobGetResults] = kwargs.pop("cls", None) - _request = build_cancel_request( + _request = build_pause_request( resource_group_name=resource_group_name, account_name=account_name, job_name=job_name, @@ -692,10 +776,10 @@ def cancel( return deserialized # type: ignore @distributed_trace - def complete( + def resume( self, resource_group_name: str, account_name: str, job_name: str, **kwargs: Any ) -> _models.DataTransferJobGetResults: - """Completes a Data Transfer Online Job. + """Resumes a Data Transfer Job. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -722,7 +806,7 @@ def complete( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.DataTransferJobGetResults] = kwargs.pop("cls", None) - _request = build_complete_request( + _request = build_resume_request( resource_group_name=resource_group_name, account_name=account_name, job_name=job_name, @@ -750,87 +834,3 @@ def complete( return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - - @distributed_trace - def list_by_database_account( - self, resource_group_name: str, account_name: str, **kwargs: Any - ) -> ItemPaged["_models.DataTransferJobGetResults"]: - """Get a list of Data Transfer jobs. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param account_name: Cosmos DB database account name. Required. - :type account_name: str - :return: An iterator like instance of either DataTransferJobGetResults or the result of - cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cosmosdb.models.DataTransferJobGetResults] - :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.DataTransferJobFeedResults] = 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_database_account_request( - resource_group_name=resource_group_name, - account_name=account_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("DataTransferJobFeedResults", 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) diff --git a/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/operations/_database_account_region_operations.py b/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/operations/_database_account_region_operations.py index 756ed4cfd26..4893403e0f4 100644 --- a/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/operations/_database_account_region_operations.py +++ b/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/operations/_database_account_region_operations.py @@ -44,7 +44,7 @@ def build_list_metrics_request( _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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -166,7 +166,7 @@ def extract_data(pipeline_response): list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore - return None, iter(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): _request = prepare_request(next_link) @@ -179,7 +179,11 @@ 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response diff --git a/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/operations/_database_accounts_operations.py b/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/operations/_database_accounts_operations.py index b360a831efa..3fff5b0b569 100644 --- a/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/operations/_database_accounts_operations.py +++ b/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/operations/_database_accounts_operations.py @@ -43,23 +43,16 @@ _SERIALIZER.client_side_validation = False -def build_get_request(resource_group_name: str, account_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: +def build_check_name_exists_request(account_name: 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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}", - ) + _url = kwargs.pop("template_url", "/providers/Microsoft.DocumentDB/databaseAccountNames/{accountName}") 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 - ), "accountName": _SERIALIZER.url( "account_name", account_name, "str", max_length=50, min_length=3, pattern=r"^[a-z0-9]+(-[a-z0-9]+)*" ), @@ -73,32 +66,20 @@ def build_get_request(resource_group_name: str, account_name: str, subscription_ # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="HEAD", url=_url, params=_params, headers=_headers, **kwargs) -def build_update_request( - resource_group_name: str, account_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: +def build_list_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-11-01-preview")) - 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-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}", - ) + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.DocumentDB/databaseAccounts") 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 - ), - "accountName": _SERIALIZER.url( - "account_name", account_name, "str", max_length=50, min_length=3, pattern=r"^[a-z0-9]+(-[a-z0-9]+)*" - ), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -107,36 +88,28 @@ def build_update_request( _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) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_or_update_request( - resource_group_name: str, account_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: +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-11-01-preview")) - 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-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts", ) 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 ), - "accountName": _SERIALIZER.url( - "account_name", account_name, "str", max_length=50, min_length=3, pattern=r"^[a-z0-9]+(-[a-z0-9]+)*" - ), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -145,19 +118,18 @@ def build_create_or_update_request( _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) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_delete_request( - resource_group_name: str, account_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: +def build_get_request(resource_group_name: str, account_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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop( "template_url", @@ -178,21 +150,26 @@ def build_delete_request( # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_failover_priority_change_request( +def build_create_or_update_request( resource_group_name: str, account_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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) 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.DocumentDB/databaseAccounts/{accountName}/failoverPriorityChange", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}", ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), @@ -212,21 +189,34 @@ def build_failover_priority_change_request( # 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) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_request(subscription_id: str, **kwargs: Any) -> HttpRequest: +def build_update_request( + resource_group_name: str, account_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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) + 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.DocumentDB/databaseAccounts") + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}", + ) 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 + ), + "accountName": _SERIALIZER.url( + "account_name", account_name, "str", max_length=50, min_length=3, pattern=r"^[a-z0-9]+(-[a-z0-9]+)*" + ), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -235,28 +225,35 @@ def build_list_request(subscription_id: str, **kwargs: Any) -> HttpRequest: _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="GET", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_by_resource_group_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: +def build_delete_request( + resource_group_name: str, account_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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}", ) 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 ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "accountName": _SERIALIZER.url( + "account_name", account_name, "str", max_length=50, min_length=3, pattern=r"^[a-z0-9]+(-[a-z0-9]+)*" + ), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -267,22 +264,23 @@ def build_list_by_resource_group_request(resource_group_name: str, subscription_ # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_keys_request( +def build_failover_priority_change_request( resource_group_name: str, account_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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) + 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.DocumentDB/databaseAccounts/{accountName}/listKeys", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/failoverPriorityChange", ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), @@ -300,6 +298,8 @@ def build_list_keys_request( _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) @@ -311,7 +311,7 @@ def build_list_connection_strings_request( _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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -340,20 +340,19 @@ def build_list_connection_strings_request( return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_offline_region_request( +def build_list_keys_request( resource_group_name: str, account_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-11-01-preview")) - 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-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/offlineRegion", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/listKeys", ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), @@ -371,27 +370,24 @@ def build_offline_region_request( _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_online_region_request( +def build_list_metric_definitions_request( resource_group_name: str, account_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-11-01-preview")) - 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-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/onlineRegion", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/metricDefinitions", ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), @@ -409,26 +405,24 @@ def build_online_region_request( _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) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_get_read_only_keys_request( - resource_group_name: str, account_name: str, subscription_id: str, **kwargs: Any +def build_list_metrics_request( + resource_group_name: str, account_name: str, subscription_id: str, *, filter: 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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/readonlykeys", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/metrics", ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), @@ -444,6 +438,7 @@ def build_get_read_only_keys_request( # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") @@ -451,19 +446,20 @@ def build_get_read_only_keys_request( return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_read_only_keys_request( +def build_offline_region_request( resource_group_name: str, account_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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) + 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.DocumentDB/databaseAccounts/{accountName}/readonlykeys", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/offlineRegion", ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), @@ -481,23 +477,27 @@ def build_list_read_only_keys_request( _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_regenerate_key_request( +def build_online_region_request( resource_group_name: str, account_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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) 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.DocumentDB/databaseAccounts/{accountName}/regenerateKey", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/onlineRegion", ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), @@ -517,17 +517,30 @@ def build_regenerate_key_request( # 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_name_exists_request(account_name: str, **kwargs: Any) -> HttpRequest: +def build_get_read_only_keys_request( + resource_group_name: str, account_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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) + accept = _headers.pop("Accept", "application/json") + # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.DocumentDB/databaseAccountNames/{accountName}") + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/readonlykeys", + ) 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 + ), "accountName": _SERIALIZER.url( "account_name", account_name, "str", max_length=50, min_length=3, pattern=r"^[a-z0-9]+(-[a-z0-9]+)*" ), @@ -538,22 +551,25 @@ def build_check_name_exists_request(account_name: str, **kwargs: Any) -> HttpReq # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - return HttpRequest(method="HEAD", url=_url, params=_params, **kwargs) + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_metrics_request( - resource_group_name: str, account_name: str, subscription_id: str, *, filter: str, **kwargs: Any +def build_list_read_only_keys_request( + resource_group_name: str, account_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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/metrics", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/readonlykeys", ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), @@ -569,27 +585,27 @@ def build_list_metrics_request( # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - _params["$filter"] = _SERIALIZER.query("filter", filter, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_usages_request( - resource_group_name: str, account_name: str, subscription_id: str, *, filter: Optional[str] = None, **kwargs: Any +def build_regenerate_key_request( + resource_group_name: str, account_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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) + 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.DocumentDB/databaseAccounts/{accountName}/usages", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/regenerateKey", ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), @@ -605,28 +621,28 @@ def build_list_usages_request( # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - if filter is not None: - _params["$filter"] = _SERIALIZER.query("filter", filter, "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="GET", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_metric_definitions_request( - resource_group_name: str, account_name: str, subscription_id: str, **kwargs: Any +def build_list_usages_request( + resource_group_name: str, account_name: str, subscription_id: str, *, filter: Optional[str] = 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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/metricDefinitions", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/usages", ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), @@ -642,6 +658,8 @@ def build_list_metric_definitions_request( # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if filter is not None: + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") @@ -669,16 +687,15 @@ def __init__(self, *args, **kwargs) -> None: self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def get(self, resource_group_name: str, account_name: str, **kwargs: Any) -> _models.DatabaseAccountGetResults: - """Retrieves the properties of an existing Azure Cosmos DB database account. + def check_name_exists(self, account_name: str, **kwargs: Any) -> bool: + """Checks that the Azure Cosmos DB account name already exists. A valid account name may contain + only lowercase letters, numbers, and the '-' character, and must be between 3 and 50 + characters. - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str :param account_name: Cosmos DB database account name. Required. :type account_name: str - :return: DatabaseAccountGetResults or the result of cls(response) - :rtype: ~azure.mgmt.cosmosdb.models.DatabaseAccountGetResults + :return: bool or the result of cls(response) + :rtype: bool :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -693,12 +710,10 @@ def get(self, resource_group_name: str, account_name: str, **kwargs: Any) -> _mo _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.DatabaseAccountGetResults] = kwargs.pop("cls", None) + cls: ClsType[None] = kwargs.pop("cls", None) - _request = build_get_request( - resource_group_name=resource_group_name, + _request = build_check_name_exists_request( account_name=account_name, - subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, params=_params, @@ -712,24 +727,33 @@ def get(self, resource_group_name: str, account_name: str, **kwargs: Any) -> _mo response = pipeline_response.http_response - if response.status_code not in [200]: + if response.status_code not in [200, 404]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("DatabaseAccountGetResults", pipeline_response.http_response) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, None, {}) # type: ignore + return 200 <= response.status_code <= 299 - return deserialized # type: ignore + @distributed_trace + def list(self, **kwargs: Any) -> ItemPaged["_models.DatabaseAccountGetResults"]: + """Lists all the Azure Cosmos DB database accounts available under the subscription. + + :return: An iterator like instance of either DatabaseAccountGetResults or the result of + cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cosmosdb.models.DatabaseAccountGetResults] + :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.DatabaseAccountsListResult] = kwargs.pop("cls", None) - def _update_initial( - self, - resource_group_name: str, - account_name: str, - update_parameters: Union[_models.DatabaseAccountUpdateParameters, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -738,22 +762,237 @@ def _update_initial( } 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) + def prepare_request(next_link=None): + if not next_link: - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(update_parameters, (IOBase, bytes)): - _content = update_parameters + _request = build_list_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("DatabaseAccountsListResult", 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_resource_group( + self, resource_group_name: str, **kwargs: Any + ) -> ItemPaged["_models.DatabaseAccountGetResults"]: + """Lists all the Azure Cosmos DB database accounts available under the given 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 DatabaseAccountGetResults or the result of + cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cosmosdb.models.DatabaseAccountGetResults] + :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.DatabaseAccountsListResult] = 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("DatabaseAccountsListResult", 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, account_name: str, **kwargs: Any) -> _models.DatabaseAccountGetResults: + """Retrieves the properties of an existing Azure Cosmos DB database account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :return: DatabaseAccountGetResults or the result of cls(response) + :rtype: ~azure.mgmt.cosmosdb.models.DatabaseAccountGetResults + :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.DatabaseAccountGetResults] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + account_name=account_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("DatabaseAccountGetResults", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + def _create_or_update_initial( + self, + resource_group_name: str, + account_name: str, + create_update_parameters: Union[_models.DatabaseAccountCreateUpdateParameters, 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(create_update_parameters, (IOBase, bytes)): + _content = create_update_parameters else: - _json = self._serialize.body(update_parameters, "DatabaseAccountUpdateParameters") + _json = self._serialize.body(create_update_parameters, "DatabaseAccountCreateUpdateParameters") - _request = build_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -780,34 +1019,44 @@ def _update_initial( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + 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")) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @overload - def begin_update( + def begin_create_or_update( self, resource_group_name: str, account_name: str, - update_parameters: _models.DatabaseAccountUpdateParameters, + create_update_parameters: _models.DatabaseAccountCreateUpdateParameters, *, content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.DatabaseAccountGetResults]: - """Updates the properties of an existing Azure Cosmos DB database account. + """Creates or updates an Azure Cosmos DB database account. The "Update" method is preferred when + performing updates on an account. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param update_parameters: The parameters to provide for the current database account. Required. - :type update_parameters: ~azure.mgmt.cosmosdb.models.DatabaseAccountUpdateParameters + :param create_update_parameters: The parameters to provide for the current database account. + Required. + :type create_update_parameters: + ~azure.mgmt.cosmosdb.models.DatabaseAccountCreateUpdateParameters :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str @@ -818,24 +1067,26 @@ def begin_update( """ @overload - def begin_update( + def begin_create_or_update( self, resource_group_name: str, account_name: str, - update_parameters: IO[bytes], + create_update_parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.DatabaseAccountGetResults]: - """Updates the properties of an existing Azure Cosmos DB database account. + """Creates or updates an Azure Cosmos DB database account. The "Update" method is preferred when + performing updates on an account. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param update_parameters: The parameters to provide for the current database account. Required. - :type update_parameters: IO[bytes] + :param create_update_parameters: The parameters to provide for the current database account. + Required. + :type create_update_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 @@ -846,24 +1097,25 @@ def begin_update( """ @distributed_trace - def begin_update( + def begin_create_or_update( self, resource_group_name: str, account_name: str, - update_parameters: Union[_models.DatabaseAccountUpdateParameters, IO[bytes]], + create_update_parameters: Union[_models.DatabaseAccountCreateUpdateParameters, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.DatabaseAccountGetResults]: - """Updates the properties of an existing Azure Cosmos DB database account. + """Creates or updates an Azure Cosmos DB database account. The "Update" method is preferred when + performing updates on an account. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param update_parameters: The parameters to provide for the current database account. Is either - a DatabaseAccountUpdateParameters type or a IO[bytes] type. Required. - :type update_parameters: ~azure.mgmt.cosmosdb.models.DatabaseAccountUpdateParameters or - IO[bytes] + :param create_update_parameters: The parameters to provide for the current database account. Is + either a DatabaseAccountCreateUpdateParameters type or a IO[bytes] type. Required. + :type create_update_parameters: + ~azure.mgmt.cosmosdb.models.DatabaseAccountCreateUpdateParameters or IO[bytes] :return: An instance of LROPoller that returns either DatabaseAccountGetResults or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.DatabaseAccountGetResults] @@ -879,10 +1131,10 @@ def begin_update( 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( + raw_result = self._create_or_update_initial( resource_group_name=resource_group_name, account_name=account_name, - update_parameters=update_parameters, + create_update_parameters=create_update_parameters, api_version=api_version, content_type=content_type, cls=lambda x, y, z: x, @@ -894,13 +1146,19 @@ def begin_update( kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): + response_headers = {} + response = pipeline_response.http_response + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + deserialized = self._deserialize("DatabaseAccountGetResults", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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: @@ -916,11 +1174,11 @@ def get_long_running_output(pipeline_response): self._client, raw_result, get_long_running_output, polling_method # type: ignore ) - def _create_or_update_initial( + def _update_initial( self, resource_group_name: str, account_name: str, - create_update_parameters: Union[_models.DatabaseAccountCreateUpdateParameters, IO[bytes]], + update_parameters: Union[_models.DatabaseAccountUpdateParameters, IO[bytes]], **kwargs: Any ) -> Iterator[bytes]: error_map: MutableMapping = { @@ -941,12 +1199,12 @@ def _create_or_update_initial( content_type = content_type or "application/json" _json = None _content = None - if isinstance(create_update_parameters, (IOBase, bytes)): - _content = create_update_parameters + if isinstance(update_parameters, (IOBase, bytes)): + _content = update_parameters else: - _json = self._serialize.body(create_update_parameters, "DatabaseAccountCreateUpdateParameters") + _json = self._serialize.body(update_parameters, "DatabaseAccountUpdateParameters") - _request = build_create_or_update_request( + _request = build_update_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -973,37 +1231,41 @@ def _create_or_update_initial( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + 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")) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @overload - def begin_create_or_update( + def begin_update( self, resource_group_name: str, account_name: str, - create_update_parameters: _models.DatabaseAccountCreateUpdateParameters, + update_parameters: _models.DatabaseAccountUpdateParameters, *, content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.DatabaseAccountGetResults]: - """Creates or updates an Azure Cosmos DB database account. The "Update" method is preferred when - performing updates on an account. + """Updates the properties of an existing Azure Cosmos DB database account. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param create_update_parameters: The parameters to provide for the current database account. - Required. - :type create_update_parameters: - ~azure.mgmt.cosmosdb.models.DatabaseAccountCreateUpdateParameters + :param update_parameters: The parameters to provide for the current database account. Required. + :type update_parameters: ~azure.mgmt.cosmosdb.models.DatabaseAccountUpdateParameters :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str @@ -1014,26 +1276,24 @@ def begin_create_or_update( """ @overload - def begin_create_or_update( + def begin_update( self, resource_group_name: str, account_name: str, - create_update_parameters: IO[bytes], + update_parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.DatabaseAccountGetResults]: - """Creates or updates an Azure Cosmos DB database account. The "Update" method is preferred when - performing updates on an account. + """Updates the properties of an existing Azure Cosmos DB database account. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param create_update_parameters: The parameters to provide for the current database account. - Required. - :type create_update_parameters: IO[bytes] + :param update_parameters: The parameters to provide for the current database account. Required. + :type update_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 @@ -1044,25 +1304,24 @@ def begin_create_or_update( """ @distributed_trace - def begin_create_or_update( + def begin_update( self, resource_group_name: str, account_name: str, - create_update_parameters: Union[_models.DatabaseAccountCreateUpdateParameters, IO[bytes]], + update_parameters: Union[_models.DatabaseAccountUpdateParameters, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.DatabaseAccountGetResults]: - """Creates or updates an Azure Cosmos DB database account. The "Update" method is preferred when - performing updates on an account. + """Updates the properties of an existing Azure Cosmos DB database account. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param create_update_parameters: The parameters to provide for the current database account. Is - either a DatabaseAccountCreateUpdateParameters type or a IO[bytes] type. Required. - :type create_update_parameters: - ~azure.mgmt.cosmosdb.models.DatabaseAccountCreateUpdateParameters or IO[bytes] + :param update_parameters: The parameters to provide for the current database account. Is either + a DatabaseAccountUpdateParameters type or a IO[bytes] type. Required. + :type update_parameters: ~azure.mgmt.cosmosdb.models.DatabaseAccountUpdateParameters or + IO[bytes] :return: An instance of LROPoller that returns either DatabaseAccountGetResults or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.DatabaseAccountGetResults] @@ -1078,10 +1337,10 @@ def begin_create_or_update( 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( + raw_result = self._update_initial( resource_group_name=resource_group_name, account_name=account_name, - create_update_parameters=create_update_parameters, + update_parameters=update_parameters, api_version=api_version, content_type=content_type, cls=lambda x, y, z: x, @@ -1093,13 +1352,19 @@ def begin_create_or_update( kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): + response_headers = {} + response = pipeline_response.http_response + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + deserialized = self._deserialize("DatabaseAccountGetResults", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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: @@ -1154,14 +1419,18 @@ def _delete_initial(self, resource_group_name: str, account_name: str, **kwargs: except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + 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["azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("azure-AsyncOperation") + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") ) - response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) @@ -1209,7 +1478,9 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- return cls(pipeline_response, None, {}) # type: ignore if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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: @@ -1280,14 +1551,19 @@ def _failover_priority_change_initial( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + 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["azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("azure-AsyncOperation") + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") ) - response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) @@ -1374,70 +1650,200 @@ def begin_failover_priority_change( :type resource_group_name: str :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param failover_parameters: The new failover policies for the database account. Is either a - FailoverPolicies type or a IO[bytes] type. Required. - :type failover_parameters: ~azure.mgmt.cosmosdb.models.FailoverPolicies or IO[bytes] - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] + :param failover_parameters: The new failover policies for the database account. Is either a + FailoverPolicies type or a IO[bytes] type. Required. + :type failover_parameters: ~azure.mgmt.cosmosdb.models.FailoverPolicies 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)) + 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._failover_priority_change_initial( + resource_group_name=resource_group_name, + account_name=account_name, + failover_parameters=failover_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 + + @distributed_trace + def list_connection_strings( + self, resource_group_name: str, account_name: str, **kwargs: Any + ) -> _models.DatabaseAccountListConnectionStringsResult: + """Lists the connection strings for the specified Azure Cosmos DB database account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :return: DatabaseAccountListConnectionStringsResult or the result of cls(response) + :rtype: ~azure.mgmt.cosmosdb.models.DatabaseAccountListConnectionStringsResult + :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.DatabaseAccountListConnectionStringsResult] = kwargs.pop("cls", None) + + _request = build_list_connection_strings_request( + resource_group_name=resource_group_name, + account_name=account_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("DatabaseAccountListConnectionStringsResult", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list_keys( + self, resource_group_name: str, account_name: str, **kwargs: Any + ) -> _models.DatabaseAccountListKeysResult: + """Lists the access keys for the specified Azure Cosmos DB database account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :return: DatabaseAccountListKeysResult or the result of cls(response) + :rtype: ~azure.mgmt.cosmosdb.models.DatabaseAccountListKeysResult :raises ~azure.core.exceptions.HttpResponseError: """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + 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)) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", 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._failover_priority_change_initial( - resource_group_name=resource_group_name, - account_name=account_name, - failover_parameters=failover_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) + cls: ClsType[_models.DatabaseAccountListKeysResult] = kwargs.pop("cls", None) - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore + _request = build_list_keys_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) - if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **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, + _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, ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("DatabaseAccountListKeysResult", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore @distributed_trace - def list(self, **kwargs: Any) -> ItemPaged["_models.DatabaseAccountGetResults"]: - """Lists all the Azure Cosmos DB database accounts available under the subscription. + def list_metric_definitions( + self, resource_group_name: str, account_name: str, **kwargs: Any + ) -> ItemPaged["_models.MetricDefinition"]: + """Retrieves metric definitions for the given database account. - :return: An iterator like instance of either DatabaseAccountGetResults or the result of - cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cosmosdb.models.DatabaseAccountGetResults] + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :return: An iterator like instance of either MetricDefinition or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cosmosdb.models.MetricDefinition] :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.DatabaseAccountsListResult] = kwargs.pop("cls", None) + cls: ClsType[_models.MetricDefinitionsListResult] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -1450,7 +1856,9 @@ def list(self, **kwargs: Any) -> ItemPaged["_models.DatabaseAccountGetResults"]: def prepare_request(next_link=None): if not next_link: - _request = build_list_request( + _request = build_list_metric_definitions_request( + resource_group_name=resource_group_name, + account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, @@ -1476,11 +1884,11 @@ def prepare_request(next_link=None): return _request def extract_data(pipeline_response): - deserialized = self._deserialize("DatabaseAccountsListResult", pipeline_response) + deserialized = self._deserialize("MetricDefinitionsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore - return None, iter(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): _request = prepare_request(next_link) @@ -1493,31 +1901,40 @@ 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + 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_resource_group( - self, resource_group_name: str, **kwargs: Any - ) -> ItemPaged["_models.DatabaseAccountGetResults"]: - """Lists all the Azure Cosmos DB database accounts available under the given resource group. + def list_metrics( + self, resource_group_name: str, account_name: str, filter: str, **kwargs: Any + ) -> ItemPaged["_models.Metric"]: + """Retrieves the metrics determined by the given filter for the given database account. :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 DatabaseAccountGetResults or the result of - cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cosmosdb.models.DatabaseAccountGetResults] + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param filter: An OData filter expression that describes a subset of metrics to return. The + parameters that can be filtered are name.value (name of the metric, can have an or of multiple + names), startTime, endTime, and timeGrain. The supported operator is eq. Required. + :type filter: str + :return: An iterator like instance of either Metric or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cosmosdb.models.Metric] :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.DatabaseAccountsListResult] = kwargs.pop("cls", None) + cls: ClsType[_models.MetricListResult] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -1530,9 +1947,11 @@ def list_by_resource_group( def prepare_request(next_link=None): if not next_link: - _request = build_list_by_resource_group_request( + _request = build_list_metrics_request( resource_group_name=resource_group_name, + account_name=account_name, subscription_id=self._config.subscription_id, + filter=filter, api_version=api_version, headers=_headers, params=_params, @@ -1553,146 +1972,36 @@ def prepare_request(next_link=None): "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("DatabaseAccountsListResult", 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def list_keys( - self, resource_group_name: str, account_name: str, **kwargs: Any - ) -> _models.DatabaseAccountListKeysResult: - """Lists the access keys for the specified Azure Cosmos DB database account. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param account_name: Cosmos DB database account name. Required. - :type account_name: str - :return: DatabaseAccountListKeysResult or the result of cls(response) - :rtype: ~azure.mgmt.cosmosdb.models.DatabaseAccountListKeysResult - :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.DatabaseAccountListKeysResult] = kwargs.pop("cls", None) - - _request = build_list_keys_request( - resource_group_name=resource_group_name, - account_name=account_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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("DatabaseAccountListKeysResult", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def list_connection_strings( - self, resource_group_name: str, account_name: str, **kwargs: Any - ) -> _models.DatabaseAccountListConnectionStringsResult: - """Lists the connection strings for the specified Azure Cosmos DB database account. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param account_name: Cosmos DB database account name. Required. - :type account_name: str - :return: DatabaseAccountListConnectionStringsResult or the result of cls(response) - :rtype: ~azure.mgmt.cosmosdb.models.DatabaseAccountListConnectionStringsResult - :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.DatabaseAccountListConnectionStringsResult] = kwargs.pop("cls", None) - - _request = build_list_connection_strings_request( - resource_group_name=resource_group_name, - account_name=account_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 - ) + _request.method = "GET" + return _request - response = pipeline_response.http_response + def extract_data(pipeline_response): + deserialized = self._deserialize("MetricListResult", 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) - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + def get_next(next_link=None): + _request = prepare_request(next_link) - deserialized = self._deserialize("DatabaseAccountListConnectionStringsResult", pipeline_response.http_response) + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + 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 deserialized # type: ignore + return pipeline_response + + return ItemPaged(get_next, extract_data) def _offline_region_initial( self, @@ -1752,17 +2061,18 @@ def _offline_region_initial( pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize( - _models.ErrorResponseAutoGenerated2, + _models.ErrorResponse, pipeline_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["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") ) - response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) @@ -1879,7 +2189,9 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- return cls(pipeline_response, None, {}) # type: ignore if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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: @@ -1951,17 +2263,18 @@ def _online_region_initial( pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize( - _models.ErrorResponseAutoGenerated2, + _models.ErrorResponse, pipeline_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["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") ) - response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) @@ -2078,7 +2391,9 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- return cls(pipeline_response, None, {}) # type: ignore if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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: @@ -2140,7 +2455,11 @@ def get_read_only_keys( if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("DatabaseAccountListReadOnlyKeysResult", pipeline_response.http_response) @@ -2197,7 +2516,11 @@ def list_read_only_keys( if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("DatabaseAccountListReadOnlyKeysResult", pipeline_response.http_response) @@ -2263,14 +2586,19 @@ def _regenerate_key_initial( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + 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["azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("azure-AsyncOperation") + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") ) - response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) @@ -2385,7 +2713,9 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- return cls(pipeline_response, None, {}) # type: ignore if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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: @@ -2399,143 +2729,6 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- ) return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - @distributed_trace - def check_name_exists(self, account_name: str, **kwargs: Any) -> bool: - """Checks that the Azure Cosmos DB account name already exists. A valid account name may contain - only lowercase letters, numbers, and the '-' character, and must be between 3 and 50 - characters. - - :param account_name: Cosmos DB database account name. Required. - :type account_name: str - :return: bool or the result of cls(response) - :rtype: bool - :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[None] = kwargs.pop("cls", None) - - _request = build_check_name_exists_request( - account_name=account_name, - 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, 404]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) # type: ignore - return 200 <= response.status_code <= 299 - - @distributed_trace - def list_metrics( - self, resource_group_name: str, account_name: str, filter: str, **kwargs: Any - ) -> ItemPaged["_models.Metric"]: - """Retrieves the metrics determined by the given filter for the given database account. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param account_name: Cosmos DB database account name. Required. - :type account_name: str - :param filter: An OData filter expression that describes a subset of metrics to return. The - parameters that can be filtered are name.value (name of the metric, can have an or of multiple - names), startTime, endTime, and timeGrain. The supported operator is eq. Required. - :type filter: str - :return: An iterator like instance of either Metric or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cosmosdb.models.Metric] - :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.MetricListResult] = 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_metrics_request( - resource_group_name=resource_group_name, - account_name=account_name, - subscription_id=self._config.subscription_id, - filter=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("MetricListResult", 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - @distributed_trace def list_usages( self, resource_group_name: str, account_name: str, filter: Optional[str] = None, **kwargs: Any @@ -2605,7 +2798,7 @@ def extract_data(pipeline_response): list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore - return None, iter(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): _request = prepare_request(next_link) @@ -2618,90 +2811,11 @@ 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def list_metric_definitions( - self, resource_group_name: str, account_name: str, **kwargs: Any - ) -> ItemPaged["_models.MetricDefinition"]: - """Retrieves metric definitions for the given database account. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param account_name: Cosmos DB database account name. Required. - :type account_name: str - :return: An iterator like instance of either MetricDefinition or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cosmosdb.models.MetricDefinition] - :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.MetricDefinitionsListResult] = 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_metric_definitions_request( - resource_group_name=resource_group_name, - account_name=account_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 + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("MetricDefinitionsListResult", 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response diff --git a/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/operations/_database_operations.py b/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/operations/_database_operations.py index a3a6f578025..f3e3a7ef98d 100644 --- a/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/operations/_database_operations.py +++ b/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/operations/_database_operations.py @@ -38,19 +38,19 @@ _SERIALIZER.client_side_validation = False -def build_list_metrics_request( - resource_group_name: str, account_name: str, database_rid: str, subscription_id: str, *, filter: str, **kwargs: Any +def build_list_metric_definitions_request( + resource_group_name: str, account_name: str, database_rid: 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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/databases/{databaseRid}/metrics", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/databases/{databaseRid}/metricDefinitions", ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), @@ -67,7 +67,6 @@ def build_list_metrics_request( # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - _params["$filter"] = _SERIALIZER.query("filter", filter, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") @@ -75,25 +74,19 @@ def build_list_metrics_request( return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_usages_request( - resource_group_name: str, - account_name: str, - database_rid: str, - subscription_id: str, - *, - filter: Optional[str] = None, - **kwargs: Any +def build_list_metrics_request( + resource_group_name: str, account_name: str, database_rid: str, subscription_id: str, *, filter: 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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/databases/{databaseRid}/usages", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/databases/{databaseRid}/metrics", ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), @@ -110,8 +103,7 @@ def build_list_usages_request( # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - if filter is not None: - _params["$filter"] = _SERIALIZER.query("filter", filter, "str") + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") @@ -119,19 +111,25 @@ def build_list_usages_request( return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_metric_definitions_request( - resource_group_name: str, account_name: str, database_rid: str, subscription_id: str, **kwargs: Any +def build_list_usages_request( + resource_group_name: str, + account_name: str, + database_rid: str, + subscription_id: str, + *, + filter: Optional[str] = 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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/databases/{databaseRid}/metricDefinitions", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/databases/{databaseRid}/usages", ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), @@ -148,6 +146,8 @@ def build_list_metric_definitions_request( # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if filter is not None: + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") @@ -175,11 +175,10 @@ def __init__(self, *args, **kwargs) -> None: self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def list_metrics( - self, resource_group_name: str, account_name: str, database_rid: str, filter: str, **kwargs: Any - ) -> ItemPaged["_models.Metric"]: - """Retrieves the metrics determined by the given filter for the given database account and - database. + def list_metric_definitions( + self, resource_group_name: str, account_name: str, database_rid: str, **kwargs: Any + ) -> ItemPaged["_models.MetricDefinition"]: + """Retrieves metric definitions for the given database. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -188,19 +187,15 @@ def list_metrics( :type account_name: str :param database_rid: Cosmos DB database rid. Required. :type database_rid: str - :param filter: An OData filter expression that describes a subset of metrics to return. The - parameters that can be filtered are name.value (name of the metric, can have an or of multiple - names), startTime, endTime, and timeGrain. The supported operator is eq. Required. - :type filter: str - :return: An iterator like instance of either Metric or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cosmosdb.models.Metric] + :return: An iterator like instance of either MetricDefinition or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cosmosdb.models.MetricDefinition] :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.MetricListResult] = kwargs.pop("cls", None) + cls: ClsType[_models.MetricDefinitionsListResult] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -213,12 +208,11 @@ def list_metrics( def prepare_request(next_link=None): if not next_link: - _request = build_list_metrics_request( + _request = build_list_metric_definitions_request( resource_group_name=resource_group_name, account_name=account_name, database_rid=database_rid, subscription_id=self._config.subscription_id, - filter=filter, api_version=api_version, headers=_headers, params=_params, @@ -243,11 +237,11 @@ def prepare_request(next_link=None): return _request def extract_data(pipeline_response): - deserialized = self._deserialize("MetricListResult", pipeline_response) + deserialized = self._deserialize("MetricDefinitionsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore - return None, iter(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): _request = prepare_request(next_link) @@ -260,22 +254,22 @@ 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + 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_usages( - self, - resource_group_name: str, - account_name: str, - database_rid: str, - filter: Optional[str] = None, - **kwargs: Any - ) -> ItemPaged["_models.Usage"]: - """Retrieves the usages (most recent data) for the given database. + def list_metrics( + self, resource_group_name: str, account_name: str, database_rid: str, filter: str, **kwargs: Any + ) -> ItemPaged["_models.Metric"]: + """Retrieves the metrics determined by the given filter for the given database account and + database. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -284,19 +278,19 @@ def list_usages( :type account_name: str :param database_rid: Cosmos DB database rid. Required. :type database_rid: str - :param filter: An OData filter expression that describes a subset of usages to return. The - supported parameter is name.value (name of the metric, can have an or of multiple names). - Default value is None. + :param filter: An OData filter expression that describes a subset of metrics to return. The + parameters that can be filtered are name.value (name of the metric, can have an or of multiple + names), startTime, endTime, and timeGrain. The supported operator is eq. Required. :type filter: str - :return: An iterator like instance of either Usage or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cosmosdb.models.Usage] + :return: An iterator like instance of either Metric or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cosmosdb.models.Metric] :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.UsagesResult] = kwargs.pop("cls", None) + cls: ClsType[_models.MetricListResult] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -309,7 +303,7 @@ def list_usages( def prepare_request(next_link=None): if not next_link: - _request = build_list_usages_request( + _request = build_list_metrics_request( resource_group_name=resource_group_name, account_name=account_name, database_rid=database_rid, @@ -339,11 +333,11 @@ def prepare_request(next_link=None): return _request def extract_data(pipeline_response): - deserialized = self._deserialize("UsagesResult", pipeline_response) + deserialized = self._deserialize("MetricListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore - return None, iter(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): _request = prepare_request(next_link) @@ -356,17 +350,26 @@ 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + 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_metric_definitions( - self, resource_group_name: str, account_name: str, database_rid: str, **kwargs: Any - ) -> ItemPaged["_models.MetricDefinition"]: - """Retrieves metric definitions for the given database. + def list_usages( + self, + resource_group_name: str, + account_name: str, + database_rid: str, + filter: Optional[str] = None, + **kwargs: Any + ) -> ItemPaged["_models.Usage"]: + """Retrieves the usages (most recent data) for the given database. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -375,15 +378,19 @@ def list_metric_definitions( :type account_name: str :param database_rid: Cosmos DB database rid. Required. :type database_rid: str - :return: An iterator like instance of either MetricDefinition or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cosmosdb.models.MetricDefinition] + :param filter: An OData filter expression that describes a subset of usages to return. The + supported parameter is name.value (name of the metric, can have an or of multiple names). + Default value is None. + :type filter: str + :return: An iterator like instance of either Usage or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cosmosdb.models.Usage] :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.MetricDefinitionsListResult] = kwargs.pop("cls", None) + cls: ClsType[_models.UsagesResult] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -396,11 +403,12 @@ def list_metric_definitions( def prepare_request(next_link=None): if not next_link: - _request = build_list_metric_definitions_request( + _request = build_list_usages_request( resource_group_name=resource_group_name, account_name=account_name, database_rid=database_rid, subscription_id=self._config.subscription_id, + filter=filter, api_version=api_version, headers=_headers, params=_params, @@ -425,11 +433,11 @@ def prepare_request(next_link=None): return _request def extract_data(pipeline_response): - deserialized = self._deserialize("MetricDefinitionsListResult", pipeline_response) + deserialized = self._deserialize("UsagesResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore - return None, iter(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): _request = prepare_request(next_link) @@ -442,7 +450,11 @@ 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response diff --git a/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/operations/_fleet_analytics_operations.py b/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/operations/_fleet_analytics_operations.py index 4d00e416407..df63fbd919c 100644 --- a/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/operations/_fleet_analytics_operations.py +++ b/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/operations/_fleet_analytics_operations.py @@ -47,7 +47,7 @@ def build_list_request(resource_group_name: str, fleet_name: str, subscription_i _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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -82,7 +82,7 @@ def build_get_request( _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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -125,7 +125,7 @@ def build_create_request( _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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -171,7 +171,7 @@ def build_delete_request( _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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -306,7 +306,7 @@ 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( - _models.ErrorResponseAutoGenerated, + _models.ErrorResponse, pipeline_response, ) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -367,7 +367,7 @@ def get( 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.ErrorResponseAutoGenerated, + _models.ErrorResponse, pipeline_response, ) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -511,7 +511,7 @@ def create( 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.ErrorResponseAutoGenerated, + _models.ErrorResponse, pipeline_response, ) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -566,17 +566,18 @@ def _delete_initial( pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize( - _models.ErrorResponseAutoGenerated, + _models.ErrorResponse, pipeline_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["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") ) - response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) diff --git a/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/operations/_fleet_operations.py b/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/operations/_fleet_operations.py index 07bb1b823c6..b99b4db45b4 100644 --- a/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/operations/_fleet_operations.py +++ b/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/operations/_fleet_operations.py @@ -47,7 +47,7 @@ def build_list_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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -71,7 +71,7 @@ def build_list_by_resource_group_request(resource_group_name: str, subscription_ _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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -101,7 +101,7 @@ def build_get_request(resource_group_name: str, fleet_name: str, subscription_id _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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -134,7 +134,7 @@ def build_create_request(resource_group_name: str, fleet_name: str, subscription _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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -170,7 +170,7 @@ def build_update_request(resource_group_name: str, fleet_name: str, subscription _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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -206,7 +206,7 @@ def build_delete_request(resource_group_name: str, fleet_name: str, subscription _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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -323,7 +323,7 @@ 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( - _models.ErrorResponseAutoGenerated, + _models.ErrorResponse, pipeline_response, ) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -405,7 +405,7 @@ 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( - _models.ErrorResponseAutoGenerated, + _models.ErrorResponse, pipeline_response, ) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -461,7 +461,7 @@ def get(self, resource_group_name: str, fleet_name: str, **kwargs: Any) -> _mode 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.ErrorResponseAutoGenerated, + _models.ErrorResponse, pipeline_response, ) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -591,7 +591,7 @@ def create( 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.ErrorResponseAutoGenerated, + _models.ErrorResponse, pipeline_response, ) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -729,7 +729,7 @@ def update( 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.ErrorResponseAutoGenerated, + _models.ErrorResponse, pipeline_response, ) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -781,17 +781,18 @@ def _delete_initial(self, resource_group_name: str, fleet_name: str, **kwargs: A pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize( - _models.ErrorResponseAutoGenerated, + _models.ErrorResponse, pipeline_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["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") ) - response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) diff --git a/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/operations/_fleetspace_account_operations.py b/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/operations/_fleetspace_account_operations.py index 6b30561f7f9..b6c0a46821d 100644 --- a/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/operations/_fleetspace_account_operations.py +++ b/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/operations/_fleetspace_account_operations.py @@ -49,7 +49,7 @@ def build_list_request( _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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -92,7 +92,7 @@ def build_get_request( _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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -143,7 +143,7 @@ def build_create_request( _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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -197,7 +197,7 @@ def build_delete_request( _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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -338,7 +338,7 @@ 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( - _models.ErrorResponseAutoGenerated, + _models.ErrorResponse, pipeline_response, ) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -407,7 +407,7 @@ def get( 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.ErrorResponseAutoGenerated, + _models.ErrorResponse, pipeline_response, ) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -481,15 +481,22 @@ def _create_initial( pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize( - _models.ErrorResponseAutoGenerated, + _models.ErrorResponse, pipeline_response, ) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + response_headers = {} + if response.status_code == 201: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @@ -690,17 +697,18 @@ def _delete_initial( pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize( - _models.ErrorResponseAutoGenerated, + _models.ErrorResponse, pipeline_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["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") ) - response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) diff --git a/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/operations/_fleetspace_operations.py b/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/operations/_fleetspace_operations.py index 180ee2e0fbf..7483ca11464 100644 --- a/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/operations/_fleetspace_operations.py +++ b/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/operations/_fleetspace_operations.py @@ -47,7 +47,7 @@ def build_list_request(resource_group_name: str, fleet_name: str, subscription_i _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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -82,7 +82,7 @@ def build_get_request( _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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -120,7 +120,7 @@ def build_create_request( _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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -161,7 +161,7 @@ def build_update_request( _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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -202,7 +202,7 @@ def build_delete_request( _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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -329,7 +329,7 @@ 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( - _models.ErrorResponseAutoGenerated, + _models.ErrorResponse, pipeline_response, ) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -390,7 +390,7 @@ def get( 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.ErrorResponseAutoGenerated, + _models.ErrorResponse, pipeline_response, ) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -462,15 +462,22 @@ def _create_initial( pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize( - _models.ErrorResponseAutoGenerated, + _models.ErrorResponse, pipeline_response, ) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + response_headers = {} + if response.status_code == 201: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @@ -676,17 +683,18 @@ def _update_initial( pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize( - _models.ErrorResponseAutoGenerated, + _models.ErrorResponse, pipeline_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["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") ) - response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) @@ -877,17 +885,18 @@ def _delete_initial( pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize( - _models.ErrorResponseAutoGenerated, + _models.ErrorResponse, pipeline_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["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") ) - response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) diff --git a/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/operations/_garnet_clusters_operations.py b/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/operations/_garnet_clusters_operations.py index 6b7b8440a53..ce38c5176ba 100644 --- a/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/operations/_garnet_clusters_operations.py +++ b/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/operations/_garnet_clusters_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=line-too-long,useless-suppression +# pylint: disable=line-too-long,useless-suppression,too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -47,7 +47,7 @@ def build_list_by_subscription_request(subscription_id: str, **kwargs: Any) -> H _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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -71,7 +71,7 @@ def build_list_by_resource_group_request(resource_group_name: str, subscription_ _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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -101,7 +101,7 @@ def build_get_request(resource_group_name: str, cluster_name: str, subscription_ _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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -130,13 +130,14 @@ def build_get_request(resource_group_name: str, cluster_name: str, subscription_ return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_delete_request( +def build_create_update_request( resource_group_name: str, cluster_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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -160,18 +161,20 @@ def build_delete_request( _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="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_update_request( +def build_update_request( resource_group_name: str, cluster_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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -200,17 +203,16 @@ def build_create_update_request( _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) + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) -def build_update_request( +def build_delete_request( resource_group_name: str, cluster_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-11-01-preview")) - 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-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -234,11 +236,9 @@ def build_update_request( _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) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) class GarnetClustersOperations: @@ -316,7 +316,7 @@ def extract_data(pipeline_response): list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore - return None, iter(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): _request = prepare_request(next_link) @@ -330,7 +330,7 @@ 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( - _models.ErrorResponseAutoGenerated, + _models.ErrorResponse, pipeline_response, ) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -401,7 +401,7 @@ def extract_data(pipeline_response): list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore - return None, iter(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): _request = prepare_request(next_link) @@ -415,7 +415,7 @@ 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( - _models.ErrorResponseAutoGenerated, + _models.ErrorResponse, pipeline_response, ) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -431,7 +431,7 @@ def get(self, resource_group_name: str, cluster_name: str, **kwargs: Any) -> _mo :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str - :param cluster_name: Garnet cache cluster name. Required. + :param cluster_name: The name of the GarnetClusterResource. Required. :type cluster_name: str :return: GarnetClusterResource or the result of cls(response) :rtype: ~azure.mgmt.cosmosdb.models.GarnetClusterResource @@ -471,7 +471,7 @@ def get(self, resource_group_name: str, cluster_name: str, **kwargs: Any) -> _mo 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.ErrorResponseAutoGenerated, + _models.ErrorResponse, pipeline_response, ) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -483,118 +483,6 @@ def get(self, resource_group_name: str, cluster_name: str, **kwargs: Any) -> _mo return deserialized # type: ignore - def _delete_initial(self, resource_group_name: str, cluster_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, - cluster_name=cluster_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.ErrorResponseAutoGenerated, - pipeline_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")) - - 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, cluster_name: str, **kwargs: Any) -> LROPoller[None]: - """Deletes a Garnet cluster. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param cluster_name: Garnet cache cluster name. Required. - :type cluster_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, - cluster_name=cluster_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, **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 _create_update_initial( self, resource_group_name: str, @@ -653,15 +541,20 @@ def _create_update_initial( pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize( - _models.ErrorResponseAutoGenerated, + _models.ErrorResponse, pipeline_response, ) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + response_headers = {} + if response.status_code == 201: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @@ -681,9 +574,9 @@ def begin_create_update( :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str - :param cluster_name: Garnet cache cluster name. Required. + :param cluster_name: The name of the GarnetClusterResource. Required. :type cluster_name: str - :param body: The properties specifying the desired state of the Garnet cache cluster. Required. + :param body: Resource create parameters. Required. :type body: ~azure.mgmt.cosmosdb.models.GarnetClusterResource :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". @@ -710,9 +603,9 @@ def begin_create_update( :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str - :param cluster_name: Garnet cache cluster name. Required. + :param cluster_name: The name of the GarnetClusterResource. Required. :type cluster_name: str - :param body: The properties specifying the desired state of the Garnet cache cluster. Required. + :param body: Resource create parameters. Required. :type body: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". @@ -737,10 +630,10 @@ def begin_create_update( :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str - :param cluster_name: Garnet cache cluster name. Required. + :param cluster_name: The name of the GarnetClusterResource. Required. :type cluster_name: str - :param body: The properties specifying the desired state of the Garnet cache cluster. Is either - a GarnetClusterResource type or a IO[bytes] type. Required. + :param body: Resource create parameters. Is either a GarnetClusterResource type or a IO[bytes] + type. Required. :type body: ~azure.mgmt.cosmosdb.models.GarnetClusterResource or IO[bytes] :return: An instance of LROPoller that returns either GarnetClusterResource or the result of cls(response) @@ -778,7 +671,9 @@ def get_long_running_output(pipeline_response): return deserialized if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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: @@ -852,17 +747,18 @@ def _update_initial( pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize( - _models.ErrorResponseAutoGenerated, + _models.ErrorResponse, pipeline_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["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") ) - response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) @@ -886,9 +782,9 @@ def begin_update( :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str - :param cluster_name: Garnet cache cluster name. Required. + :param cluster_name: The name of the GarnetClusterResource. Required. :type cluster_name: str - :param body: Parameters to provide for updating the Garnet cluster. Required. + :param body: The resource properties to be updated. Required. :type body: ~azure.mgmt.cosmosdb.models.GarnetClusterResourcePatch :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". @@ -914,9 +810,9 @@ def begin_update( :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str - :param cluster_name: Garnet cache cluster name. Required. + :param cluster_name: The name of the GarnetClusterResource. Required. :type cluster_name: str - :param body: Parameters to provide for updating the Garnet cluster. Required. + :param body: The resource properties to be updated. Required. :type body: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". @@ -940,10 +836,10 @@ def begin_update( :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str - :param cluster_name: Garnet cache cluster name. Required. + :param cluster_name: The name of the GarnetClusterResource. Required. :type cluster_name: str - :param body: Parameters to provide for updating the Garnet cluster. Is either a - GarnetClusterResourcePatch type or a IO[bytes] type. Required. + :param body: The resource properties to be updated. Is either a GarnetClusterResourcePatch type + or a IO[bytes] type. Required. :type body: ~azure.mgmt.cosmosdb.models.GarnetClusterResourcePatch or IO[bytes] :return: An instance of LROPoller that returns either GarnetClusterResource or the result of cls(response) @@ -981,7 +877,9 @@ def get_long_running_output(pipeline_response): return deserialized if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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: @@ -996,3 +894,118 @@ def get_long_running_output(pipeline_response): return LROPoller[_models.GarnetClusterResource]( self._client, raw_result, get_long_running_output, polling_method # type: ignore ) + + def _delete_initial(self, resource_group_name: str, cluster_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, + cluster_name=cluster_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["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.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, cluster_name: str, **kwargs: Any) -> LROPoller[None]: + """Deletes a Garnet cluster. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_name: The name of the GarnetClusterResource. Required. + :type cluster_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, + cluster_name=cluster_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/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/operations/_graph_resources_operations.py b/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/operations/_graph_resources_operations.py index 29be6f0e7f8..5e9d7228a69 100644 --- a/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/operations/_graph_resources_operations.py +++ b/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/operations/_graph_resources_operations.py @@ -49,7 +49,7 @@ def build_list_graphs_request( _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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -84,7 +84,7 @@ def build_get_graph_request( _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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -120,7 +120,7 @@ def build_create_update_graph_request( _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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -156,9 +156,12 @@ def build_create_update_graph_request( def build_delete_graph_resource_request( resource_group_name: str, account_name: str, graph_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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop( "template_url", @@ -180,7 +183,10 @@ def build_delete_graph_resource_request( # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) class GraphResourcesOperations: @@ -267,7 +273,7 @@ def extract_data(pipeline_response): list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore - return None, iter(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): _request = prepare_request(next_link) @@ -280,7 +286,11 @@ 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response @@ -338,7 +348,11 @@ def get_graph( if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("GraphResourceGetResults", pipeline_response.http_response) @@ -406,14 +420,19 @@ def _create_update_graph_initial( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + 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["azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("azure-AsyncOperation") + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") ) - response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) @@ -546,7 +565,9 @@ def get_long_running_output(pipeline_response): return deserialized if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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: @@ -604,14 +625,18 @@ def _delete_graph_resource_initial( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + 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["azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("azure-AsyncOperation") + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") ) - response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) @@ -664,7 +689,9 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- return cls(pipeline_response, None, {}) # type: ignore if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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: diff --git a/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/operations/_gremlin_resources_operations.py b/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/operations/_gremlin_resources_operations.py index a340e4e6036..d6afabc12db 100644 --- a/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/operations/_gremlin_resources_operations.py +++ b/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/operations/_gremlin_resources_operations.py @@ -49,7 +49,7 @@ def build_list_gremlin_databases_request( _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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -84,7 +84,7 @@ def build_get_gremlin_database_request( _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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -120,7 +120,7 @@ def build_create_update_gremlin_database_request( # pylint: disable=name-too-lo _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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -156,9 +156,12 @@ def build_create_update_gremlin_database_request( # pylint: disable=name-too-lo def build_delete_gremlin_database_request( resource_group_name: str, account_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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop( "template_url", @@ -180,22 +183,25 @@ def build_delete_gremlin_database_request( # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) -def build_get_gremlin_database_throughput_request( # pylint: disable=name-too-long +def build_list_gremlin_graphs_request( resource_group_name: str, account_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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/gremlinDatabases/{databaseName}/throughputSettings/default", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/gremlinDatabases/{databaseName}/graphs", ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), @@ -219,20 +225,24 @@ def build_get_gremlin_database_throughput_request( # pylint: disable=name-too-l return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_update_gremlin_database_throughput_request( # pylint: disable=name-too-long - resource_group_name: str, account_name: str, database_name: str, subscription_id: str, **kwargs: Any +def build_get_gremlin_graph_request( + resource_group_name: str, + account_name: str, + database_name: str, + graph_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-11-01-preview")) - 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-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/gremlinDatabases/{databaseName}/throughputSettings/default", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/gremlinDatabases/{databaseName}/graphs/{graphName}", ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), @@ -243,6 +253,7 @@ def build_update_gremlin_database_throughput_request( # pylint: disable=name-to "account_name", account_name, "str", max_length=50, min_length=3, pattern=r"^[a-z0-9]+(-[a-z0-9]+)*" ), "databaseName": _SERIALIZER.url("database_name", database_name, "str"), + "graphName": _SERIALIZER.url("graph_name", graph_name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -251,26 +262,30 @@ def build_update_gremlin_database_throughput_request( # pylint: disable=name-to _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) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_migrate_gremlin_database_to_autoscale_request( # pylint: disable=name-too-long - resource_group_name: str, account_name: str, database_name: str, subscription_id: str, **kwargs: Any +def build_create_update_gremlin_graph_request( # pylint: disable=name-too-long + resource_group_name: str, + account_name: str, + database_name: str, + graph_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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) + 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.DocumentDB/databaseAccounts/{accountName}/gremlinDatabases/{databaseName}/throughputSettings/default/migrateToAutoscale", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/gremlinDatabases/{databaseName}/graphs/{graphName}", ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), @@ -281,6 +296,7 @@ def build_migrate_gremlin_database_to_autoscale_request( # pylint: disable=name "account_name", account_name, "str", max_length=50, min_length=3, pattern=r"^[a-z0-9]+(-[a-z0-9]+)*" ), "databaseName": _SERIALIZER.url("database_name", database_name, "str"), + "graphName": _SERIALIZER.url("graph_name", graph_name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -289,24 +305,31 @@ def build_migrate_gremlin_database_to_autoscale_request( # pylint: disable=name _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) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_migrate_gremlin_database_to_manual_throughput_request( # pylint: disable=name-too-long - resource_group_name: str, account_name: str, database_name: str, subscription_id: str, **kwargs: Any +def build_delete_gremlin_graph_request( + resource_group_name: str, + account_name: str, + database_name: str, + graph_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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/gremlinDatabases/{databaseName}/throughputSettings/default/migrateToManualThroughput", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/gremlinDatabases/{databaseName}/graphs/{graphName}", ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), @@ -317,6 +340,7 @@ def build_migrate_gremlin_database_to_manual_throughput_request( # pylint: disa "account_name", account_name, "str", max_length=50, min_length=3, pattern=r"^[a-z0-9]+(-[a-z0-9]+)*" ), "databaseName": _SERIALIZER.url("database_name", database_name, "str"), + "graphName": _SERIALIZER.url("graph_name", graph_name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -327,22 +351,28 @@ def build_migrate_gremlin_database_to_manual_throughput_request( # pylint: disa # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_gremlin_graphs_request( - resource_group_name: str, account_name: str, database_name: str, subscription_id: str, **kwargs: Any +def build_retrieve_continuous_backup_information_request( # pylint: disable=name-too-long + resource_group_name: str, + account_name: str, + database_name: str, + graph_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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) + 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.DocumentDB/databaseAccounts/{accountName}/gremlinDatabases/{databaseName}/graphs", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/gremlinDatabases/{databaseName}/graphs/{graphName}/retrieveContinuousBackupInformation", ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), @@ -353,6 +383,7 @@ def build_list_gremlin_graphs_request( "account_name", account_name, "str", max_length=50, min_length=3, pattern=r"^[a-z0-9]+(-[a-z0-9]+)*" ), "databaseName": _SERIALIZER.url("database_name", database_name, "str"), + "graphName": _SERIALIZER.url("graph_name", graph_name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -361,12 +392,14 @@ def build_list_gremlin_graphs_request( _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="GET", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_get_gremlin_graph_request( +def build_get_gremlin_graph_throughput_request( # pylint: disable=name-too-long resource_group_name: str, account_name: str, database_name: str, @@ -377,13 +410,13 @@ def build_get_gremlin_graph_request( _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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/gremlinDatabases/{databaseName}/graphs/{graphName}", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/gremlinDatabases/{databaseName}/graphs/{graphName}/throughputSettings/default", ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), @@ -408,7 +441,7 @@ def build_get_gremlin_graph_request( return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_update_gremlin_graph_request( # pylint: disable=name-too-long +def build_update_gremlin_graph_throughput_request( # pylint: disable=name-too-long resource_group_name: str, account_name: str, database_name: str, @@ -419,14 +452,14 @@ def build_create_update_gremlin_graph_request( # 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", "2025-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) 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.DocumentDB/databaseAccounts/{accountName}/gremlinDatabases/{databaseName}/graphs/{graphName}", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/gremlinDatabases/{databaseName}/graphs/{graphName}/throughputSettings/default", ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), @@ -453,7 +486,7 @@ def build_create_update_gremlin_graph_request( # pylint: disable=name-too-long return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_delete_gremlin_graph_request( +def build_migrate_gremlin_graph_to_autoscale_request( # pylint: disable=name-too-long resource_group_name: str, account_name: str, database_name: str, @@ -461,13 +494,16 @@ def build_delete_gremlin_graph_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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/gremlinDatabases/{databaseName}/graphs/{graphName}", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/gremlinDatabases/{databaseName}/graphs/{graphName}/throughputSettings/default/migrateToAutoscale", ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), @@ -486,10 +522,13 @@ def build_delete_gremlin_graph_request( # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_get_gremlin_graph_throughput_request( # pylint: disable=name-too-long +def build_migrate_gremlin_graph_to_manual_throughput_request( # pylint: disable=name-too-long resource_group_name: str, account_name: str, database_name: str, @@ -500,13 +539,13 @@ def build_get_gremlin_graph_throughput_request( # 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", "2025-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/gremlinDatabases/{databaseName}/graphs/{graphName}/throughputSettings/default", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/gremlinDatabases/{databaseName}/graphs/{graphName}/throughputSettings/default/migrateToManualThroughput", ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), @@ -528,28 +567,22 @@ def build_get_gremlin_graph_throughput_request( # pylint: disable=name-too-long # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_update_gremlin_graph_throughput_request( # pylint: disable=name-too-long - resource_group_name: str, - account_name: str, - database_name: str, - graph_name: str, - subscription_id: str, - **kwargs: Any +def build_get_gremlin_database_throughput_request( # pylint: disable=name-too-long + resource_group_name: str, account_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-11-01-preview")) - 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-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/gremlinDatabases/{databaseName}/graphs/{graphName}/throughputSettings/default", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/gremlinDatabases/{databaseName}/throughputSettings/default", ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), @@ -560,7 +593,6 @@ def build_update_gremlin_graph_throughput_request( # pylint: disable=name-too-l "account_name", account_name, "str", max_length=50, min_length=3, pattern=r"^[a-z0-9]+(-[a-z0-9]+)*" ), "databaseName": _SERIALIZER.url("database_name", database_name, "str"), - "graphName": _SERIALIZER.url("graph_name", graph_name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -569,31 +601,25 @@ def build_update_gremlin_graph_throughput_request( # pylint: disable=name-too-l _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) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_migrate_gremlin_graph_to_autoscale_request( # pylint: disable=name-too-long - resource_group_name: str, - account_name: str, - database_name: str, - graph_name: str, - subscription_id: str, - **kwargs: Any +def build_update_gremlin_database_throughput_request( # pylint: disable=name-too-long + resource_group_name: str, account_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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) + 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.DocumentDB/databaseAccounts/{accountName}/gremlinDatabases/{databaseName}/graphs/{graphName}/throughputSettings/default/migrateToAutoscale", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/gremlinDatabases/{databaseName}/throughputSettings/default", ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), @@ -604,7 +630,6 @@ def build_migrate_gremlin_graph_to_autoscale_request( # pylint: disable=name-to "account_name", account_name, "str", max_length=50, min_length=3, pattern=r"^[a-z0-9]+(-[a-z0-9]+)*" ), "databaseName": _SERIALIZER.url("database_name", database_name, "str"), - "graphName": _SERIALIZER.url("graph_name", graph_name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -613,29 +638,26 @@ def build_migrate_gremlin_graph_to_autoscale_request( # pylint: disable=name-to _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) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_migrate_gremlin_graph_to_manual_throughput_request( # pylint: disable=name-too-long - resource_group_name: str, - account_name: str, - database_name: str, - graph_name: str, - subscription_id: str, - **kwargs: Any +def build_migrate_gremlin_database_to_autoscale_request( # pylint: disable=name-too-long + resource_group_name: str, account_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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/gremlinDatabases/{databaseName}/graphs/{graphName}/throughputSettings/default/migrateToManualThroughput", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/gremlinDatabases/{databaseName}/throughputSettings/default/migrateToAutoscale", ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), @@ -646,7 +668,6 @@ def build_migrate_gremlin_graph_to_manual_throughput_request( # pylint: disable "account_name", account_name, "str", max_length=50, min_length=3, pattern=r"^[a-z0-9]+(-[a-z0-9]+)*" ), "databaseName": _SERIALIZER.url("database_name", database_name, "str"), - "graphName": _SERIALIZER.url("graph_name", graph_name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -660,19 +681,19 @@ def build_migrate_gremlin_graph_to_manual_throughput_request( # pylint: disable return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_get_gremlin_role_definition_request( # pylint: disable=name-too-long - resource_group_name: str, account_name: str, role_definition_id: str, subscription_id: str, **kwargs: Any +def build_migrate_gremlin_database_to_manual_throughput_request( # pylint: disable=name-too-long + resource_group_name: str, account_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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/gremlinRoleDefinitions/{roleDefinitionId}", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/gremlinDatabases/{databaseName}/throughputSettings/default/migrateToManualThroughput", ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), @@ -682,7 +703,7 @@ def build_get_gremlin_role_definition_request( # pylint: disable=name-too-long "accountName": _SERIALIZER.url( "account_name", account_name, "str", max_length=50, min_length=3, pattern=r"^[a-z0-9]+(-[a-z0-9]+)*" ), - "roleDefinitionId": _SERIALIZER.url("role_definition_id", role_definition_id, "str"), + "databaseName": _SERIALIZER.url("database_name", database_name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -693,23 +714,22 @@ def build_get_gremlin_role_definition_request( # pylint: disable=name-too-long # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_update_gremlin_role_definition_request( # pylint: disable=name-too-long - resource_group_name: str, account_name: str, role_definition_id: str, subscription_id: str, **kwargs: Any +def build_list_gremlin_role_assignments_request( # pylint: disable=name-too-long + resource_group_name: str, account_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-11-01-preview")) - 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-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/gremlinRoleDefinitions/{roleDefinitionId}", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/gremlinRoleAssignments", ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), @@ -719,7 +739,6 @@ def build_create_update_gremlin_role_definition_request( # pylint: disable=name "accountName": _SERIALIZER.url( "account_name", account_name, "str", max_length=50, min_length=3, pattern=r"^[a-z0-9]+(-[a-z0-9]+)*" ), - "roleDefinitionId": _SERIALIZER.url("role_definition_id", role_definition_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -728,26 +747,24 @@ def build_create_update_gremlin_role_definition_request( # pylint: disable=name _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) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_delete_gremlin_role_definition_request( # pylint: disable=name-too-long - resource_group_name: str, account_name: str, role_definition_id: str, subscription_id: str, **kwargs: Any +def build_get_gremlin_role_assignment_request( # pylint: disable=name-too-long + resource_group_name: str, account_name: str, role_assignment_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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/gremlinRoleDefinitions/{roleDefinitionId}", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/gremlinRoleAssignments/{roleAssignmentId}", ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), @@ -757,7 +774,7 @@ def build_delete_gremlin_role_definition_request( # pylint: disable=name-too-lo "accountName": _SERIALIZER.url( "account_name", account_name, "str", max_length=50, min_length=3, pattern=r"^[a-z0-9]+(-[a-z0-9]+)*" ), - "roleDefinitionId": _SERIALIZER.url("role_definition_id", role_definition_id, "str"), + "roleAssignmentId": _SERIALIZER.url("role_assignment_id", role_assignment_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -768,22 +785,23 @@ def build_delete_gremlin_role_definition_request( # pylint: disable=name-too-lo # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_gremlin_role_definitions_request( # pylint: disable=name-too-long - resource_group_name: str, account_name: str, subscription_id: str, **kwargs: Any +def build_create_update_gremlin_role_assignment_request( # pylint: disable=name-too-long + resource_group_name: str, account_name: str, role_assignment_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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) + 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.DocumentDB/databaseAccounts/{accountName}/gremlinRoleDefinitions", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/gremlinRoleAssignments/{roleAssignmentId}", ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), @@ -793,6 +811,7 @@ def build_list_gremlin_role_definitions_request( # pylint: disable=name-too-lon "accountName": _SERIALIZER.url( "account_name", account_name, "str", max_length=50, min_length=3, pattern=r"^[a-z0-9]+(-[a-z0-9]+)*" ), + "roleAssignmentId": _SERIALIZER.url("role_assignment_id", role_assignment_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -801,18 +820,20 @@ def build_list_gremlin_role_definitions_request( # pylint: disable=name-too-lon _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="GET", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_get_gremlin_role_assignment_request( # pylint: disable=name-too-long +def build_delete_gremlin_role_assignment_request( # pylint: disable=name-too-long resource_group_name: str, account_name: str, role_assignment_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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -839,23 +860,22 @@ def build_get_gremlin_role_assignment_request( # pylint: disable=name-too-long # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_update_gremlin_role_assignment_request( # pylint: disable=name-too-long - resource_group_name: str, account_name: str, role_assignment_id: str, subscription_id: str, **kwargs: Any +def build_list_gremlin_role_definitions_request( # pylint: disable=name-too-long + resource_group_name: str, account_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-11-01-preview")) - 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-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/gremlinRoleAssignments/{roleAssignmentId}", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/gremlinRoleDefinitions", ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), @@ -865,7 +885,6 @@ def build_create_update_gremlin_role_assignment_request( # pylint: disable=name "accountName": _SERIALIZER.url( "account_name", account_name, "str", max_length=50, min_length=3, pattern=r"^[a-z0-9]+(-[a-z0-9]+)*" ), - "roleAssignmentId": _SERIALIZER.url("role_assignment_id", role_assignment_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -874,26 +893,24 @@ def build_create_update_gremlin_role_assignment_request( # pylint: disable=name _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) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_delete_gremlin_role_assignment_request( # pylint: disable=name-too-long - resource_group_name: str, account_name: str, role_assignment_id: str, subscription_id: str, **kwargs: Any +def build_get_gremlin_role_definition_request( # pylint: disable=name-too-long + resource_group_name: str, account_name: str, role_definition_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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/gremlinRoleAssignments/{roleAssignmentId}", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/gremlinRoleDefinitions/{roleDefinitionId}", ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), @@ -903,7 +920,7 @@ def build_delete_gremlin_role_assignment_request( # pylint: disable=name-too-lo "accountName": _SERIALIZER.url( "account_name", account_name, "str", max_length=50, min_length=3, pattern=r"^[a-z0-9]+(-[a-z0-9]+)*" ), - "roleAssignmentId": _SERIALIZER.url("role_assignment_id", role_assignment_id, "str"), + "roleDefinitionId": _SERIALIZER.url("role_definition_id", role_definition_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -914,22 +931,23 @@ def build_delete_gremlin_role_assignment_request( # pylint: disable=name-too-lo # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_gremlin_role_assignments_request( # pylint: disable=name-too-long - resource_group_name: str, account_name: str, subscription_id: str, **kwargs: Any +def build_create_update_gremlin_role_definition_request( # pylint: disable=name-too-long + resource_group_name: str, account_name: str, role_definition_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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) + 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.DocumentDB/databaseAccounts/{accountName}/gremlinRoleAssignments", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/gremlinRoleDefinitions/{roleDefinitionId}", ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), @@ -939,6 +957,7 @@ def build_list_gremlin_role_assignments_request( # pylint: disable=name-too-lon "accountName": _SERIALIZER.url( "account_name", account_name, "str", max_length=50, min_length=3, pattern=r"^[a-z0-9]+(-[a-z0-9]+)*" ), + "roleDefinitionId": _SERIALIZER.url("role_definition_id", role_definition_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -947,30 +966,26 @@ def build_list_gremlin_role_assignments_request( # pylint: disable=name-too-lon _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="GET", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_retrieve_continuous_backup_information_request( # pylint: disable=name-too-long - resource_group_name: str, - account_name: str, - database_name: str, - graph_name: str, - subscription_id: str, - **kwargs: Any +def build_delete_gremlin_role_definition_request( # pylint: disable=name-too-long + resource_group_name: str, account_name: str, role_definition_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-11-01-preview")) - 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-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/gremlinDatabases/{databaseName}/graphs/{graphName}/retrieveContinuousBackupInformation", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/gremlinRoleDefinitions/{roleDefinitionId}", ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), @@ -980,8 +995,7 @@ def build_retrieve_continuous_backup_information_request( # pylint: disable=nam "accountName": _SERIALIZER.url( "account_name", account_name, "str", max_length=50, min_length=3, pattern=r"^[a-z0-9]+(-[a-z0-9]+)*" ), - "databaseName": _SERIALIZER.url("database_name", database_name, "str"), - "graphName": _SERIALIZER.url("graph_name", graph_name, "str"), + "roleDefinitionId": _SERIALIZER.url("role_definition_id", role_definition_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -990,11 +1004,9 @@ def build_retrieve_continuous_backup_information_request( # pylint: disable=nam _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) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) class GremlinResourcesOperations: # pylint: disable=too-many-public-methods @@ -1081,7 +1093,7 @@ def extract_data(pipeline_response): list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore - return None, iter(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): _request = prepare_request(next_link) @@ -1094,7 +1106,11 @@ 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response @@ -1152,9 +1168,13 @@ def get_gremlin_database( if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("GremlinDatabaseGetResults", pipeline_response.http_response) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("GremlinDatabaseGetResults", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -1222,14 +1242,19 @@ def _create_update_gremlin_database_initial( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + 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["azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("azure-AsyncOperation") + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") ) - response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) @@ -1363,7 +1388,9 @@ def get_long_running_output(pipeline_response): return deserialized if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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: @@ -1421,14 +1448,18 @@ def _delete_gremlin_database_initial( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + 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["azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("azure-AsyncOperation") + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") ) - response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) @@ -1481,7 +1512,9 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- return cls(pipeline_response, None, {}) # type: ignore if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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: @@ -1496,11 +1529,10 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore @distributed_trace - def get_gremlin_database_throughput( + def list_gremlin_graphs( self, resource_group_name: str, account_name: str, database_name: str, **kwargs: Any - ) -> _models.ThroughputSettingsGetResults: - """Gets the RUs per second of the Gremlin database under an existing Azure Cosmos DB database - account with the provided name. + ) -> ItemPaged["_models.GremlinGraphGetResults"]: + """Lists the Gremlin graph under an existing Azure Cosmos DB database account. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -1509,8 +1541,101 @@ def get_gremlin_database_throughput( :type account_name: str :param database_name: Cosmos DB database name. Required. :type database_name: str - :return: ThroughputSettingsGetResults or the result of cls(response) - :rtype: ~azure.mgmt.cosmosdb.models.ThroughputSettingsGetResults + :return: An iterator like instance of either GremlinGraphGetResults or the result of + cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cosmosdb.models.GremlinGraphGetResults] + :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.GremlinGraphListResult] = 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_gremlin_graphs_request( + resource_group_name=resource_group_name, + account_name=account_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) + + 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("GremlinGraphListResult", 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_gremlin_graph( + self, resource_group_name: str, account_name: str, database_name: str, graph_name: str, **kwargs: Any + ) -> _models.GremlinGraphGetResults: + """Gets the Gremlin graph under an existing Azure Cosmos DB database account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param database_name: Cosmos DB database name. Required. + :type database_name: str + :param graph_name: Cosmos DB graph name. Required. + :type graph_name: str + :return: GremlinGraphGetResults or the result of cls(response) + :rtype: ~azure.mgmt.cosmosdb.models.GremlinGraphGetResults :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -1525,12 +1650,13 @@ def get_gremlin_database_throughput( _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.ThroughputSettingsGetResults] = kwargs.pop("cls", None) + cls: ClsType[_models.GremlinGraphGetResults] = kwargs.pop("cls", None) - _request = build_get_gremlin_database_throughput_request( + _request = build_get_gremlin_graph_request( resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, + graph_name=graph_name, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, @@ -1547,21 +1673,26 @@ def get_gremlin_database_throughput( if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("ThroughputSettingsGetResults", pipeline_response.http_response) + deserialized = self._deserialize("GremlinGraphGetResults", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - def _update_gremlin_database_throughput_initial( # pylint: disable=name-too-long + def _create_update_gremlin_graph_initial( self, resource_group_name: str, account_name: str, database_name: str, - update_throughput_parameters: Union[_models.ThroughputSettingsUpdateParameters, IO[bytes]], + graph_name: str, + create_update_gremlin_graph_parameters: Union[_models.GremlinGraphCreateUpdateParameters, IO[bytes]], **kwargs: Any ) -> Iterator[bytes]: error_map: MutableMapping = { @@ -1582,15 +1713,16 @@ def _update_gremlin_database_throughput_initial( # pylint: disable=name-too-lon content_type = content_type or "application/json" _json = None _content = None - if isinstance(update_throughput_parameters, (IOBase, bytes)): - _content = update_throughput_parameters + if isinstance(create_update_gremlin_graph_parameters, (IOBase, bytes)): + _content = create_update_gremlin_graph_parameters else: - _json = self._serialize.body(update_throughput_parameters, "ThroughputSettingsUpdateParameters") + _json = self._serialize.body(create_update_gremlin_graph_parameters, "GremlinGraphCreateUpdateParameters") - _request = build_update_gremlin_database_throughput_request( + _request = build_create_update_gremlin_graph_request( resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, + graph_name=graph_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, @@ -1615,14 +1747,19 @@ def _update_gremlin_database_throughput_initial( # pylint: disable=name-too-lon except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + 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["azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("azure-AsyncOperation") + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") ) - response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) @@ -1632,17 +1769,18 @@ def _update_gremlin_database_throughput_initial( # pylint: disable=name-too-lon return deserialized # type: ignore @overload - def begin_update_gremlin_database_throughput( + def begin_create_update_gremlin_graph( self, resource_group_name: str, account_name: str, database_name: str, - update_throughput_parameters: _models.ThroughputSettingsUpdateParameters, + graph_name: str, + create_update_gremlin_graph_parameters: _models.GremlinGraphCreateUpdateParameters, *, content_type: str = "application/json", **kwargs: Any - ) -> LROPoller[_models.ThroughputSettingsGetResults]: - """Update RUs per second of an Azure Cosmos DB Gremlin database. + ) -> LROPoller[_models.GremlinGraphGetResults]: + """Create or update an Azure Cosmos DB Gremlin graph. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -1651,31 +1789,34 @@ def begin_update_gremlin_database_throughput( :type account_name: str :param database_name: Cosmos DB database name. Required. :type database_name: str - :param update_throughput_parameters: The RUs per second of the parameters to provide for the - current Gremlin database. Required. - :type update_throughput_parameters: - ~azure.mgmt.cosmosdb.models.ThroughputSettingsUpdateParameters + :param graph_name: Cosmos DB graph name. Required. + :type graph_name: str + :param create_update_gremlin_graph_parameters: The parameters to provide for the current + Gremlin graph. Required. + :type create_update_gremlin_graph_parameters: + ~azure.mgmt.cosmosdb.models.GremlinGraphCreateUpdateParameters :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 ThroughputSettingsGetResults or the - result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.ThroughputSettingsGetResults] + :return: An instance of LROPoller that returns either GremlinGraphGetResults or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.GremlinGraphGetResults] :raises ~azure.core.exceptions.HttpResponseError: """ @overload - def begin_update_gremlin_database_throughput( + def begin_create_update_gremlin_graph( self, resource_group_name: str, account_name: str, database_name: str, - update_throughput_parameters: IO[bytes], + graph_name: str, + create_update_gremlin_graph_parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> LROPoller[_models.ThroughputSettingsGetResults]: - """Update RUs per second of an Azure Cosmos DB Gremlin database. + ) -> LROPoller[_models.GremlinGraphGetResults]: + """Create or update an Azure Cosmos DB Gremlin graph. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -1684,28 +1825,31 @@ def begin_update_gremlin_database_throughput( :type account_name: str :param database_name: Cosmos DB database name. Required. :type database_name: str - :param update_throughput_parameters: The RUs per second of the parameters to provide for the - current Gremlin database. Required. - :type update_throughput_parameters: IO[bytes] + :param graph_name: Cosmos DB graph name. Required. + :type graph_name: str + :param create_update_gremlin_graph_parameters: The parameters to provide for the current + Gremlin graph. Required. + :type create_update_gremlin_graph_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 ThroughputSettingsGetResults or the - result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.ThroughputSettingsGetResults] + :return: An instance of LROPoller that returns either GremlinGraphGetResults or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.GremlinGraphGetResults] :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace - def begin_update_gremlin_database_throughput( + def begin_create_update_gremlin_graph( self, resource_group_name: str, account_name: str, database_name: str, - update_throughput_parameters: Union[_models.ThroughputSettingsUpdateParameters, IO[bytes]], + graph_name: str, + create_update_gremlin_graph_parameters: Union[_models.GremlinGraphCreateUpdateParameters, IO[bytes]], **kwargs: Any - ) -> LROPoller[_models.ThroughputSettingsGetResults]: - """Update RUs per second of an Azure Cosmos DB Gremlin database. + ) -> LROPoller[_models.GremlinGraphGetResults]: + """Create or update an Azure Cosmos DB Gremlin graph. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -1714,14 +1858,16 @@ def begin_update_gremlin_database_throughput( :type account_name: str :param database_name: Cosmos DB database name. Required. :type database_name: str - :param update_throughput_parameters: The RUs per second of the parameters to provide for the - current Gremlin database. Is either a ThroughputSettingsUpdateParameters type or a IO[bytes] - type. Required. - :type update_throughput_parameters: - ~azure.mgmt.cosmosdb.models.ThroughputSettingsUpdateParameters or IO[bytes] - :return: An instance of LROPoller that returns either ThroughputSettingsGetResults or the - result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.ThroughputSettingsGetResults] + :param graph_name: Cosmos DB graph name. Required. + :type graph_name: str + :param create_update_gremlin_graph_parameters: The parameters to provide for the current + Gremlin graph. Is either a GremlinGraphCreateUpdateParameters type or a IO[bytes] type. + Required. + :type create_update_gremlin_graph_parameters: + ~azure.mgmt.cosmosdb.models.GremlinGraphCreateUpdateParameters or IO[bytes] + :return: An instance of LROPoller that returns either GremlinGraphGetResults or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.GremlinGraphGetResults] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -1729,16 +1875,17 @@ def begin_update_gremlin_database_throughput( 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.ThroughputSettingsGetResults] = kwargs.pop("cls", None) + cls: ClsType[_models.GremlinGraphGetResults] = 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_gremlin_database_throughput_initial( + raw_result = self._create_update_gremlin_graph_initial( resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, - update_throughput_parameters=update_throughput_parameters, + graph_name=graph_name, + create_update_gremlin_graph_parameters=create_update_gremlin_graph_parameters, api_version=api_version, content_type=content_type, cls=lambda x, y, z: x, @@ -1750,30 +1897,32 @@ def begin_update_gremlin_database_throughput( kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ThroughputSettingsGetResults", pipeline_response.http_response) + deserialized = self._deserialize("GremlinGraphGetResults", 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, **kwargs)) + 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.ThroughputSettingsGetResults].from_continuation_token( + return LROPoller[_models.GremlinGraphGetResults].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller[_models.ThroughputSettingsGetResults]( + return LROPoller[_models.GremlinGraphGetResults]( self._client, raw_result, get_long_running_output, polling_method # type: ignore ) - def _migrate_gremlin_database_to_autoscale_initial( # pylint: disable=name-too-long - self, resource_group_name: str, account_name: str, database_name: str, **kwargs: Any + def _delete_gremlin_graph_initial( + self, resource_group_name: str, account_name: str, database_name: str, graph_name: str, **kwargs: Any ) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -1789,10 +1938,11 @@ def _migrate_gremlin_database_to_autoscale_initial( # pylint: disable=name-too- 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_migrate_gremlin_database_to_autoscale_request( + _request = build_delete_gremlin_graph_request( resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, + graph_name=graph_name, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, @@ -1808,20 +1958,24 @@ def _migrate_gremlin_database_to_autoscale_initial( # pylint: disable=name-too- response = pipeline_response.http_response - if response.status_code not in [200, 202]: + 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + 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["azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("azure-AsyncOperation") + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") ) - response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) @@ -1831,10 +1985,10 @@ def _migrate_gremlin_database_to_autoscale_initial( # pylint: disable=name-too- return deserialized # type: ignore @distributed_trace - def begin_migrate_gremlin_database_to_autoscale( # pylint: disable=name-too-long - self, resource_group_name: str, account_name: str, database_name: str, **kwargs: Any - ) -> LROPoller[_models.ThroughputSettingsGetResults]: - """Migrate an Azure Cosmos DB Gremlin database from manual throughput to autoscale. + def begin_delete_gremlin_graph( + self, resource_group_name: str, account_name: str, database_name: str, graph_name: str, **kwargs: Any + ) -> LROPoller[None]: + """Deletes an existing Azure Cosmos DB Gremlin graph. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -1843,24 +1997,26 @@ def begin_migrate_gremlin_database_to_autoscale( # pylint: disable=name-too-lon :type account_name: str :param database_name: Cosmos DB database name. Required. :type database_name: str - :return: An instance of LROPoller that returns either ThroughputSettingsGetResults or the - result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.ThroughputSettingsGetResults] + :param graph_name: Cosmos DB graph name. Required. + :type graph_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[_models.ThroughputSettingsGetResults] = kwargs.pop("cls", 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._migrate_gremlin_database_to_autoscale_initial( + raw_result = self._delete_gremlin_graph_initial( resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, + graph_name=graph_name, api_version=api_version, cls=lambda x, y, z: x, headers=_headers, @@ -1870,31 +2026,35 @@ def begin_migrate_gremlin_database_to_autoscale( # pylint: disable=name-too-lon raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ThroughputSettingsGetResults", pipeline_response.http_response) + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return cls(pipeline_response, None, {}) # type: ignore if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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.ThroughputSettingsGetResults].from_continuation_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[_models.ThroughputSettingsGetResults]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - def _migrate_gremlin_database_to_manual_throughput_initial( # pylint: disable=name-too-long - self, resource_group_name: str, account_name: str, database_name: str, **kwargs: Any + def _retrieve_continuous_backup_information_initial( # pylint: disable=name-too-long + self, + resource_group_name: str, + account_name: str, + database_name: str, + graph_name: str, + location: Union[_models.ContinuousBackupRestoreLocation, IO[bytes]], + **kwargs: Any ) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -1904,18 +2064,31 @@ def _migrate_gremlin_database_to_manual_throughput_initial( # pylint: disable=n } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) 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) - _request = build_migrate_gremlin_database_to_manual_throughput_request( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(location, (IOBase, bytes)): + _content = location + else: + _json = self._serialize.body(location, "ContinuousBackupRestoreLocation") + + _request = build_retrieve_continuous_backup_information_request( resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, + graph_name=graph_name, subscription_id=self._config.subscription_id, api_version=api_version, + content_type=content_type, + json=_json, + content=_content, headers=_headers, params=_params, ) @@ -1939,10 +2112,8 @@ def _migrate_gremlin_database_to_manual_throughput_initial( # pylint: disable=n 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["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) @@ -1951,11 +2122,85 @@ def _migrate_gremlin_database_to_manual_throughput_initial( # pylint: disable=n return deserialized # type: ignore + @overload + def begin_retrieve_continuous_backup_information( # pylint: disable=name-too-long + self, + resource_group_name: str, + account_name: str, + database_name: str, + graph_name: str, + location: _models.ContinuousBackupRestoreLocation, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.BackupInformation]: + """Retrieves continuous backup information for a gremlin graph. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param database_name: Cosmos DB database name. Required. + :type database_name: str + :param graph_name: Cosmos DB graph name. Required. + :type graph_name: str + :param location: The name of the continuous backup restore location. Required. + :type location: ~azure.mgmt.cosmosdb.models.ContinuousBackupRestoreLocation + :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 BackupInformation or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.BackupInformation] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_retrieve_continuous_backup_information( # pylint: disable=name-too-long + self, + resource_group_name: str, + account_name: str, + database_name: str, + graph_name: str, + location: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.BackupInformation]: + """Retrieves continuous backup information for a gremlin graph. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param database_name: Cosmos DB database name. Required. + :type database_name: str + :param graph_name: Cosmos DB graph name. Required. + :type graph_name: str + :param location: The name of the continuous backup restore location. Required. + :type location: 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 BackupInformation or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.BackupInformation] + :raises ~azure.core.exceptions.HttpResponseError: + """ + @distributed_trace - def begin_migrate_gremlin_database_to_manual_throughput( # pylint: disable=name-too-long - self, resource_group_name: str, account_name: str, database_name: str, **kwargs: Any - ) -> LROPoller[_models.ThroughputSettingsGetResults]: - """Migrate an Azure Cosmos DB Gremlin database from autoscale to manual throughput. + def begin_retrieve_continuous_backup_information( # pylint: disable=name-too-long + self, + resource_group_name: str, + account_name: str, + database_name: str, + graph_name: str, + location: Union[_models.ContinuousBackupRestoreLocation, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.BackupInformation]: + """Retrieves continuous backup information for a gremlin graph. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -1964,25 +2209,34 @@ def begin_migrate_gremlin_database_to_manual_throughput( # pylint: disable=name :type account_name: str :param database_name: Cosmos DB database name. Required. :type database_name: str - :return: An instance of LROPoller that returns either ThroughputSettingsGetResults or the - result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.ThroughputSettingsGetResults] + :param graph_name: Cosmos DB graph name. Required. + :type graph_name: str + :param location: The name of the continuous backup restore location. Is either a + ContinuousBackupRestoreLocation type or a IO[bytes] type. Required. + :type location: ~azure.mgmt.cosmosdb.models.ContinuousBackupRestoreLocation or IO[bytes] + :return: An instance of LROPoller that returns either BackupInformation or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.BackupInformation] :raises ~azure.core.exceptions.HttpResponseError: """ - _headers = kwargs.pop("headers", {}) 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)) - cls: ClsType[_models.ThroughputSettingsGetResults] = kwargs.pop("cls", None) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.BackupInformation] = 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_gremlin_database_to_manual_throughput_initial( + raw_result = self._retrieve_continuous_backup_information_initial( resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, + graph_name=graph_name, + location=location, api_version=api_version, + content_type=content_type, cls=lambda x, y, z: x, headers=_headers, params=_params, @@ -1992,33 +2246,36 @@ def begin_migrate_gremlin_database_to_manual_throughput( # pylint: disable=name kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ThroughputSettingsGetResults", pipeline_response.http_response) + deserialized = self._deserialize("BackupInformation", 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, **kwargs)) + 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.ThroughputSettingsGetResults].from_continuation_token( + return LROPoller[_models.BackupInformation].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller[_models.ThroughputSettingsGetResults]( + return LROPoller[_models.BackupInformation]( self._client, raw_result, get_long_running_output, polling_method # type: ignore ) @distributed_trace - def list_gremlin_graphs( - self, resource_group_name: str, account_name: str, database_name: str, **kwargs: Any - ) -> ItemPaged["_models.GremlinGraphGetResults"]: - """Lists the Gremlin graph under an existing Azure Cosmos DB database account. + def get_gremlin_graph_throughput( + self, resource_group_name: str, account_name: str, database_name: str, graph_name: str, **kwargs: Any + ) -> _models.ThroughputSettingsGetResults: + """Gets the Gremlin graph throughput under an existing Azure Cosmos DB database account with the + provided name. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -2027,152 +2284,69 @@ def list_gremlin_graphs( :type account_name: str :param database_name: Cosmos DB database name. Required. :type database_name: str - :return: An iterator like instance of either GremlinGraphGetResults or the result of - cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cosmosdb.models.GremlinGraphGetResults] + :param graph_name: Cosmos DB graph name. Required. + :type graph_name: str + :return: ThroughputSettingsGetResults or the result of cls(response) + :rtype: ~azure.mgmt.cosmosdb.models.ThroughputSettingsGetResults :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.GremlinGraphListResult] = kwargs.pop("cls", None) + cls: ClsType[_models.ThroughputSettingsGetResults] = kwargs.pop("cls", None) + + _request = build_get_gremlin_graph_throughput_request( + resource_group_name=resource_group_name, + account_name=account_name, + database_name=database_name, + graph_name=graph_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) - 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_gremlin_graphs_request( - resource_group_name=resource_group_name, - account_name=account_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) - - 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("GremlinGraphListResult", 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def get_gremlin_graph( - self, resource_group_name: str, account_name: str, database_name: str, graph_name: str, **kwargs: Any - ) -> _models.GremlinGraphGetResults: - """Gets the Gremlin graph under an existing Azure Cosmos DB database account. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param account_name: Cosmos DB database account name. Required. - :type account_name: str - :param database_name: Cosmos DB database name. Required. - :type database_name: str - :param graph_name: Cosmos DB graph name. Required. - :type graph_name: str - :return: GremlinGraphGetResults or the result of cls(response) - :rtype: ~azure.mgmt.cosmosdb.models.GremlinGraphGetResults - :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.GremlinGraphGetResults] = kwargs.pop("cls", None) - - _request = build_get_gremlin_graph_request( - resource_group_name=resource_group_name, - account_name=account_name, - database_name=database_name, - graph_name=graph_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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("GremlinGraphGetResults", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - def _create_update_gremlin_graph_initial( - self, - resource_group_name: str, - account_name: str, - database_name: str, - graph_name: str, - create_update_gremlin_graph_parameters: Union[_models.GremlinGraphCreateUpdateParameters, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: + _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("ThroughputSettingsGetResults", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + def _update_gremlin_graph_throughput_initial( + self, + resource_group_name: str, + account_name: str, + database_name: str, + graph_name: str, + update_throughput_parameters: Union[_models.ThroughputSettingsUpdateParameters, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -2191,12 +2365,12 @@ def _create_update_gremlin_graph_initial( content_type = content_type or "application/json" _json = None _content = None - if isinstance(create_update_gremlin_graph_parameters, (IOBase, bytes)): - _content = create_update_gremlin_graph_parameters + if isinstance(update_throughput_parameters, (IOBase, bytes)): + _content = update_throughput_parameters else: - _json = self._serialize.body(create_update_gremlin_graph_parameters, "GremlinGraphCreateUpdateParameters") + _json = self._serialize.body(update_throughput_parameters, "ThroughputSettingsUpdateParameters") - _request = build_create_update_gremlin_graph_request( + _request = build_update_gremlin_graph_throughput_request( resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, @@ -2225,14 +2399,19 @@ def _create_update_gremlin_graph_initial( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + 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["azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("azure-AsyncOperation") + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") ) - response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) @@ -2242,18 +2421,18 @@ def _create_update_gremlin_graph_initial( return deserialized # type: ignore @overload - def begin_create_update_gremlin_graph( + def begin_update_gremlin_graph_throughput( self, resource_group_name: str, account_name: str, database_name: str, graph_name: str, - create_update_gremlin_graph_parameters: _models.GremlinGraphCreateUpdateParameters, + update_throughput_parameters: _models.ThroughputSettingsUpdateParameters, *, content_type: str = "application/json", **kwargs: Any - ) -> LROPoller[_models.GremlinGraphGetResults]: - """Create or update an Azure Cosmos DB Gremlin graph. + ) -> LROPoller[_models.ThroughputSettingsGetResults]: + """Update RUs per second of an Azure Cosmos DB Gremlin graph. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -2264,32 +2443,32 @@ def begin_create_update_gremlin_graph( :type database_name: str :param graph_name: Cosmos DB graph name. Required. :type graph_name: str - :param create_update_gremlin_graph_parameters: The parameters to provide for the current - Gremlin graph. Required. - :type create_update_gremlin_graph_parameters: - ~azure.mgmt.cosmosdb.models.GremlinGraphCreateUpdateParameters + :param update_throughput_parameters: The RUs per second of the parameters to provide for the + current Gremlin graph. Required. + :type update_throughput_parameters: + ~azure.mgmt.cosmosdb.models.ThroughputSettingsUpdateParameters :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 GremlinGraphGetResults or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.GremlinGraphGetResults] + :return: An instance of LROPoller that returns either ThroughputSettingsGetResults or the + result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.ThroughputSettingsGetResults] :raises ~azure.core.exceptions.HttpResponseError: """ @overload - def begin_create_update_gremlin_graph( + def begin_update_gremlin_graph_throughput( self, resource_group_name: str, account_name: str, database_name: str, graph_name: str, - create_update_gremlin_graph_parameters: IO[bytes], + update_throughput_parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> LROPoller[_models.GremlinGraphGetResults]: - """Create or update an Azure Cosmos DB Gremlin graph. + ) -> LROPoller[_models.ThroughputSettingsGetResults]: + """Update RUs per second of an Azure Cosmos DB Gremlin graph. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -2300,29 +2479,29 @@ def begin_create_update_gremlin_graph( :type database_name: str :param graph_name: Cosmos DB graph name. Required. :type graph_name: str - :param create_update_gremlin_graph_parameters: The parameters to provide for the current - Gremlin graph. Required. - :type create_update_gremlin_graph_parameters: IO[bytes] + :param update_throughput_parameters: The RUs per second of the parameters to provide for the + current Gremlin graph. Required. + :type update_throughput_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 GremlinGraphGetResults or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.GremlinGraphGetResults] + :return: An instance of LROPoller that returns either ThroughputSettingsGetResults or the + result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.ThroughputSettingsGetResults] :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace - def begin_create_update_gremlin_graph( + def begin_update_gremlin_graph_throughput( self, resource_group_name: str, account_name: str, database_name: str, graph_name: str, - create_update_gremlin_graph_parameters: Union[_models.GremlinGraphCreateUpdateParameters, IO[bytes]], + update_throughput_parameters: Union[_models.ThroughputSettingsUpdateParameters, IO[bytes]], **kwargs: Any - ) -> LROPoller[_models.GremlinGraphGetResults]: - """Create or update an Azure Cosmos DB Gremlin graph. + ) -> LROPoller[_models.ThroughputSettingsGetResults]: + """Update RUs per second of an Azure Cosmos DB Gremlin graph. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -2333,14 +2512,14 @@ def begin_create_update_gremlin_graph( :type database_name: str :param graph_name: Cosmos DB graph name. Required. :type graph_name: str - :param create_update_gremlin_graph_parameters: The parameters to provide for the current - Gremlin graph. Is either a GremlinGraphCreateUpdateParameters type or a IO[bytes] type. + :param update_throughput_parameters: The RUs per second of the parameters to provide for the + current Gremlin graph. Is either a ThroughputSettingsUpdateParameters type or a IO[bytes] type. Required. - :type create_update_gremlin_graph_parameters: - ~azure.mgmt.cosmosdb.models.GremlinGraphCreateUpdateParameters or IO[bytes] - :return: An instance of LROPoller that returns either GremlinGraphGetResults or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.GremlinGraphGetResults] + :type update_throughput_parameters: + ~azure.mgmt.cosmosdb.models.ThroughputSettingsUpdateParameters or IO[bytes] + :return: An instance of LROPoller that returns either ThroughputSettingsGetResults or the + result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.ThroughputSettingsGetResults] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -2348,17 +2527,17 @@ def begin_create_update_gremlin_graph( 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.GremlinGraphGetResults] = kwargs.pop("cls", None) + cls: ClsType[_models.ThroughputSettingsGetResults] = 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_update_gremlin_graph_initial( + raw_result = self._update_gremlin_graph_throughput_initial( resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, graph_name=graph_name, - create_update_gremlin_graph_parameters=create_update_gremlin_graph_parameters, + update_throughput_parameters=update_throughput_parameters, api_version=api_version, content_type=content_type, cls=lambda x, y, z: x, @@ -2370,29 +2549,31 @@ def begin_create_update_gremlin_graph( kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("GremlinGraphGetResults", pipeline_response.http_response) + deserialized = self._deserialize("ThroughputSettingsGetResults", 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, **kwargs)) + 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.GremlinGraphGetResults].from_continuation_token( + return LROPoller[_models.ThroughputSettingsGetResults].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller[_models.GremlinGraphGetResults]( + return LROPoller[_models.ThroughputSettingsGetResults]( self._client, raw_result, get_long_running_output, polling_method # type: ignore ) - def _delete_gremlin_graph_initial( + def _migrate_gremlin_graph_to_autoscale_initial( # pylint: disable=name-too-long self, resource_group_name: str, account_name: str, database_name: str, graph_name: str, **kwargs: Any ) -> Iterator[bytes]: error_map: MutableMapping = { @@ -2409,7 +2590,7 @@ def _delete_gremlin_graph_initial( 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_gremlin_graph_request( + _request = build_migrate_gremlin_graph_to_autoscale_request( resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, @@ -2429,7 +2610,7 @@ def _delete_gremlin_graph_initial( response = pipeline_response.http_response - if response.status_code not in [202, 204]: + if response.status_code not in [200, 202]: try: response.read() # Load the body in memory and close the socket except (StreamConsumedError, StreamClosedError): @@ -2439,10 +2620,11 @@ def _delete_gremlin_graph_initial( response_headers = {} if response.status_code == 202: - response_headers["azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("azure-AsyncOperation") + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") ) - response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) @@ -2452,10 +2634,10 @@ def _delete_gremlin_graph_initial( return deserialized # type: ignore @distributed_trace - def begin_delete_gremlin_graph( + def begin_migrate_gremlin_graph_to_autoscale( self, resource_group_name: str, account_name: str, database_name: str, graph_name: str, **kwargs: Any - ) -> LROPoller[None]: - """Deletes an existing Azure Cosmos DB Gremlin graph. + ) -> LROPoller[_models.ThroughputSettingsGetResults]: + """Migrate an Azure Cosmos DB Gremlin graph from manual throughput to autoscale. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -2466,20 +2648,21 @@ def begin_delete_gremlin_graph( :type database_name: str :param graph_name: Cosmos DB graph name. Required. :type graph_name: str - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] + :return: An instance of LROPoller that returns either ThroughputSettingsGetResults or the + result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.ThroughputSettingsGetResults] :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) + cls: ClsType[_models.ThroughputSettingsGetResults] = 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_gremlin_graph_initial( + raw_result = self._migrate_gremlin_graph_to_autoscale_initial( resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, @@ -2493,31 +2676,96 @@ def begin_delete_gremlin_graph( raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("ThroughputSettingsGetResults", pipeline_response.http_response) if cls: - return cls(pipeline_response, None, {}) # type: ignore + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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( + return LROPoller[_models.ThroughputSettingsGetResults].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 + return LROPoller[_models.ThroughputSettingsGetResults]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + def _migrate_gremlin_graph_to_manual_throughput_initial( # pylint: disable=name-too-long + self, resource_group_name: str, account_name: str, database_name: str, graph_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_migrate_gremlin_graph_to_manual_throughput_request( + resource_group_name=resource_group_name, + account_name=account_name, + database_name=database_name, + graph_name=graph_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) + raise HttpResponseError(response=response, 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.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 get_gremlin_graph_throughput( + def begin_migrate_gremlin_graph_to_manual_throughput( # pylint: disable=name-too-long self, resource_group_name: str, account_name: str, database_name: str, graph_name: str, **kwargs: Any - ) -> _models.ThroughputSettingsGetResults: - """Gets the Gremlin graph throughput under an existing Azure Cosmos DB database account with the - provided name. + ) -> LROPoller[_models.ThroughputSettingsGetResults]: + """Migrate an Azure Cosmos DB Gremlin graph from autoscale to manual throughput. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -2528,6 +2776,73 @@ def get_gremlin_graph_throughput( :type database_name: str :param graph_name: Cosmos DB graph name. Required. :type graph_name: str + :return: An instance of LROPoller that returns either ThroughputSettingsGetResults or the + result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.ThroughputSettingsGetResults] + :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.ThroughputSettingsGetResults] = 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_gremlin_graph_to_manual_throughput_initial( + resource_group_name=resource_group_name, + account_name=account_name, + database_name=database_name, + graph_name=graph_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("ThroughputSettingsGetResults", 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": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.ThroughputSettingsGetResults].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.ThroughputSettingsGetResults]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + @distributed_trace + def get_gremlin_database_throughput( + self, resource_group_name: str, account_name: str, database_name: str, **kwargs: Any + ) -> _models.ThroughputSettingsGetResults: + """Gets the RUs per second of the Gremlin database under an existing Azure Cosmos DB database + account with the provided name. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param database_name: Cosmos DB database name. Required. + :type database_name: str :return: ThroughputSettingsGetResults or the result of cls(response) :rtype: ~azure.mgmt.cosmosdb.models.ThroughputSettingsGetResults :raises ~azure.core.exceptions.HttpResponseError: @@ -2546,11 +2861,10 @@ def get_gremlin_graph_throughput( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ThroughputSettingsGetResults] = kwargs.pop("cls", None) - _request = build_get_gremlin_graph_throughput_request( + _request = build_get_gremlin_database_throughput_request( resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, - graph_name=graph_name, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, @@ -2567,7 +2881,11 @@ def get_gremlin_graph_throughput( if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("ThroughputSettingsGetResults", pipeline_response.http_response) @@ -2576,12 +2894,11 @@ def get_gremlin_graph_throughput( return deserialized # type: ignore - def _update_gremlin_graph_throughput_initial( + def _update_gremlin_database_throughput_initial( # pylint: disable=name-too-long self, resource_group_name: str, account_name: str, database_name: str, - graph_name: str, update_throughput_parameters: Union[_models.ThroughputSettingsUpdateParameters, IO[bytes]], **kwargs: Any ) -> Iterator[bytes]: @@ -2608,11 +2925,10 @@ def _update_gremlin_graph_throughput_initial( else: _json = self._serialize.body(update_throughput_parameters, "ThroughputSettingsUpdateParameters") - _request = build_update_gremlin_graph_throughput_request( + _request = build_update_gremlin_database_throughput_request( resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, - graph_name=graph_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, @@ -2637,14 +2953,19 @@ def _update_gremlin_graph_throughput_initial( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + 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["azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("azure-AsyncOperation") + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") ) - response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) @@ -2654,18 +2975,17 @@ def _update_gremlin_graph_throughput_initial( return deserialized # type: ignore @overload - def begin_update_gremlin_graph_throughput( + def begin_update_gremlin_database_throughput( self, resource_group_name: str, account_name: str, database_name: str, - graph_name: str, update_throughput_parameters: _models.ThroughputSettingsUpdateParameters, *, content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.ThroughputSettingsGetResults]: - """Update RUs per second of an Azure Cosmos DB Gremlin graph. + """Update RUs per second of an Azure Cosmos DB Gremlin database. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -2674,10 +2994,8 @@ def begin_update_gremlin_graph_throughput( :type account_name: str :param database_name: Cosmos DB database name. Required. :type database_name: str - :param graph_name: Cosmos DB graph name. Required. - :type graph_name: str :param update_throughput_parameters: The RUs per second of the parameters to provide for the - current Gremlin graph. Required. + current Gremlin database. Required. :type update_throughput_parameters: ~azure.mgmt.cosmosdb.models.ThroughputSettingsUpdateParameters :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. @@ -2690,18 +3008,17 @@ def begin_update_gremlin_graph_throughput( """ @overload - def begin_update_gremlin_graph_throughput( + def begin_update_gremlin_database_throughput( self, resource_group_name: str, account_name: str, database_name: str, - graph_name: str, update_throughput_parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.ThroughputSettingsGetResults]: - """Update RUs per second of an Azure Cosmos DB Gremlin graph. + """Update RUs per second of an Azure Cosmos DB Gremlin database. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -2710,10 +3027,8 @@ def begin_update_gremlin_graph_throughput( :type account_name: str :param database_name: Cosmos DB database name. Required. :type database_name: str - :param graph_name: Cosmos DB graph name. Required. - :type graph_name: str :param update_throughput_parameters: The RUs per second of the parameters to provide for the - current Gremlin graph. Required. + current Gremlin database. Required. :type update_throughput_parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". @@ -2725,16 +3040,15 @@ def begin_update_gremlin_graph_throughput( """ @distributed_trace - def begin_update_gremlin_graph_throughput( + def begin_update_gremlin_database_throughput( self, resource_group_name: str, account_name: str, database_name: str, - graph_name: str, update_throughput_parameters: Union[_models.ThroughputSettingsUpdateParameters, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.ThroughputSettingsGetResults]: - """Update RUs per second of an Azure Cosmos DB Gremlin graph. + """Update RUs per second of an Azure Cosmos DB Gremlin database. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -2743,11 +3057,9 @@ def begin_update_gremlin_graph_throughput( :type account_name: str :param database_name: Cosmos DB database name. Required. :type database_name: str - :param graph_name: Cosmos DB graph name. Required. - :type graph_name: str :param update_throughput_parameters: The RUs per second of the parameters to provide for the - current Gremlin graph. Is either a ThroughputSettingsUpdateParameters type or a IO[bytes] type. - Required. + current Gremlin database. Is either a ThroughputSettingsUpdateParameters type or a IO[bytes] + type. Required. :type update_throughput_parameters: ~azure.mgmt.cosmosdb.models.ThroughputSettingsUpdateParameters or IO[bytes] :return: An instance of LROPoller that returns either ThroughputSettingsGetResults or the @@ -2765,11 +3077,10 @@ def begin_update_gremlin_graph_throughput( 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_gremlin_graph_throughput_initial( + raw_result = self._update_gremlin_database_throughput_initial( resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, - graph_name=graph_name, update_throughput_parameters=update_throughput_parameters, api_version=api_version, content_type=content_type, @@ -2788,7 +3099,9 @@ def get_long_running_output(pipeline_response): return deserialized if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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: @@ -2804,8 +3117,8 @@ def get_long_running_output(pipeline_response): self._client, raw_result, get_long_running_output, polling_method # type: ignore ) - def _migrate_gremlin_graph_to_autoscale_initial( # pylint: disable=name-too-long - self, resource_group_name: str, account_name: str, database_name: str, graph_name: str, **kwargs: Any + def _migrate_gremlin_database_to_autoscale_initial( # pylint: disable=name-too-long + self, resource_group_name: str, account_name: str, database_name: str, **kwargs: Any ) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -2821,11 +3134,10 @@ def _migrate_gremlin_graph_to_autoscale_initial( # pylint: disable=name-too-lon 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_migrate_gremlin_graph_to_autoscale_request( + _request = build_migrate_gremlin_database_to_autoscale_request( resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, - graph_name=graph_name, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, @@ -2851,10 +3163,11 @@ def _migrate_gremlin_graph_to_autoscale_initial( # pylint: disable=name-too-lon response_headers = {} if response.status_code == 202: - response_headers["azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("azure-AsyncOperation") + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") ) - response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) @@ -2864,10 +3177,10 @@ def _migrate_gremlin_graph_to_autoscale_initial( # pylint: disable=name-too-lon return deserialized # type: ignore @distributed_trace - def begin_migrate_gremlin_graph_to_autoscale( - self, resource_group_name: str, account_name: str, database_name: str, graph_name: str, **kwargs: Any + def begin_migrate_gremlin_database_to_autoscale( # pylint: disable=name-too-long + self, resource_group_name: str, account_name: str, database_name: str, **kwargs: Any ) -> LROPoller[_models.ThroughputSettingsGetResults]: - """Migrate an Azure Cosmos DB Gremlin graph from manual throughput to autoscale. + """Migrate an Azure Cosmos DB Gremlin database from manual throughput to autoscale. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -2876,8 +3189,6 @@ def begin_migrate_gremlin_graph_to_autoscale( :type account_name: str :param database_name: Cosmos DB database name. Required. :type database_name: str - :param graph_name: Cosmos DB graph name. Required. - :type graph_name: str :return: An instance of LROPoller that returns either ThroughputSettingsGetResults or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.ThroughputSettingsGetResults] @@ -2892,11 +3203,10 @@ def begin_migrate_gremlin_graph_to_autoscale( 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_gremlin_graph_to_autoscale_initial( + raw_result = self._migrate_gremlin_database_to_autoscale_initial( resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, - graph_name=graph_name, api_version=api_version, cls=lambda x, y, z: x, headers=_headers, @@ -2913,7 +3223,9 @@ def get_long_running_output(pipeline_response): return deserialized if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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: @@ -2929,8 +3241,8 @@ def get_long_running_output(pipeline_response): self._client, raw_result, get_long_running_output, polling_method # type: ignore ) - def _migrate_gremlin_graph_to_manual_throughput_initial( # pylint: disable=name-too-long - self, resource_group_name: str, account_name: str, database_name: str, graph_name: str, **kwargs: Any + def _migrate_gremlin_database_to_manual_throughput_initial( # pylint: disable=name-too-long + self, resource_group_name: str, account_name: str, database_name: str, **kwargs: Any ) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -2946,11 +3258,10 @@ def _migrate_gremlin_graph_to_manual_throughput_initial( # pylint: disable=name 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_migrate_gremlin_graph_to_manual_throughput_request( + _request = build_migrate_gremlin_database_to_manual_throughput_request( resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, - graph_name=graph_name, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, @@ -2976,10 +3287,11 @@ def _migrate_gremlin_graph_to_manual_throughput_initial( # pylint: disable=name response_headers = {} if response.status_code == 202: - response_headers["azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("azure-AsyncOperation") + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") ) - response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) @@ -2989,10 +3301,10 @@ def _migrate_gremlin_graph_to_manual_throughput_initial( # pylint: disable=name return deserialized # type: ignore @distributed_trace - def begin_migrate_gremlin_graph_to_manual_throughput( # pylint: disable=name-too-long - self, resource_group_name: str, account_name: str, database_name: str, graph_name: str, **kwargs: Any + def begin_migrate_gremlin_database_to_manual_throughput( # pylint: disable=name-too-long + self, resource_group_name: str, account_name: str, database_name: str, **kwargs: Any ) -> LROPoller[_models.ThroughputSettingsGetResults]: - """Migrate an Azure Cosmos DB Gremlin graph from autoscale to manual throughput. + """Migrate an Azure Cosmos DB Gremlin database from autoscale to manual throughput. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -3001,8 +3313,6 @@ def begin_migrate_gremlin_graph_to_manual_throughput( # pylint: disable=name-to :type account_name: str :param database_name: Cosmos DB database name. Required. :type database_name: str - :param graph_name: Cosmos DB graph name. Required. - :type graph_name: str :return: An instance of LROPoller that returns either ThroughputSettingsGetResults or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.ThroughputSettingsGetResults] @@ -3017,11 +3327,10 @@ def begin_migrate_gremlin_graph_to_manual_throughput( # pylint: disable=name-to 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_gremlin_graph_to_manual_throughput_initial( + raw_result = self._migrate_gremlin_database_to_manual_throughput_initial( resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, - graph_name=graph_name, api_version=api_version, cls=lambda x, y, z: x, headers=_headers, @@ -3038,7 +3347,9 @@ def get_long_running_output(pipeline_response): return deserialized if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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: @@ -3055,23 +3366,27 @@ def get_long_running_output(pipeline_response): ) @distributed_trace - def get_gremlin_role_definition( - self, resource_group_name: str, account_name: str, role_definition_id: str, **kwargs: Any - ) -> _models.GremlinRoleDefinitionResource: - """Retrieves the properties of an existing Azure Cosmos DB Gremlin Role Definition with the given - Id. + def list_gremlin_role_assignments( + self, resource_group_name: str, account_name: str, **kwargs: Any + ) -> ItemPaged["_models.GremlinRoleAssignmentResource"]: + """Retrieves the list of all Azure Cosmos DB Gremlin Role Assignments. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param role_definition_id: The GUID for the Role Definition. Required. - :type role_definition_id: str - :return: GremlinRoleDefinitionResource or the result of cls(response) - :rtype: ~azure.mgmt.cosmosdb.models.GremlinRoleDefinitionResource + :return: An iterator like instance of either GremlinRoleAssignmentResource or the result of + cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cosmosdb.models.GremlinRoleAssignmentResource] :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.GremlinRoleAssignmentListResult] = kwargs.pop("cls", None) + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -3080,16 +3395,100 @@ def get_gremlin_role_definition( } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) or {} + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_gremlin_role_assignments_request( + resource_group_name=resource_group_name, + account_name=account_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("GremlinRoleAssignmentListResult", 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_gremlin_role_assignment( + self, resource_group_name: str, account_name: str, role_assignment_id: str, **kwargs: Any + ) -> _models.GremlinRoleAssignmentResource: + """Retrieves the properties of an existing Azure Cosmos DB Gremlin Role Assignment with the given + Id. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param role_assignment_id: The GUID for the Role Assignment. Required. + :type role_assignment_id: str + :return: GremlinRoleAssignmentResource or the result of cls(response) + :rtype: ~azure.mgmt.cosmosdb.models.GremlinRoleAssignmentResource + :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.GremlinRoleDefinitionResource] = kwargs.pop("cls", None) + cls: ClsType[_models.GremlinRoleAssignmentResource] = kwargs.pop("cls", None) - _request = build_get_gremlin_role_definition_request( + _request = build_get_gremlin_role_assignment_request( resource_group_name=resource_group_name, account_name=account_name, - role_definition_id=role_definition_id, + role_assignment_id=role_assignment_id, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, @@ -3112,19 +3511,19 @@ def get_gremlin_role_definition( ) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("GremlinRoleDefinitionResource", pipeline_response.http_response) + deserialized = self._deserialize("GremlinRoleAssignmentResource", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - def _create_update_gremlin_role_definition_initial( # pylint: disable=name-too-long + def _create_update_gremlin_role_assignment_initial( # pylint: disable=name-too-long self, resource_group_name: str, account_name: str, - role_definition_id: str, - create_update_gremlin_role_definition_parameters: Union[_models.GremlinRoleDefinitionResource, IO[bytes]], + role_assignment_id: str, + create_update_gremlin_role_assignment_parameters: Union[_models.GremlinRoleAssignmentResource, IO[bytes]], **kwargs: Any ) -> Iterator[bytes]: error_map: MutableMapping = { @@ -3145,17 +3544,17 @@ def _create_update_gremlin_role_definition_initial( # pylint: disable=name-too- content_type = content_type or "application/json" _json = None _content = None - if isinstance(create_update_gremlin_role_definition_parameters, (IOBase, bytes)): - _content = create_update_gremlin_role_definition_parameters + if isinstance(create_update_gremlin_role_assignment_parameters, (IOBase, bytes)): + _content = create_update_gremlin_role_assignment_parameters else: _json = self._serialize.body( - create_update_gremlin_role_definition_parameters, "GremlinRoleDefinitionResource" + create_update_gremlin_role_assignment_parameters, "GremlinRoleAssignmentResource" ) - _request = build_create_update_gremlin_role_definition_request( + _request = build_create_update_gremlin_role_assignment_request( resource_group_name=resource_group_name, account_name=account_name, - role_definition_id=role_definition_id, + role_assignment_id=role_assignment_id, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, @@ -3188,10 +3587,11 @@ def _create_update_gremlin_role_definition_initial( # pylint: disable=name-too- response_headers = {} if response.status_code == 202: - response_headers["azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("azure-AsyncOperation") + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") ) - response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) @@ -3201,99 +3601,99 @@ def _create_update_gremlin_role_definition_initial( # pylint: disable=name-too- return deserialized # type: ignore @overload - def begin_create_update_gremlin_role_definition( # pylint: disable=name-too-long + def begin_create_update_gremlin_role_assignment( # pylint: disable=name-too-long self, resource_group_name: str, account_name: str, - role_definition_id: str, - create_update_gremlin_role_definition_parameters: _models.GremlinRoleDefinitionResource, + role_assignment_id: str, + create_update_gremlin_role_assignment_parameters: _models.GremlinRoleAssignmentResource, *, content_type: str = "application/json", **kwargs: Any - ) -> LROPoller[_models.GremlinRoleDefinitionResource]: - """Creates or updates an Azure Cosmos DB Gremlin Role Definition. + ) -> LROPoller[_models.GremlinRoleAssignmentResource]: + """Creates or updates an Azure Cosmos DB Gremlin Role Assignment. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param role_definition_id: The GUID for the Role Definition. Required. - :type role_definition_id: str - :param create_update_gremlin_role_definition_parameters: The properties required to create or - update a Role Definition. Required. - :type create_update_gremlin_role_definition_parameters: - ~azure.mgmt.cosmosdb.models.GremlinRoleDefinitionResource + :param role_assignment_id: The GUID for the Role Assignment. Required. + :type role_assignment_id: str + :param create_update_gremlin_role_assignment_parameters: The properties required to create or + update a Role Assignment. Required. + :type create_update_gremlin_role_assignment_parameters: + ~azure.mgmt.cosmosdb.models.GremlinRoleAssignmentResource :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 GremlinRoleDefinitionResource or the + :return: An instance of LROPoller that returns either GremlinRoleAssignmentResource or the result of cls(response) :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.GremlinRoleDefinitionResource] + ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.GremlinRoleAssignmentResource] :raises ~azure.core.exceptions.HttpResponseError: """ @overload - def begin_create_update_gremlin_role_definition( # pylint: disable=name-too-long + def begin_create_update_gremlin_role_assignment( # pylint: disable=name-too-long self, resource_group_name: str, account_name: str, - role_definition_id: str, - create_update_gremlin_role_definition_parameters: IO[bytes], + role_assignment_id: str, + create_update_gremlin_role_assignment_parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> LROPoller[_models.GremlinRoleDefinitionResource]: - """Creates or updates an Azure Cosmos DB Gremlin Role Definition. + ) -> LROPoller[_models.GremlinRoleAssignmentResource]: + """Creates or updates an Azure Cosmos DB Gremlin Role Assignment. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param role_definition_id: The GUID for the Role Definition. Required. - :type role_definition_id: str - :param create_update_gremlin_role_definition_parameters: The properties required to create or - update a Role Definition. Required. - :type create_update_gremlin_role_definition_parameters: IO[bytes] + :param role_assignment_id: The GUID for the Role Assignment. Required. + :type role_assignment_id: str + :param create_update_gremlin_role_assignment_parameters: The properties required to create or + update a Role Assignment. Required. + :type create_update_gremlin_role_assignment_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 GremlinRoleDefinitionResource or the + :return: An instance of LROPoller that returns either GremlinRoleAssignmentResource or the result of cls(response) :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.GremlinRoleDefinitionResource] + ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.GremlinRoleAssignmentResource] :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace - def begin_create_update_gremlin_role_definition( # pylint: disable=name-too-long + def begin_create_update_gremlin_role_assignment( # pylint: disable=name-too-long self, resource_group_name: str, account_name: str, - role_definition_id: str, - create_update_gremlin_role_definition_parameters: Union[_models.GremlinRoleDefinitionResource, IO[bytes]], + role_assignment_id: str, + create_update_gremlin_role_assignment_parameters: Union[_models.GremlinRoleAssignmentResource, IO[bytes]], **kwargs: Any - ) -> LROPoller[_models.GremlinRoleDefinitionResource]: - """Creates or updates an Azure Cosmos DB Gremlin Role Definition. + ) -> LROPoller[_models.GremlinRoleAssignmentResource]: + """Creates or updates an Azure Cosmos DB Gremlin Role Assignment. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param role_definition_id: The GUID for the Role Definition. Required. - :type role_definition_id: str - :param create_update_gremlin_role_definition_parameters: The properties required to create or - update a Role Definition. Is either a GremlinRoleDefinitionResource type or a IO[bytes] type. + :param role_assignment_id: The GUID for the Role Assignment. Required. + :type role_assignment_id: str + :param create_update_gremlin_role_assignment_parameters: The properties required to create or + update a Role Assignment. Is either a GremlinRoleAssignmentResource type or a IO[bytes] type. Required. - :type create_update_gremlin_role_definition_parameters: - ~azure.mgmt.cosmosdb.models.GremlinRoleDefinitionResource or IO[bytes] - :return: An instance of LROPoller that returns either GremlinRoleDefinitionResource or the + :type create_update_gremlin_role_assignment_parameters: + ~azure.mgmt.cosmosdb.models.GremlinRoleAssignmentResource or IO[bytes] + :return: An instance of LROPoller that returns either GremlinRoleAssignmentResource or the result of cls(response) :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.GremlinRoleDefinitionResource] + ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.GremlinRoleAssignmentResource] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -3301,16 +3701,16 @@ def begin_create_update_gremlin_role_definition( # pylint: disable=name-too-lon 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.GremlinRoleDefinitionResource] = kwargs.pop("cls", None) + cls: ClsType[_models.GremlinRoleAssignmentResource] = 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_update_gremlin_role_definition_initial( + raw_result = self._create_update_gremlin_role_assignment_initial( resource_group_name=resource_group_name, account_name=account_name, - role_definition_id=role_definition_id, - create_update_gremlin_role_definition_parameters=create_update_gremlin_role_definition_parameters, + role_assignment_id=role_assignment_id, + create_update_gremlin_role_assignment_parameters=create_update_gremlin_role_assignment_parameters, api_version=api_version, content_type=content_type, cls=lambda x, y, z: x, @@ -3322,30 +3722,32 @@ def begin_create_update_gremlin_role_definition( # pylint: disable=name-too-lon kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("GremlinRoleDefinitionResource", pipeline_response.http_response) + deserialized = self._deserialize("GremlinRoleAssignmentResource", 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, **kwargs)) + 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.GremlinRoleDefinitionResource].from_continuation_token( + return LROPoller[_models.GremlinRoleAssignmentResource].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller[_models.GremlinRoleDefinitionResource]( + return LROPoller[_models.GremlinRoleAssignmentResource]( self._client, raw_result, get_long_running_output, polling_method # type: ignore ) - def _delete_gremlin_role_definition_initial( - self, resource_group_name: str, account_name: str, role_definition_id: str, **kwargs: Any + def _delete_gremlin_role_assignment_initial( + self, resource_group_name: str, account_name: str, role_assignment_id: str, **kwargs: Any ) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -3361,10 +3763,10 @@ def _delete_gremlin_role_definition_initial( 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_gremlin_role_definition_request( + _request = build_delete_gremlin_role_assignment_request( resource_group_name=resource_group_name, account_name=account_name, - role_definition_id=role_definition_id, + role_assignment_id=role_assignment_id, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, @@ -3394,10 +3796,10 @@ def _delete_gremlin_role_definition_initial( response_headers = {} if response.status_code == 202: - response_headers["azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("azure-AsyncOperation") + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") ) - response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) @@ -3407,18 +3809,18 @@ def _delete_gremlin_role_definition_initial( return deserialized # type: ignore @distributed_trace - def begin_delete_gremlin_role_definition( - self, resource_group_name: str, account_name: str, role_definition_id: str, **kwargs: Any + def begin_delete_gremlin_role_assignment( + self, resource_group_name: str, account_name: str, role_assignment_id: str, **kwargs: Any ) -> LROPoller[None]: - """Deletes an existing Azure Cosmos DB Gremlin Role Definition. + """Deletes an existing Azure Cosmos DB Gremlin Role Assignment. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param role_definition_id: The GUID for the Role Definition. Required. - :type role_definition_id: str + :param role_assignment_id: The GUID for the Role Assignment. Required. + :type role_assignment_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: @@ -3432,10 +3834,10 @@ def begin_delete_gremlin_role_definition( 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_gremlin_role_definition_initial( + raw_result = self._delete_gremlin_role_assignment_initial( resource_group_name=resource_group_name, account_name=account_name, - role_definition_id=role_definition_id, + role_assignment_id=role_assignment_id, api_version=api_version, cls=lambda x, y, z: x, headers=_headers, @@ -3450,7 +3852,9 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- return cls(pipeline_response, None, {}) # type: ignore if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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: @@ -3529,7 +3933,7 @@ def extract_data(pipeline_response): list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore - return None, iter(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): _request = prepare_request(next_link) @@ -3553,10 +3957,10 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) @distributed_trace - def get_gremlin_role_assignment( - self, resource_group_name: str, account_name: str, role_assignment_id: str, **kwargs: Any - ) -> _models.GremlinRoleAssignmentResource: - """Retrieves the properties of an existing Azure Cosmos DB Gremlin Role Assignment with the given + def get_gremlin_role_definition( + self, resource_group_name: str, account_name: str, role_definition_id: str, **kwargs: Any + ) -> _models.GremlinRoleDefinitionResource: + """Retrieves the properties of an existing Azure Cosmos DB Gremlin Role Definition with the given Id. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -3564,10 +3968,10 @@ def get_gremlin_role_assignment( :type resource_group_name: str :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param role_assignment_id: The GUID for the Role Assignment. Required. - :type role_assignment_id: str - :return: GremlinRoleAssignmentResource or the result of cls(response) - :rtype: ~azure.mgmt.cosmosdb.models.GremlinRoleAssignmentResource + :param role_definition_id: The GUID for the Role Definition. Required. + :type role_definition_id: str + :return: GremlinRoleDefinitionResource or the result of cls(response) + :rtype: ~azure.mgmt.cosmosdb.models.GremlinRoleDefinitionResource :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -3582,12 +3986,12 @@ def get_gremlin_role_assignment( _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.GremlinRoleAssignmentResource] = kwargs.pop("cls", None) + cls: ClsType[_models.GremlinRoleDefinitionResource] = kwargs.pop("cls", None) - _request = build_get_gremlin_role_assignment_request( + _request = build_get_gremlin_role_definition_request( resource_group_name=resource_group_name, account_name=account_name, - role_assignment_id=role_assignment_id, + role_definition_id=role_definition_id, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, @@ -3610,19 +4014,19 @@ def get_gremlin_role_assignment( ) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("GremlinRoleAssignmentResource", pipeline_response.http_response) + deserialized = self._deserialize("GremlinRoleDefinitionResource", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - def _create_update_gremlin_role_assignment_initial( # pylint: disable=name-too-long + def _create_update_gremlin_role_definition_initial( # pylint: disable=name-too-long self, resource_group_name: str, account_name: str, - role_assignment_id: str, - create_update_gremlin_role_assignment_parameters: Union[_models.GremlinRoleAssignmentResource, IO[bytes]], + role_definition_id: str, + create_update_gremlin_role_definition_parameters: Union[_models.GremlinRoleDefinitionResource, IO[bytes]], **kwargs: Any ) -> Iterator[bytes]: error_map: MutableMapping = { @@ -3643,17 +4047,17 @@ def _create_update_gremlin_role_assignment_initial( # pylint: disable=name-too- content_type = content_type or "application/json" _json = None _content = None - if isinstance(create_update_gremlin_role_assignment_parameters, (IOBase, bytes)): - _content = create_update_gremlin_role_assignment_parameters + if isinstance(create_update_gremlin_role_definition_parameters, (IOBase, bytes)): + _content = create_update_gremlin_role_definition_parameters else: _json = self._serialize.body( - create_update_gremlin_role_assignment_parameters, "GremlinRoleAssignmentResource" + create_update_gremlin_role_definition_parameters, "GremlinRoleDefinitionResource" ) - _request = build_create_update_gremlin_role_assignment_request( + _request = build_create_update_gremlin_role_definition_request( resource_group_name=resource_group_name, account_name=account_name, - role_assignment_id=role_assignment_id, + role_definition_id=role_definition_id, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, @@ -3686,10 +4090,11 @@ def _create_update_gremlin_role_assignment_initial( # pylint: disable=name-too- response_headers = {} if response.status_code == 202: - response_headers["azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("azure-AsyncOperation") + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") ) - response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) @@ -3699,99 +4104,99 @@ def _create_update_gremlin_role_assignment_initial( # pylint: disable=name-too- return deserialized # type: ignore @overload - def begin_create_update_gremlin_role_assignment( # pylint: disable=name-too-long + def begin_create_update_gremlin_role_definition( # pylint: disable=name-too-long self, resource_group_name: str, account_name: str, - role_assignment_id: str, - create_update_gremlin_role_assignment_parameters: _models.GremlinRoleAssignmentResource, + role_definition_id: str, + create_update_gremlin_role_definition_parameters: _models.GremlinRoleDefinitionResource, *, content_type: str = "application/json", **kwargs: Any - ) -> LROPoller[_models.GremlinRoleAssignmentResource]: - """Creates or updates an Azure Cosmos DB Gremlin Role Assignment. + ) -> LROPoller[_models.GremlinRoleDefinitionResource]: + """Creates or updates an Azure Cosmos DB Gremlin Role Definition. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param role_assignment_id: The GUID for the Role Assignment. Required. - :type role_assignment_id: str - :param create_update_gremlin_role_assignment_parameters: The properties required to create or - update a Role Assignment. Required. - :type create_update_gremlin_role_assignment_parameters: - ~azure.mgmt.cosmosdb.models.GremlinRoleAssignmentResource + :param role_definition_id: The GUID for the Role Definition. Required. + :type role_definition_id: str + :param create_update_gremlin_role_definition_parameters: The properties required to create or + update a Role Definition. Required. + :type create_update_gremlin_role_definition_parameters: + ~azure.mgmt.cosmosdb.models.GremlinRoleDefinitionResource :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 GremlinRoleAssignmentResource or the + :return: An instance of LROPoller that returns either GremlinRoleDefinitionResource or the result of cls(response) :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.GremlinRoleAssignmentResource] + ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.GremlinRoleDefinitionResource] :raises ~azure.core.exceptions.HttpResponseError: """ @overload - def begin_create_update_gremlin_role_assignment( # pylint: disable=name-too-long + def begin_create_update_gremlin_role_definition( # pylint: disable=name-too-long self, resource_group_name: str, account_name: str, - role_assignment_id: str, - create_update_gremlin_role_assignment_parameters: IO[bytes], + role_definition_id: str, + create_update_gremlin_role_definition_parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> LROPoller[_models.GremlinRoleAssignmentResource]: - """Creates or updates an Azure Cosmos DB Gremlin Role Assignment. + ) -> LROPoller[_models.GremlinRoleDefinitionResource]: + """Creates or updates an Azure Cosmos DB Gremlin Role Definition. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param role_assignment_id: The GUID for the Role Assignment. Required. - :type role_assignment_id: str - :param create_update_gremlin_role_assignment_parameters: The properties required to create or - update a Role Assignment. Required. - :type create_update_gremlin_role_assignment_parameters: IO[bytes] + :param role_definition_id: The GUID for the Role Definition. Required. + :type role_definition_id: str + :param create_update_gremlin_role_definition_parameters: The properties required to create or + update a Role Definition. Required. + :type create_update_gremlin_role_definition_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 GremlinRoleAssignmentResource or the + :return: An instance of LROPoller that returns either GremlinRoleDefinitionResource or the result of cls(response) :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.GremlinRoleAssignmentResource] + ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.GremlinRoleDefinitionResource] :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace - def begin_create_update_gremlin_role_assignment( # pylint: disable=name-too-long + def begin_create_update_gremlin_role_definition( # pylint: disable=name-too-long self, resource_group_name: str, account_name: str, - role_assignment_id: str, - create_update_gremlin_role_assignment_parameters: Union[_models.GremlinRoleAssignmentResource, IO[bytes]], + role_definition_id: str, + create_update_gremlin_role_definition_parameters: Union[_models.GremlinRoleDefinitionResource, IO[bytes]], **kwargs: Any - ) -> LROPoller[_models.GremlinRoleAssignmentResource]: - """Creates or updates an Azure Cosmos DB Gremlin Role Assignment. + ) -> LROPoller[_models.GremlinRoleDefinitionResource]: + """Creates or updates an Azure Cosmos DB Gremlin Role Definition. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param role_assignment_id: The GUID for the Role Assignment. Required. - :type role_assignment_id: str - :param create_update_gremlin_role_assignment_parameters: The properties required to create or - update a Role Assignment. Is either a GremlinRoleAssignmentResource type or a IO[bytes] type. + :param role_definition_id: The GUID for the Role Definition. Required. + :type role_definition_id: str + :param create_update_gremlin_role_definition_parameters: The properties required to create or + update a Role Definition. Is either a GremlinRoleDefinitionResource type or a IO[bytes] type. Required. - :type create_update_gremlin_role_assignment_parameters: - ~azure.mgmt.cosmosdb.models.GremlinRoleAssignmentResource or IO[bytes] - :return: An instance of LROPoller that returns either GremlinRoleAssignmentResource or the + :type create_update_gremlin_role_definition_parameters: + ~azure.mgmt.cosmosdb.models.GremlinRoleDefinitionResource or IO[bytes] + :return: An instance of LROPoller that returns either GremlinRoleDefinitionResource or the result of cls(response) :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.GremlinRoleAssignmentResource] + ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.GremlinRoleDefinitionResource] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -3799,16 +4204,16 @@ def begin_create_update_gremlin_role_assignment( # pylint: disable=name-too-lon 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.GremlinRoleAssignmentResource] = kwargs.pop("cls", None) + cls: ClsType[_models.GremlinRoleDefinitionResource] = 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_update_gremlin_role_assignment_initial( + raw_result = self._create_update_gremlin_role_definition_initial( resource_group_name=resource_group_name, account_name=account_name, - role_assignment_id=role_assignment_id, - create_update_gremlin_role_assignment_parameters=create_update_gremlin_role_assignment_parameters, + role_definition_id=role_definition_id, + create_update_gremlin_role_definition_parameters=create_update_gremlin_role_definition_parameters, api_version=api_version, content_type=content_type, cls=lambda x, y, z: x, @@ -3820,30 +4225,32 @@ def begin_create_update_gremlin_role_assignment( # pylint: disable=name-too-lon kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("GremlinRoleAssignmentResource", pipeline_response.http_response) + deserialized = self._deserialize("GremlinRoleDefinitionResource", 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, **kwargs)) + 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.GremlinRoleAssignmentResource].from_continuation_token( + return LROPoller[_models.GremlinRoleDefinitionResource].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller[_models.GremlinRoleAssignmentResource]( + return LROPoller[_models.GremlinRoleDefinitionResource]( self._client, raw_result, get_long_running_output, polling_method # type: ignore ) - def _delete_gremlin_role_assignment_initial( - self, resource_group_name: str, account_name: str, role_assignment_id: str, **kwargs: Any + def _delete_gremlin_role_definition_initial( + self, resource_group_name: str, account_name: str, role_definition_id: str, **kwargs: Any ) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -3859,10 +4266,10 @@ def _delete_gremlin_role_assignment_initial( 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_gremlin_role_assignment_request( + _request = build_delete_gremlin_role_definition_request( resource_group_name=resource_group_name, account_name=account_name, - role_assignment_id=role_assignment_id, + role_definition_id=role_definition_id, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, @@ -3892,10 +4299,10 @@ def _delete_gremlin_role_assignment_initial( response_headers = {} if response.status_code == 202: - response_headers["azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("azure-AsyncOperation") + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") ) - response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) @@ -3905,18 +4312,18 @@ def _delete_gremlin_role_assignment_initial( return deserialized # type: ignore @distributed_trace - def begin_delete_gremlin_role_assignment( - self, resource_group_name: str, account_name: str, role_assignment_id: str, **kwargs: Any + def begin_delete_gremlin_role_definition( + self, resource_group_name: str, account_name: str, role_definition_id: str, **kwargs: Any ) -> LROPoller[None]: - """Deletes an existing Azure Cosmos DB Gremlin Role Assignment. + """Deletes an existing Azure Cosmos DB Gremlin Role Definition. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param role_assignment_id: The GUID for the Role Assignment. Required. - :type role_assignment_id: str + :param role_definition_id: The GUID for the Role Definition. Required. + :type role_definition_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: @@ -3930,10 +4337,10 @@ def begin_delete_gremlin_role_assignment( 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_gremlin_role_assignment_initial( + raw_result = self._delete_gremlin_role_definition_initial( resource_group_name=resource_group_name, account_name=account_name, - role_assignment_id=role_assignment_id, + role_definition_id=role_definition_id, api_version=api_version, cls=lambda x, y, z: x, headers=_headers, @@ -3947,308 +4354,6 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- if cls: return cls(pipeline_response, None, {}) # type: ignore - if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **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_gremlin_role_assignments( - self, resource_group_name: str, account_name: str, **kwargs: Any - ) -> ItemPaged["_models.GremlinRoleAssignmentResource"]: - """Retrieves the list of all Azure Cosmos DB Gremlin Role Assignments. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param account_name: Cosmos DB database account name. Required. - :type account_name: str - :return: An iterator like instance of either GremlinRoleAssignmentResource or the result of - cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cosmosdb.models.GremlinRoleAssignmentResource] - :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.GremlinRoleAssignmentListResult] = 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_gremlin_role_assignments_request( - resource_group_name=resource_group_name, - account_name=account_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("GremlinRoleAssignmentListResult", 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) - - def _retrieve_continuous_backup_information_initial( # pylint: disable=name-too-long - self, - resource_group_name: str, - account_name: str, - database_name: str, - graph_name: str, - location: Union[_models.ContinuousBackupRestoreLocation, 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(location, (IOBase, bytes)): - _content = location - else: - _json = self._serialize.body(location, "ContinuousBackupRestoreLocation") - - _request = build_retrieve_continuous_backup_information_request( - resource_group_name=resource_group_name, - account_name=account_name, - database_name=database_name, - graph_name=graph_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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_retrieve_continuous_backup_information( # pylint: disable=name-too-long - self, - resource_group_name: str, - account_name: str, - database_name: str, - graph_name: str, - location: _models.ContinuousBackupRestoreLocation, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.BackupInformation]: - """Retrieves continuous backup information for a gremlin graph. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param account_name: Cosmos DB database account name. Required. - :type account_name: str - :param database_name: Cosmos DB database name. Required. - :type database_name: str - :param graph_name: Cosmos DB graph name. Required. - :type graph_name: str - :param location: The name of the continuous backup restore location. Required. - :type location: ~azure.mgmt.cosmosdb.models.ContinuousBackupRestoreLocation - :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 BackupInformation or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.BackupInformation] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_retrieve_continuous_backup_information( # pylint: disable=name-too-long - self, - resource_group_name: str, - account_name: str, - database_name: str, - graph_name: str, - location: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.BackupInformation]: - """Retrieves continuous backup information for a gremlin graph. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param account_name: Cosmos DB database account name. Required. - :type account_name: str - :param database_name: Cosmos DB database name. Required. - :type database_name: str - :param graph_name: Cosmos DB graph name. Required. - :type graph_name: str - :param location: The name of the continuous backup restore location. Required. - :type location: 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 BackupInformation or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.BackupInformation] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_retrieve_continuous_backup_information( # pylint: disable=name-too-long - self, - resource_group_name: str, - account_name: str, - database_name: str, - graph_name: str, - location: Union[_models.ContinuousBackupRestoreLocation, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.BackupInformation]: - """Retrieves continuous backup information for a gremlin graph. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param account_name: Cosmos DB database account name. Required. - :type account_name: str - :param database_name: Cosmos DB database name. Required. - :type database_name: str - :param graph_name: Cosmos DB graph name. Required. - :type graph_name: str - :param location: The name of the continuous backup restore location. Is either a - ContinuousBackupRestoreLocation type or a IO[bytes] type. Required. - :type location: ~azure.mgmt.cosmosdb.models.ContinuousBackupRestoreLocation or IO[bytes] - :return: An instance of LROPoller that returns either BackupInformation or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.BackupInformation] - :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.BackupInformation] = 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._retrieve_continuous_backup_information_initial( - resource_group_name=resource_group_name, - account_name=account_name, - database_name=database_name, - graph_name=graph_name, - location=location, - 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("BackupInformation", 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": "location"}, **kwargs) @@ -4258,12 +4363,10 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller[_models.BackupInformation].from_continuation_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[_models.BackupInformation]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/operations/_locations_operations.py b/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/operations/_locations_operations.py index 4d6d41c013e..b011502e8f9 100644 --- a/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/operations/_locations_operations.py +++ b/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/operations/_locations_operations.py @@ -41,7 +41,7 @@ def build_list_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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -65,7 +65,7 @@ def build_get_request(location: str, subscription_id: str, **kwargs: Any) -> Htt _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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -162,7 +162,7 @@ def extract_data(pipeline_response): list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore - return None, iter(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): _request = prepare_request(next_link) diff --git a/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/operations/_mongo_db_resources_operations.py b/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/operations/_mongo_db_resources_operations.py index 3aecd4d2d2d..83fb8df9ee0 100644 --- a/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/operations/_mongo_db_resources_operations.py +++ b/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/operations/_mongo_db_resources_operations.py @@ -49,7 +49,7 @@ def build_list_mongo_db_databases_request( _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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -84,7 +84,7 @@ def build_get_mongo_db_database_request( _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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -120,7 +120,7 @@ def build_create_update_mongo_db_database_request( # pylint: disable=name-too-l _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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -156,9 +156,12 @@ def build_create_update_mongo_db_database_request( # pylint: disable=name-too-l def build_delete_mongo_db_database_request( resource_group_name: str, account_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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop( "template_url", @@ -180,22 +183,25 @@ def build_delete_mongo_db_database_request( # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) -def build_get_mongo_db_database_throughput_request( # pylint: disable=name-too-long +def build_list_mongo_db_collections_request( resource_group_name: str, account_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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}/throughputSettings/default", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}/collections", ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), @@ -219,20 +225,24 @@ def build_get_mongo_db_database_throughput_request( # pylint: disable=name-too- return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_update_mongo_db_database_throughput_request( # pylint: disable=name-too-long - resource_group_name: str, account_name: str, database_name: str, subscription_id: str, **kwargs: Any +def build_get_mongo_db_collection_request( + resource_group_name: str, + account_name: str, + database_name: str, + collection_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-11-01-preview")) - 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-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}/throughputSettings/default", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}/collections/{collectionName}", ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), @@ -243,6 +253,7 @@ def build_update_mongo_db_database_throughput_request( # pylint: disable=name-t "account_name", account_name, "str", max_length=50, min_length=3, pattern=r"^[a-z0-9]+(-[a-z0-9]+)*" ), "databaseName": _SERIALIZER.url("database_name", database_name, "str"), + "collectionName": _SERIALIZER.url("collection_name", collection_name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -251,26 +262,30 @@ def build_update_mongo_db_database_throughput_request( # pylint: disable=name-t _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) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_migrate_mongo_db_database_to_autoscale_request( # pylint: disable=name-too-long - resource_group_name: str, account_name: str, database_name: str, subscription_id: str, **kwargs: Any +def build_create_update_mongo_db_collection_request( # pylint: disable=name-too-long + resource_group_name: str, + account_name: str, + database_name: str, + collection_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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) + 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.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}/throughputSettings/default/migrateToAutoscale", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}/collections/{collectionName}", ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), @@ -281,6 +296,7 @@ def build_migrate_mongo_db_database_to_autoscale_request( # pylint: disable=nam "account_name", account_name, "str", max_length=50, min_length=3, pattern=r"^[a-z0-9]+(-[a-z0-9]+)*" ), "databaseName": _SERIALIZER.url("database_name", database_name, "str"), + "collectionName": _SERIALIZER.url("collection_name", collection_name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -289,24 +305,31 @@ def build_migrate_mongo_db_database_to_autoscale_request( # pylint: disable=nam _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) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_migrate_mongo_db_database_to_manual_throughput_request( # pylint: disable=name-too-long - resource_group_name: str, account_name: str, database_name: str, subscription_id: str, **kwargs: Any +def build_delete_mongo_db_collection_request( + resource_group_name: str, + account_name: str, + database_name: str, + collection_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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}/throughputSettings/default/migrateToManualThroughput", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}/collections/{collectionName}", ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), @@ -317,6 +340,7 @@ def build_migrate_mongo_db_database_to_manual_throughput_request( # pylint: dis "account_name", account_name, "str", max_length=50, min_length=3, pattern=r"^[a-z0-9]+(-[a-z0-9]+)*" ), "databaseName": _SERIALIZER.url("database_name", database_name, "str"), + "collectionName": _SERIALIZER.url("collection_name", collection_name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -327,23 +351,28 @@ def build_migrate_mongo_db_database_to_manual_throughput_request( # pylint: dis # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) -def build_mongo_db_database_retrieve_throughput_distribution_request( # pylint: disable=name-too-long - resource_group_name: str, account_name: str, database_name: str, subscription_id: str, **kwargs: Any +def build_list_mongo_db_collection_partition_merge_request( # pylint: disable=name-too-long + resource_group_name: str, + account_name: str, + database_name: str, + collection_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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) 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.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}/throughputSettings/default/retrieveThroughputDistribution", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}/collections/{collectionName}/partitionMerge", ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), @@ -354,6 +383,7 @@ def build_mongo_db_database_retrieve_throughput_distribution_request( # pylint: "account_name", account_name, "str", max_length=50, min_length=3, pattern=r"^[a-z0-9]+(-[a-z0-9]+)*" ), "databaseName": _SERIALIZER.url("database_name", database_name, "str"), + "collectionName": _SERIALIZER.url("collection_name", collection_name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -369,20 +399,25 @@ def build_mongo_db_database_retrieve_throughput_distribution_request( # pylint: return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_mongo_db_database_redistribute_throughput_request( # pylint: disable=name-too-long - resource_group_name: str, account_name: str, database_name: str, subscription_id: str, **kwargs: Any +def build_retrieve_continuous_backup_information_request( # pylint: disable=name-too-long + resource_group_name: str, + account_name: str, + database_name: str, + collection_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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) 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.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}/throughputSettings/default/redistributeThroughput", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}/collections/{collectionName}/retrieveContinuousBackupInformation", ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), @@ -393,6 +428,7 @@ def build_mongo_db_database_redistribute_throughput_request( # pylint: disable= "account_name", account_name, "str", max_length=50, min_length=3, pattern=r"^[a-z0-9]+(-[a-z0-9]+)*" ), "databaseName": _SERIALIZER.url("database_name", database_name, "str"), + "collectionName": _SERIALIZER.url("collection_name", collection_name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -408,7 +444,7 @@ def build_mongo_db_database_redistribute_throughput_request( # pylint: disable= return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_mongo_db_container_retrieve_throughput_distribution_request( # pylint: disable=name-too-long +def build_get_mongo_db_collection_throughput_request( # pylint: disable=name-too-long resource_group_name: str, account_name: str, database_name: str, @@ -419,14 +455,13 @@ def build_mongo_db_container_retrieve_throughput_distribution_request( # pylint _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-11-01-preview")) - 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-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}/collections/{collectionName}/throughputSettings/default/retrieveThroughputDistribution", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}/collections/{collectionName}/throughputSettings/default", ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), @@ -446,14 +481,12 @@ def build_mongo_db_container_retrieve_throughput_distribution_request( # pylint _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) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_mongo_db_container_redistribute_throughput_request( # pylint: disable=name-too-long +def build_update_mongo_db_collection_throughput_request( # pylint: disable=name-too-long resource_group_name: str, account_name: str, database_name: str, @@ -464,14 +497,14 @@ def build_mongo_db_container_redistribute_throughput_request( # pylint: disable _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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) 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.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}/collections/{collectionName}/throughputSettings/default/redistributeThroughput", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}/collections/{collectionName}/throughputSettings/default", ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), @@ -495,22 +528,27 @@ def build_mongo_db_container_redistribute_throughput_request( # pylint: disable _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) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_mongo_db_collections_request( - resource_group_name: str, account_name: str, database_name: str, subscription_id: str, **kwargs: Any +def build_migrate_mongo_db_collection_to_autoscale_request( # pylint: disable=name-too-long + resource_group_name: str, + account_name: str, + database_name: str, + collection_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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}/collections", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}/collections/{collectionName}/throughputSettings/default/migrateToAutoscale", ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), @@ -521,6 +559,7 @@ def build_list_mongo_db_collections_request( "account_name", account_name, "str", max_length=50, min_length=3, pattern=r"^[a-z0-9]+(-[a-z0-9]+)*" ), "databaseName": _SERIALIZER.url("database_name", database_name, "str"), + "collectionName": _SERIALIZER.url("collection_name", collection_name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -531,10 +570,10 @@ def build_list_mongo_db_collections_request( # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_get_mongo_db_collection_request( +def build_migrate_mongo_db_collection_to_manual_throughput_request( # pylint: disable=name-too-long resource_group_name: str, account_name: str, database_name: str, @@ -545,13 +584,13 @@ def build_get_mongo_db_collection_request( _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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}/collections/{collectionName}", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}/collections/{collectionName}/throughputSettings/default/migrateToManualThroughput", ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), @@ -573,10 +612,10 @@ def build_get_mongo_db_collection_request( # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_update_mongo_db_collection_request( # pylint: disable=name-too-long +def build_mongo_db_container_redistribute_throughput_request( # pylint: disable=name-too-long resource_group_name: str, account_name: str, database_name: str, @@ -587,14 +626,14 @@ def build_create_update_mongo_db_collection_request( # pylint: disable=name-too _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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) 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.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}/collections/{collectionName}", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}/collections/{collectionName}/throughputSettings/default/redistributeThroughput", ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), @@ -618,10 +657,10 @@ def build_create_update_mongo_db_collection_request( # pylint: disable=name-too _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) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_delete_mongo_db_collection_request( +def build_mongo_db_container_retrieve_throughput_distribution_request( # pylint: disable=name-too-long resource_group_name: str, account_name: str, database_name: str, @@ -629,13 +668,17 @@ def build_delete_mongo_db_collection_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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) + 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.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}/collections/{collectionName}", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}/collections/{collectionName}/throughputSettings/default/retrieveThroughputDistribution", ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), @@ -654,7 +697,12 @@ def build_delete_mongo_db_collection_request( # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) + # 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_mongo_db_database_partition_merge_request( # pylint: disable=name-too-long @@ -663,7 +711,7 @@ def build_mongo_db_database_partition_merge_request( # pylint: disable=name-too _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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -696,25 +744,19 @@ def build_mongo_db_database_partition_merge_request( # pylint: disable=name-too return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_mongo_db_collection_partition_merge_request( # pylint: disable=name-too-long - resource_group_name: str, - account_name: str, - database_name: str, - collection_name: str, - subscription_id: str, - **kwargs: Any +def build_get_mongo_db_database_throughput_request( # pylint: disable=name-too-long + resource_group_name: str, account_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-11-01-preview")) - 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-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}/collections/{collectionName}/partitionMerge", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}/throughputSettings/default", ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), @@ -725,7 +767,6 @@ def build_list_mongo_db_collection_partition_merge_request( # pylint: disable=n "account_name", account_name, "str", max_length=50, min_length=3, pattern=r"^[a-z0-9]+(-[a-z0-9]+)*" ), "databaseName": _SERIALIZER.url("database_name", database_name, "str"), - "collectionName": _SERIALIZER.url("collection_name", collection_name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -734,31 +775,25 @@ def build_list_mongo_db_collection_partition_merge_request( # pylint: disable=n _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) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_get_mongo_db_collection_throughput_request( # pylint: disable=name-too-long - resource_group_name: str, - account_name: str, - database_name: str, - collection_name: str, - subscription_id: str, - **kwargs: Any +def build_update_mongo_db_database_throughput_request( # pylint: disable=name-too-long + resource_group_name: str, account_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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) + 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.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}/collections/{collectionName}/throughputSettings/default", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}/throughputSettings/default", ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), @@ -769,7 +804,6 @@ def build_get_mongo_db_collection_throughput_request( # pylint: disable=name-to "account_name", account_name, "str", max_length=50, min_length=3, pattern=r"^[a-z0-9]+(-[a-z0-9]+)*" ), "databaseName": _SERIALIZER.url("database_name", database_name, "str"), - "collectionName": _SERIALIZER.url("collection_name", collection_name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -778,30 +812,26 @@ def build_get_mongo_db_collection_throughput_request( # pylint: disable=name-to _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="GET", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_update_mongo_db_collection_throughput_request( # pylint: disable=name-too-long - resource_group_name: str, - account_name: str, - database_name: str, - collection_name: str, - subscription_id: str, - **kwargs: Any +def build_migrate_mongo_db_database_to_autoscale_request( # pylint: disable=name-too-long + resource_group_name: str, account_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-11-01-preview")) - 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-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}/collections/{collectionName}/throughputSettings/default", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}/throughputSettings/default/migrateToAutoscale", ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), @@ -812,7 +842,6 @@ def build_update_mongo_db_collection_throughput_request( # pylint: disable=name "account_name", account_name, "str", max_length=50, min_length=3, pattern=r"^[a-z0-9]+(-[a-z0-9]+)*" ), "databaseName": _SERIALIZER.url("database_name", database_name, "str"), - "collectionName": _SERIALIZER.url("collection_name", collection_name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -821,31 +850,24 @@ def build_update_mongo_db_collection_throughput_request( # pylint: disable=name _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) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_migrate_mongo_db_collection_to_autoscale_request( # pylint: disable=name-too-long - resource_group_name: str, - account_name: str, - database_name: str, - collection_name: str, - subscription_id: str, - **kwargs: Any +def build_migrate_mongo_db_database_to_manual_throughput_request( # pylint: disable=name-too-long + resource_group_name: str, account_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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}/collections/{collectionName}/throughputSettings/default/migrateToAutoscale", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}/throughputSettings/default/migrateToManualThroughput", ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), @@ -856,7 +878,6 @@ def build_migrate_mongo_db_collection_to_autoscale_request( # pylint: disable=n "account_name", account_name, "str", max_length=50, min_length=3, pattern=r"^[a-z0-9]+(-[a-z0-9]+)*" ), "databaseName": _SERIALIZER.url("database_name", database_name, "str"), - "collectionName": _SERIALIZER.url("collection_name", collection_name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -870,24 +891,20 @@ def build_migrate_mongo_db_collection_to_autoscale_request( # pylint: disable=n return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_migrate_mongo_db_collection_to_manual_throughput_request( # pylint: disable=name-too-long - resource_group_name: str, - account_name: str, - database_name: str, - collection_name: str, - subscription_id: str, - **kwargs: Any +def build_mongo_db_database_redistribute_throughput_request( # pylint: disable=name-too-long + resource_group_name: str, account_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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) + 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.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}/collections/{collectionName}/throughputSettings/default/migrateToManualThroughput", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}/throughputSettings/default/redistributeThroughput", ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), @@ -898,7 +915,6 @@ def build_migrate_mongo_db_collection_to_manual_throughput_request( # pylint: d "account_name", account_name, "str", max_length=50, min_length=3, pattern=r"^[a-z0-9]+(-[a-z0-9]+)*" ), "databaseName": _SERIALIZER.url("database_name", database_name, "str"), - "collectionName": _SERIALIZER.url("collection_name", collection_name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -907,27 +923,29 @@ def build_migrate_mongo_db_collection_to_manual_throughput_request( # pylint: d _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_mongo_role_definition_request( - mongo_role_definition_id: str, resource_group_name: str, account_name: str, subscription_id: str, **kwargs: Any +def build_mongo_db_database_retrieve_throughput_distribution_request( # pylint: disable=name-too-long + resource_group_name: str, account_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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) + 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.DocumentDB/databaseAccounts/{accountName}/mongodbRoleDefinitions/{mongoRoleDefinitionId}", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}/throughputSettings/default/retrieveThroughputDistribution", ) path_format_arguments = { - "mongoRoleDefinitionId": _SERIALIZER.url("mongo_role_definition_id", mongo_role_definition_id, "str"), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "resourceGroupName": _SERIALIZER.url( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 @@ -935,6 +953,7 @@ def build_get_mongo_role_definition_request( "accountName": _SERIALIZER.url( "account_name", account_name, "str", max_length=50, min_length=3, pattern=r"^[a-z0-9]+(-[a-z0-9]+)*" ), + "databaseName": _SERIALIZER.url("database_name", database_name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -943,28 +962,28 @@ def build_get_mongo_role_definition_request( _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="GET", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_update_mongo_role_definition_request( # pylint: disable=name-too-long - mongo_role_definition_id: str, resource_group_name: str, account_name: str, subscription_id: str, **kwargs: Any +def build_list_mongo_role_definitions_request( # pylint: disable=name-too-long + resource_group_name: str, account_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-11-01-preview")) - 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-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbRoleDefinitions/{mongoRoleDefinitionId}", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbRoleDefinitions", ) path_format_arguments = { - "mongoRoleDefinitionId": _SERIALIZER.url("mongo_role_definition_id", mongo_role_definition_id, "str"), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "resourceGroupName": _SERIALIZER.url( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 @@ -980,20 +999,18 @@ def build_create_update_mongo_role_definition_request( # pylint: disable=name-t _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) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_delete_mongo_role_definition_request( # pylint: disable=name-too-long - mongo_role_definition_id: str, resource_group_name: str, account_name: str, subscription_id: str, **kwargs: Any +def build_get_mongo_role_definition_request( + resource_group_name: str, account_name: str, mongo_role_definition_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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -1002,7 +1019,6 @@ def build_delete_mongo_role_definition_request( # pylint: disable=name-too-long "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbRoleDefinitions/{mongoRoleDefinitionId}", ) path_format_arguments = { - "mongoRoleDefinitionId": _SERIALIZER.url("mongo_role_definition_id", mongo_role_definition_id, "str"), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "resourceGroupName": _SERIALIZER.url( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 @@ -1010,6 +1026,7 @@ def build_delete_mongo_role_definition_request( # pylint: disable=name-too-long "accountName": _SERIALIZER.url( "account_name", account_name, "str", max_length=50, min_length=3, pattern=r"^[a-z0-9]+(-[a-z0-9]+)*" ), + "mongoRoleDefinitionId": _SERIALIZER.url("mongo_role_definition_id", mongo_role_definition_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -1020,22 +1037,23 @@ def build_delete_mongo_role_definition_request( # pylint: disable=name-too-long # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_mongo_role_definitions_request( # pylint: disable=name-too-long - resource_group_name: str, account_name: str, subscription_id: str, **kwargs: Any +def build_create_update_mongo_role_definition_request( # pylint: disable=name-too-long + resource_group_name: str, account_name: str, mongo_role_definition_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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) + 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.DocumentDB/databaseAccounts/{accountName}/mongodbRoleDefinitions", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbRoleDefinitions/{mongoRoleDefinitionId}", ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), @@ -1045,6 +1063,7 @@ def build_list_mongo_role_definitions_request( # pylint: disable=name-too-long "accountName": _SERIALIZER.url( "account_name", account_name, "str", max_length=50, min_length=3, pattern=r"^[a-z0-9]+(-[a-z0-9]+)*" ), + "mongoRoleDefinitionId": _SERIALIZER.url("mongo_role_definition_id", mongo_role_definition_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -1053,27 +1072,28 @@ def build_list_mongo_role_definitions_request( # pylint: disable=name-too-long _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="GET", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_get_mongo_user_definition_request( - mongo_user_definition_id: str, resource_group_name: str, account_name: str, subscription_id: str, **kwargs: Any +def build_delete_mongo_role_definition_request( # pylint: disable=name-too-long + resource_group_name: str, account_name: str, mongo_role_definition_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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbUserDefinitions/{mongoUserDefinitionId}", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbRoleDefinitions/{mongoRoleDefinitionId}", ) path_format_arguments = { - "mongoUserDefinitionId": _SERIALIZER.url("mongo_user_definition_id", mongo_user_definition_id, "str"), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "resourceGroupName": _SERIALIZER.url( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 @@ -1081,6 +1101,7 @@ def build_get_mongo_user_definition_request( "accountName": _SERIALIZER.url( "account_name", account_name, "str", max_length=50, min_length=3, pattern=r"^[a-z0-9]+(-[a-z0-9]+)*" ), + "mongoRoleDefinitionId": _SERIALIZER.url("mongo_role_definition_id", mongo_role_definition_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -1091,26 +1112,24 @@ def build_get_mongo_user_definition_request( # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_update_mongo_user_definition_request( # pylint: disable=name-too-long - mongo_user_definition_id: str, resource_group_name: str, account_name: str, subscription_id: str, **kwargs: Any +def build_list_mongo_user_definitions_request( # pylint: disable=name-too-long + resource_group_name: str, account_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-11-01-preview")) - 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-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbUserDefinitions/{mongoUserDefinitionId}", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbUserDefinitions", ) path_format_arguments = { - "mongoUserDefinitionId": _SERIALIZER.url("mongo_user_definition_id", mongo_user_definition_id, "str"), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "resourceGroupName": _SERIALIZER.url( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 @@ -1126,20 +1145,18 @@ def build_create_update_mongo_user_definition_request( # pylint: disable=name-t _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) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_delete_mongo_user_definition_request( # pylint: disable=name-too-long - mongo_user_definition_id: str, resource_group_name: str, account_name: str, subscription_id: str, **kwargs: Any +def build_get_mongo_user_definition_request( + resource_group_name: str, account_name: str, mongo_user_definition_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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -1148,7 +1165,6 @@ def build_delete_mongo_user_definition_request( # pylint: disable=name-too-long "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbUserDefinitions/{mongoUserDefinitionId}", ) path_format_arguments = { - "mongoUserDefinitionId": _SERIALIZER.url("mongo_user_definition_id", mongo_user_definition_id, "str"), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "resourceGroupName": _SERIALIZER.url( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 @@ -1156,6 +1172,7 @@ def build_delete_mongo_user_definition_request( # pylint: disable=name-too-long "accountName": _SERIALIZER.url( "account_name", account_name, "str", max_length=50, min_length=3, pattern=r"^[a-z0-9]+(-[a-z0-9]+)*" ), + "mongoUserDefinitionId": _SERIALIZER.url("mongo_user_definition_id", mongo_user_definition_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -1166,22 +1183,23 @@ def build_delete_mongo_user_definition_request( # pylint: disable=name-too-long # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_mongo_user_definitions_request( # pylint: disable=name-too-long - resource_group_name: str, account_name: str, subscription_id: str, **kwargs: Any +def build_create_update_mongo_user_definition_request( # pylint: disable=name-too-long + resource_group_name: str, account_name: str, mongo_user_definition_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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) + 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.DocumentDB/databaseAccounts/{accountName}/mongodbUserDefinitions", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbUserDefinitions/{mongoUserDefinitionId}", ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), @@ -1191,6 +1209,7 @@ def build_list_mongo_user_definitions_request( # pylint: disable=name-too-long "accountName": _SERIALIZER.url( "account_name", account_name, "str", max_length=50, min_length=3, pattern=r"^[a-z0-9]+(-[a-z0-9]+)*" ), + "mongoUserDefinitionId": _SERIALIZER.url("mongo_user_definition_id", mongo_user_definition_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -1199,30 +1218,26 @@ def build_list_mongo_user_definitions_request( # pylint: disable=name-too-long _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="GET", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_retrieve_continuous_backup_information_request( # pylint: disable=name-too-long - resource_group_name: str, - account_name: str, - database_name: str, - collection_name: str, - subscription_id: str, - **kwargs: Any +def build_delete_mongo_user_definition_request( # pylint: disable=name-too-long + resource_group_name: str, account_name: str, mongo_user_definition_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-11-01-preview")) - 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-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}/collections/{collectionName}/retrieveContinuousBackupInformation", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbUserDefinitions/{mongoUserDefinitionId}", ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), @@ -1232,8 +1247,7 @@ def build_retrieve_continuous_backup_information_request( # pylint: disable=nam "accountName": _SERIALIZER.url( "account_name", account_name, "str", max_length=50, min_length=3, pattern=r"^[a-z0-9]+(-[a-z0-9]+)*" ), - "databaseName": _SERIALIZER.url("database_name", database_name, "str"), - "collectionName": _SERIALIZER.url("collection_name", collection_name, "str"), + "mongoUserDefinitionId": _SERIALIZER.url("mongo_user_definition_id", mongo_user_definition_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -1242,11 +1256,9 @@ def build_retrieve_continuous_backup_information_request( # pylint: disable=nam _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) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) class MongoDBResourcesOperations: # pylint: disable=too-many-public-methods @@ -1333,7 +1345,7 @@ def extract_data(pipeline_response): list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore - return None, iter(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): _request = prepare_request(next_link) @@ -1346,7 +1358,11 @@ 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response @@ -1404,7 +1420,11 @@ def get_mongo_db_database( if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("MongoDBDatabaseGetResults", pipeline_response.http_response) @@ -1474,14 +1494,19 @@ def _create_update_mongo_db_database_initial( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + 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["azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("azure-AsyncOperation") + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") ) - response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) @@ -1615,7 +1640,9 @@ def get_long_running_output(pipeline_response): return deserialized if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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: @@ -1673,14 +1700,18 @@ def _delete_mongo_db_database_initial( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + 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["azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("azure-AsyncOperation") + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") ) - response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) @@ -1733,7 +1764,9 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- return cls(pipeline_response, None, {}) # type: ignore if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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: @@ -1748,11 +1781,10 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore @distributed_trace - def get_mongo_db_database_throughput( + def list_mongo_db_collections( self, resource_group_name: str, account_name: str, database_name: str, **kwargs: Any - ) -> _models.ThroughputSettingsGetResults: - """Gets the RUs per second of the MongoDB database under an existing Azure Cosmos DB database - account with the provided name. + ) -> ItemPaged["_models.MongoDBCollectionGetResults"]: + """Lists the MongoDB collection under an existing Azure Cosmos DB database account. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -1761,8 +1793,101 @@ def get_mongo_db_database_throughput( :type account_name: str :param database_name: Cosmos DB database name. Required. :type database_name: str - :return: ThroughputSettingsGetResults or the result of cls(response) - :rtype: ~azure.mgmt.cosmosdb.models.ThroughputSettingsGetResults + :return: An iterator like instance of either MongoDBCollectionGetResults or the result of + cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cosmosdb.models.MongoDBCollectionGetResults] + :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.MongoDBCollectionListResult] = 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_mongo_db_collections_request( + resource_group_name=resource_group_name, + account_name=account_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) + + 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("MongoDBCollectionListResult", 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_mongo_db_collection( + self, resource_group_name: str, account_name: str, database_name: str, collection_name: str, **kwargs: Any + ) -> _models.MongoDBCollectionGetResults: + """Gets the MongoDB collection under an existing Azure Cosmos DB database account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param database_name: Cosmos DB database name. Required. + :type database_name: str + :param collection_name: Cosmos DB collection name. Required. + :type collection_name: str + :return: MongoDBCollectionGetResults or the result of cls(response) + :rtype: ~azure.mgmt.cosmosdb.models.MongoDBCollectionGetResults :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -1777,12 +1902,13 @@ def get_mongo_db_database_throughput( _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.ThroughputSettingsGetResults] = kwargs.pop("cls", None) + cls: ClsType[_models.MongoDBCollectionGetResults] = kwargs.pop("cls", None) - _request = build_get_mongo_db_database_throughput_request( + _request = build_get_mongo_db_collection_request( resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, + collection_name=collection_name, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, @@ -1799,21 +1925,26 @@ def get_mongo_db_database_throughput( if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("ThroughputSettingsGetResults", pipeline_response.http_response) + deserialized = self._deserialize("MongoDBCollectionGetResults", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - def _update_mongo_db_database_throughput_initial( # pylint: disable=name-too-long + def _create_update_mongo_db_collection_initial( # pylint: disable=name-too-long self, resource_group_name: str, account_name: str, database_name: str, - update_throughput_parameters: Union[_models.ThroughputSettingsUpdateParameters, IO[bytes]], + collection_name: str, + create_update_mongo_db_collection_parameters: Union[_models.MongoDBCollectionCreateUpdateParameters, IO[bytes]], **kwargs: Any ) -> Iterator[bytes]: error_map: MutableMapping = { @@ -1834,15 +1965,18 @@ def _update_mongo_db_database_throughput_initial( # pylint: disable=name-too-lo content_type = content_type or "application/json" _json = None _content = None - if isinstance(update_throughput_parameters, (IOBase, bytes)): - _content = update_throughput_parameters + if isinstance(create_update_mongo_db_collection_parameters, (IOBase, bytes)): + _content = create_update_mongo_db_collection_parameters else: - _json = self._serialize.body(update_throughput_parameters, "ThroughputSettingsUpdateParameters") + _json = self._serialize.body( + create_update_mongo_db_collection_parameters, "MongoDBCollectionCreateUpdateParameters" + ) - _request = build_update_mongo_db_database_throughput_request( + _request = build_create_update_mongo_db_collection_request( resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, + collection_name=collection_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, @@ -1867,14 +2001,19 @@ def _update_mongo_db_database_throughput_initial( # pylint: disable=name-too-lo except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + 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["azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("azure-AsyncOperation") + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") ) - response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) @@ -1884,17 +2023,18 @@ def _update_mongo_db_database_throughput_initial( # pylint: disable=name-too-lo return deserialized # type: ignore @overload - def begin_update_mongo_db_database_throughput( # pylint: disable=name-too-long + def begin_create_update_mongo_db_collection( self, resource_group_name: str, account_name: str, database_name: str, - update_throughput_parameters: _models.ThroughputSettingsUpdateParameters, + collection_name: str, + create_update_mongo_db_collection_parameters: _models.MongoDBCollectionCreateUpdateParameters, *, content_type: str = "application/json", **kwargs: Any - ) -> LROPoller[_models.ThroughputSettingsGetResults]: - """Update RUs per second of the an Azure Cosmos DB MongoDB database. + ) -> LROPoller[_models.MongoDBCollectionGetResults]: + """Create or update an Azure Cosmos DB MongoDB Collection. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -1903,31 +2043,34 @@ def begin_update_mongo_db_database_throughput( # pylint: disable=name-too-long :type account_name: str :param database_name: Cosmos DB database name. Required. :type database_name: str - :param update_throughput_parameters: The RUs per second of the parameters to provide for the - current MongoDB database. Required. - :type update_throughput_parameters: - ~azure.mgmt.cosmosdb.models.ThroughputSettingsUpdateParameters + :param collection_name: Cosmos DB collection name. Required. + :type collection_name: str + :param create_update_mongo_db_collection_parameters: The parameters to provide for the current + MongoDB Collection. Required. + :type create_update_mongo_db_collection_parameters: + ~azure.mgmt.cosmosdb.models.MongoDBCollectionCreateUpdateParameters :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 ThroughputSettingsGetResults or the - result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.ThroughputSettingsGetResults] + :return: An instance of LROPoller that returns either MongoDBCollectionGetResults or the result + of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.MongoDBCollectionGetResults] :raises ~azure.core.exceptions.HttpResponseError: """ @overload - def begin_update_mongo_db_database_throughput( # pylint: disable=name-too-long + def begin_create_update_mongo_db_collection( self, resource_group_name: str, account_name: str, database_name: str, - update_throughput_parameters: IO[bytes], + collection_name: str, + create_update_mongo_db_collection_parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> LROPoller[_models.ThroughputSettingsGetResults]: - """Update RUs per second of the an Azure Cosmos DB MongoDB database. + ) -> LROPoller[_models.MongoDBCollectionGetResults]: + """Create or update an Azure Cosmos DB MongoDB Collection. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -1936,28 +2079,31 @@ def begin_update_mongo_db_database_throughput( # pylint: disable=name-too-long :type account_name: str :param database_name: Cosmos DB database name. Required. :type database_name: str - :param update_throughput_parameters: The RUs per second of the parameters to provide for the - current MongoDB database. Required. - :type update_throughput_parameters: IO[bytes] + :param collection_name: Cosmos DB collection name. Required. + :type collection_name: str + :param create_update_mongo_db_collection_parameters: The parameters to provide for the current + MongoDB Collection. Required. + :type create_update_mongo_db_collection_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 ThroughputSettingsGetResults or the - result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.ThroughputSettingsGetResults] + :return: An instance of LROPoller that returns either MongoDBCollectionGetResults or the result + of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.MongoDBCollectionGetResults] :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace - def begin_update_mongo_db_database_throughput( # pylint: disable=name-too-long + def begin_create_update_mongo_db_collection( self, resource_group_name: str, account_name: str, database_name: str, - update_throughput_parameters: Union[_models.ThroughputSettingsUpdateParameters, IO[bytes]], + collection_name: str, + create_update_mongo_db_collection_parameters: Union[_models.MongoDBCollectionCreateUpdateParameters, IO[bytes]], **kwargs: Any - ) -> LROPoller[_models.ThroughputSettingsGetResults]: - """Update RUs per second of the an Azure Cosmos DB MongoDB database. + ) -> LROPoller[_models.MongoDBCollectionGetResults]: + """Create or update an Azure Cosmos DB MongoDB Collection. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -1966,14 +2112,16 @@ def begin_update_mongo_db_database_throughput( # pylint: disable=name-too-long :type account_name: str :param database_name: Cosmos DB database name. Required. :type database_name: str - :param update_throughput_parameters: The RUs per second of the parameters to provide for the - current MongoDB database. Is either a ThroughputSettingsUpdateParameters type or a IO[bytes] - type. Required. - :type update_throughput_parameters: - ~azure.mgmt.cosmosdb.models.ThroughputSettingsUpdateParameters or IO[bytes] - :return: An instance of LROPoller that returns either ThroughputSettingsGetResults or the - result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.ThroughputSettingsGetResults] + :param collection_name: Cosmos DB collection name. Required. + :type collection_name: str + :param create_update_mongo_db_collection_parameters: The parameters to provide for the current + MongoDB Collection. Is either a MongoDBCollectionCreateUpdateParameters type or a IO[bytes] + type. Required. + :type create_update_mongo_db_collection_parameters: + ~azure.mgmt.cosmosdb.models.MongoDBCollectionCreateUpdateParameters or IO[bytes] + :return: An instance of LROPoller that returns either MongoDBCollectionGetResults or the result + of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.MongoDBCollectionGetResults] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -1981,16 +2129,17 @@ def begin_update_mongo_db_database_throughput( # pylint: disable=name-too-long 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.ThroughputSettingsGetResults] = kwargs.pop("cls", None) + cls: ClsType[_models.MongoDBCollectionGetResults] = 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_mongo_db_database_throughput_initial( + raw_result = self._create_update_mongo_db_collection_initial( resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, - update_throughput_parameters=update_throughput_parameters, + collection_name=collection_name, + create_update_mongo_db_collection_parameters=create_update_mongo_db_collection_parameters, api_version=api_version, content_type=content_type, cls=lambda x, y, z: x, @@ -2002,30 +2151,32 @@ def begin_update_mongo_db_database_throughput( # pylint: disable=name-too-long kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ThroughputSettingsGetResults", pipeline_response.http_response) + deserialized = self._deserialize("MongoDBCollectionGetResults", 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, **kwargs)) + 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.ThroughputSettingsGetResults].from_continuation_token( + return LROPoller[_models.MongoDBCollectionGetResults].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller[_models.ThroughputSettingsGetResults]( + return LROPoller[_models.MongoDBCollectionGetResults]( self._client, raw_result, get_long_running_output, polling_method # type: ignore ) - def _migrate_mongo_db_database_to_autoscale_initial( # pylint: disable=name-too-long - self, resource_group_name: str, account_name: str, database_name: str, **kwargs: Any + def _delete_mongo_db_collection_initial( + self, resource_group_name: str, account_name: str, database_name: str, collection_name: str, **kwargs: Any ) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -2041,10 +2192,11 @@ def _migrate_mongo_db_database_to_autoscale_initial( # pylint: disable=name-too 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_migrate_mongo_db_database_to_autoscale_request( + _request = build_delete_mongo_db_collection_request( resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, + collection_name=collection_name, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, @@ -2060,20 +2212,24 @@ def _migrate_mongo_db_database_to_autoscale_initial( # pylint: disable=name-too response = pipeline_response.http_response - if response.status_code not in [200, 202]: + 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + 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["azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("azure-AsyncOperation") + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") ) - response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) @@ -2083,10 +2239,10 @@ def _migrate_mongo_db_database_to_autoscale_initial( # pylint: disable=name-too return deserialized # type: ignore @distributed_trace - def begin_migrate_mongo_db_database_to_autoscale( # pylint: disable=name-too-long - self, resource_group_name: str, account_name: str, database_name: str, **kwargs: Any - ) -> LROPoller[_models.ThroughputSettingsGetResults]: - """Migrate an Azure Cosmos DB MongoDB database from manual throughput to autoscale. + def begin_delete_mongo_db_collection( + self, resource_group_name: str, account_name: str, database_name: str, collection_name: str, **kwargs: Any + ) -> LROPoller[None]: + """Deletes an existing Azure Cosmos DB MongoDB Collection. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -2095,24 +2251,26 @@ def begin_migrate_mongo_db_database_to_autoscale( # pylint: disable=name-too-lo :type account_name: str :param database_name: Cosmos DB database name. Required. :type database_name: str - :return: An instance of LROPoller that returns either ThroughputSettingsGetResults or the - result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.ThroughputSettingsGetResults] + :param collection_name: Cosmos DB collection name. Required. + :type collection_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[_models.ThroughputSettingsGetResults] = kwargs.pop("cls", 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._migrate_mongo_db_database_to_autoscale_initial( + raw_result = self._delete_mongo_db_collection_initial( resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, + collection_name=collection_name, api_version=api_version, cls=lambda x, y, z: x, headers=_headers, @@ -2122,31 +2280,35 @@ def begin_migrate_mongo_db_database_to_autoscale( # pylint: disable=name-too-lo raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ThroughputSettingsGetResults", pipeline_response.http_response) + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return cls(pipeline_response, None, {}) # type: ignore if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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.ThroughputSettingsGetResults].from_continuation_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[_models.ThroughputSettingsGetResults]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - def _migrate_mongo_db_database_to_manual_throughput_initial( # pylint: disable=name-too-long - self, resource_group_name: str, account_name: str, database_name: str, **kwargs: Any + def _list_mongo_db_collection_partition_merge_initial( # pylint: disable=name-too-long + self, + resource_group_name: str, + account_name: str, + database_name: str, + collection_name: str, + merge_parameters: Union[_models.MergeParameters, IO[bytes]], + **kwargs: Any ) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -2156,18 +2318,31 @@ def _migrate_mongo_db_database_to_manual_throughput_initial( # pylint: disable= } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) 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) - _request = build_migrate_mongo_db_database_to_manual_throughput_request( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(merge_parameters, (IOBase, bytes)): + _content = merge_parameters + else: + _json = self._serialize.body(merge_parameters, "MergeParameters") + + _request = build_list_mongo_db_collection_partition_merge_request( resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, + collection_name=collection_name, subscription_id=self._config.subscription_id, api_version=api_version, + content_type=content_type, + json=_json, + content=_content, headers=_headers, params=_params, ) @@ -2191,10 +2366,11 @@ def _migrate_mongo_db_database_to_manual_throughput_initial( # pylint: disable= response_headers = {} if response.status_code == 202: - response_headers["azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("azure-AsyncOperation") + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") ) - response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) @@ -2203,11 +2379,87 @@ def _migrate_mongo_db_database_to_manual_throughput_initial( # pylint: disable= return deserialized # type: ignore + @overload + def begin_list_mongo_db_collection_partition_merge( # pylint: disable=name-too-long + self, + resource_group_name: str, + account_name: str, + database_name: str, + collection_name: str, + merge_parameters: _models.MergeParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.PhysicalPartitionStorageInfoCollection]: + """Merges the partitions of a MongoDB Collection. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param database_name: Cosmos DB database name. Required. + :type database_name: str + :param collection_name: Cosmos DB collection name. Required. + :type collection_name: str + :param merge_parameters: The parameters for the merge operation. Required. + :type merge_parameters: ~azure.mgmt.cosmosdb.models.MergeParameters + :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 PhysicalPartitionStorageInfoCollection or + the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.PhysicalPartitionStorageInfoCollection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_list_mongo_db_collection_partition_merge( # pylint: disable=name-too-long + self, + resource_group_name: str, + account_name: str, + database_name: str, + collection_name: str, + merge_parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.PhysicalPartitionStorageInfoCollection]: + """Merges the partitions of a MongoDB Collection. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param database_name: Cosmos DB database name. Required. + :type database_name: str + :param collection_name: Cosmos DB collection name. Required. + :type collection_name: str + :param merge_parameters: The parameters for the merge operation. Required. + :type merge_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 PhysicalPartitionStorageInfoCollection or + the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.PhysicalPartitionStorageInfoCollection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + @distributed_trace - def begin_migrate_mongo_db_database_to_manual_throughput( # pylint: disable=name-too-long - self, resource_group_name: str, account_name: str, database_name: str, **kwargs: Any - ) -> LROPoller[_models.ThroughputSettingsGetResults]: - """Migrate an Azure Cosmos DB MongoDB database from autoscale to manual throughput. + def begin_list_mongo_db_collection_partition_merge( # pylint: disable=name-too-long + self, + resource_group_name: str, + account_name: str, + database_name: str, + collection_name: str, + merge_parameters: Union[_models.MergeParameters, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.PhysicalPartitionStorageInfoCollection]: + """Merges the partitions of a MongoDB Collection. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -2216,25 +2468,35 @@ def begin_migrate_mongo_db_database_to_manual_throughput( # pylint: disable=nam :type account_name: str :param database_name: Cosmos DB database name. Required. :type database_name: str - :return: An instance of LROPoller that returns either ThroughputSettingsGetResults or the - result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.ThroughputSettingsGetResults] + :param collection_name: Cosmos DB collection name. Required. + :type collection_name: str + :param merge_parameters: The parameters for the merge operation. Is either a MergeParameters + type or a IO[bytes] type. Required. + :type merge_parameters: ~azure.mgmt.cosmosdb.models.MergeParameters or IO[bytes] + :return: An instance of LROPoller that returns either PhysicalPartitionStorageInfoCollection or + the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.PhysicalPartitionStorageInfoCollection] :raises ~azure.core.exceptions.HttpResponseError: """ - _headers = kwargs.pop("headers", {}) 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)) - cls: ClsType[_models.ThroughputSettingsGetResults] = kwargs.pop("cls", None) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.PhysicalPartitionStorageInfoCollection] = 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_mongo_db_database_to_manual_throughput_initial( + raw_result = self._list_mongo_db_collection_partition_merge_initial( resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, + collection_name=collection_name, + merge_parameters=merge_parameters, api_version=api_version, + content_type=content_type, cls=lambda x, y, z: x, headers=_headers, params=_params, @@ -2244,34 +2506,37 @@ def begin_migrate_mongo_db_database_to_manual_throughput( # pylint: disable=nam kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ThroughputSettingsGetResults", pipeline_response.http_response) + deserialized = self._deserialize("PhysicalPartitionStorageInfoCollection", 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, **kwargs)) + 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.ThroughputSettingsGetResults].from_continuation_token( + return LROPoller[_models.PhysicalPartitionStorageInfoCollection].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller[_models.ThroughputSettingsGetResults]( + return LROPoller[_models.PhysicalPartitionStorageInfoCollection]( self._client, raw_result, get_long_running_output, polling_method # type: ignore ) - def _mongo_db_database_retrieve_throughput_distribution_initial( # pylint: disable=name-too-long + def _retrieve_continuous_backup_information_initial( # pylint: disable=name-too-long self, resource_group_name: str, account_name: str, database_name: str, - retrieve_throughput_parameters: Union[_models.RetrieveThroughputParameters, IO[bytes]], + collection_name: str, + location: Union[_models.ContinuousBackupRestoreLocation, IO[bytes]], **kwargs: Any ) -> Iterator[bytes]: error_map: MutableMapping = { @@ -2292,15 +2557,16 @@ def _mongo_db_database_retrieve_throughput_distribution_initial( # pylint: disa content_type = content_type or "application/json" _json = None _content = None - if isinstance(retrieve_throughput_parameters, (IOBase, bytes)): - _content = retrieve_throughput_parameters + if isinstance(location, (IOBase, bytes)): + _content = location else: - _json = self._serialize.body(retrieve_throughput_parameters, "RetrieveThroughputParameters") + _json = self._serialize.body(location, "ContinuousBackupRestoreLocation") - _request = build_mongo_db_database_retrieve_throughput_distribution_request( + _request = build_retrieve_continuous_backup_information_request( resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, + collection_name=collection_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, @@ -2329,10 +2595,8 @@ def _mongo_db_database_retrieve_throughput_distribution_initial( # pylint: disa 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["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) @@ -2342,17 +2606,18 @@ def _mongo_db_database_retrieve_throughput_distribution_initial( # pylint: disa return deserialized # type: ignore @overload - def begin_mongo_db_database_retrieve_throughput_distribution( # pylint: disable=name-too-long + def begin_retrieve_continuous_backup_information( # pylint: disable=name-too-long self, resource_group_name: str, account_name: str, database_name: str, - retrieve_throughput_parameters: _models.RetrieveThroughputParameters, + collection_name: str, + location: _models.ContinuousBackupRestoreLocation, *, content_type: str = "application/json", **kwargs: Any - ) -> LROPoller[_models.PhysicalPartitionThroughputInfoResult]: - """Retrieve throughput distribution for an Azure Cosmos DB MongoDB database. + ) -> LROPoller[_models.BackupInformation]: + """Retrieves continuous backup information for a Mongodb collection. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -2361,31 +2626,32 @@ def begin_mongo_db_database_retrieve_throughput_distribution( # pylint: disable :type account_name: str :param database_name: Cosmos DB database name. Required. :type database_name: str - :param retrieve_throughput_parameters: The parameters to provide for retrieving throughput - distribution for the current MongoDB database. Required. - :type retrieve_throughput_parameters: ~azure.mgmt.cosmosdb.models.RetrieveThroughputParameters + :param collection_name: Cosmos DB collection name. Required. + :type collection_name: str + :param location: The name of the continuous backup restore location. Required. + :type location: ~azure.mgmt.cosmosdb.models.ContinuousBackupRestoreLocation :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 PhysicalPartitionThroughputInfoResult or - the result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.PhysicalPartitionThroughputInfoResult] + :return: An instance of LROPoller that returns either BackupInformation or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.BackupInformation] :raises ~azure.core.exceptions.HttpResponseError: """ @overload - def begin_mongo_db_database_retrieve_throughput_distribution( # pylint: disable=name-too-long + def begin_retrieve_continuous_backup_information( # pylint: disable=name-too-long self, resource_group_name: str, account_name: str, database_name: str, - retrieve_throughput_parameters: IO[bytes], + collection_name: str, + location: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> LROPoller[_models.PhysicalPartitionThroughputInfoResult]: - """Retrieve throughput distribution for an Azure Cosmos DB MongoDB database. + ) -> LROPoller[_models.BackupInformation]: + """Retrieves continuous backup information for a Mongodb collection. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -2394,29 +2660,30 @@ def begin_mongo_db_database_retrieve_throughput_distribution( # pylint: disable :type account_name: str :param database_name: Cosmos DB database name. Required. :type database_name: str - :param retrieve_throughput_parameters: The parameters to provide for retrieving throughput - distribution for the current MongoDB database. Required. - :type retrieve_throughput_parameters: IO[bytes] + :param collection_name: Cosmos DB collection name. Required. + :type collection_name: str + :param location: The name of the continuous backup restore location. Required. + :type location: 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 PhysicalPartitionThroughputInfoResult or - the result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.PhysicalPartitionThroughputInfoResult] + :return: An instance of LROPoller that returns either BackupInformation or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.BackupInformation] :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace - def begin_mongo_db_database_retrieve_throughput_distribution( # pylint: disable=name-too-long + def begin_retrieve_continuous_backup_information( # pylint: disable=name-too-long self, resource_group_name: str, account_name: str, database_name: str, - retrieve_throughput_parameters: Union[_models.RetrieveThroughputParameters, IO[bytes]], + collection_name: str, + location: Union[_models.ContinuousBackupRestoreLocation, IO[bytes]], **kwargs: Any - ) -> LROPoller[_models.PhysicalPartitionThroughputInfoResult]: - """Retrieve throughput distribution for an Azure Cosmos DB MongoDB database. + ) -> LROPoller[_models.BackupInformation]: + """Retrieves continuous backup information for a Mongodb collection. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -2425,15 +2692,14 @@ def begin_mongo_db_database_retrieve_throughput_distribution( # pylint: disable :type account_name: str :param database_name: Cosmos DB database name. Required. :type database_name: str - :param retrieve_throughput_parameters: The parameters to provide for retrieving throughput - distribution for the current MongoDB database. Is either a RetrieveThroughputParameters type or - a IO[bytes] type. Required. - :type retrieve_throughput_parameters: ~azure.mgmt.cosmosdb.models.RetrieveThroughputParameters - or IO[bytes] - :return: An instance of LROPoller that returns either PhysicalPartitionThroughputInfoResult or - the result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.PhysicalPartitionThroughputInfoResult] + :param collection_name: Cosmos DB collection name. Required. + :type collection_name: str + :param location: The name of the continuous backup restore location. Is either a + ContinuousBackupRestoreLocation type or a IO[bytes] type. Required. + :type location: ~azure.mgmt.cosmosdb.models.ContinuousBackupRestoreLocation or IO[bytes] + :return: An instance of LROPoller that returns either BackupInformation or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.BackupInformation] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -2441,16 +2707,17 @@ def begin_mongo_db_database_retrieve_throughput_distribution( # pylint: disable 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.PhysicalPartitionThroughputInfoResult] = kwargs.pop("cls", None) + cls: ClsType[_models.BackupInformation] = 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._mongo_db_database_retrieve_throughput_distribution_initial( + raw_result = self._retrieve_continuous_backup_information_initial( resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, - retrieve_throughput_parameters=retrieve_throughput_parameters, + collection_name=collection_name, + location=location, api_version=api_version, content_type=content_type, cls=lambda x, y, z: x, @@ -2462,7 +2729,7 @@ def begin_mongo_db_database_retrieve_throughput_distribution( # pylint: disable kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("PhysicalPartitionThroughputInfoResult", pipeline_response.http_response) + deserialized = self._deserialize("BackupInformation", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized @@ -2476,22 +2743,91 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller[_models.PhysicalPartitionThroughputInfoResult].from_continuation_token( + return LROPoller[_models.BackupInformation].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller[_models.PhysicalPartitionThroughputInfoResult]( + return LROPoller[_models.BackupInformation]( self._client, raw_result, get_long_running_output, polling_method # type: ignore ) - def _mongo_db_database_redistribute_throughput_initial( # pylint: disable=name-too-long + @distributed_trace + def get_mongo_db_collection_throughput( + self, resource_group_name: str, account_name: str, database_name: str, collection_name: str, **kwargs: Any + ) -> _models.ThroughputSettingsGetResults: + """Gets the RUs per second of the MongoDB collection under an existing Azure Cosmos DB database + account with the provided name. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param database_name: Cosmos DB database name. Required. + :type database_name: str + :param collection_name: Cosmos DB collection name. Required. + :type collection_name: str + :return: ThroughputSettingsGetResults or the result of cls(response) + :rtype: ~azure.mgmt.cosmosdb.models.ThroughputSettingsGetResults + :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.ThroughputSettingsGetResults] = kwargs.pop("cls", None) + + _request = build_get_mongo_db_collection_throughput_request( + resource_group_name=resource_group_name, + account_name=account_name, + database_name=database_name, + collection_name=collection_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("ThroughputSettingsGetResults", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + def _update_mongo_db_collection_throughput_initial( # pylint: disable=name-too-long self, resource_group_name: str, account_name: str, database_name: str, - redistribute_throughput_parameters: Union[_models.RedistributeThroughputParameters, IO[bytes]], + collection_name: str, + update_throughput_parameters: Union[_models.ThroughputSettingsUpdateParameters, IO[bytes]], **kwargs: Any ) -> Iterator[bytes]: error_map: MutableMapping = { @@ -2512,15 +2848,16 @@ def _mongo_db_database_redistribute_throughput_initial( # pylint: disable=name- content_type = content_type or "application/json" _json = None _content = None - if isinstance(redistribute_throughput_parameters, (IOBase, bytes)): - _content = redistribute_throughput_parameters + if isinstance(update_throughput_parameters, (IOBase, bytes)): + _content = update_throughput_parameters else: - _json = self._serialize.body(redistribute_throughput_parameters, "RedistributeThroughputParameters") + _json = self._serialize.body(update_throughput_parameters, "ThroughputSettingsUpdateParameters") - _request = build_mongo_db_database_redistribute_throughput_request( + _request = build_update_mongo_db_collection_throughput_request( resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, + collection_name=collection_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, @@ -2545,14 +2882,19 @@ def _mongo_db_database_redistribute_throughput_initial( # pylint: disable=name- except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + 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["azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("azure-AsyncOperation") + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") ) - response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) @@ -2562,17 +2904,18 @@ def _mongo_db_database_redistribute_throughput_initial( # pylint: disable=name- return deserialized # type: ignore @overload - def begin_mongo_db_database_redistribute_throughput( # pylint: disable=name-too-long + def begin_update_mongo_db_collection_throughput( # pylint: disable=name-too-long self, resource_group_name: str, account_name: str, database_name: str, - redistribute_throughput_parameters: _models.RedistributeThroughputParameters, + collection_name: str, + update_throughput_parameters: _models.ThroughputSettingsUpdateParameters, *, content_type: str = "application/json", **kwargs: Any - ) -> LROPoller[_models.PhysicalPartitionThroughputInfoResult]: - """Redistribute throughput for an Azure Cosmos DB MongoDB database. + ) -> LROPoller[_models.ThroughputSettingsGetResults]: + """Update the RUs per second of an Azure Cosmos DB MongoDB collection. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -2581,32 +2924,34 @@ def begin_mongo_db_database_redistribute_throughput( # pylint: disable=name-too :type account_name: str :param database_name: Cosmos DB database name. Required. :type database_name: str - :param redistribute_throughput_parameters: The parameters to provide for redistributing - throughput for the current MongoDB database. Required. - :type redistribute_throughput_parameters: - ~azure.mgmt.cosmosdb.models.RedistributeThroughputParameters + :param collection_name: Cosmos DB collection name. Required. + :type collection_name: str + :param update_throughput_parameters: The RUs per second of the parameters to provide for the + current MongoDB collection. Required. + :type update_throughput_parameters: + ~azure.mgmt.cosmosdb.models.ThroughputSettingsUpdateParameters :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 PhysicalPartitionThroughputInfoResult or - the result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.PhysicalPartitionThroughputInfoResult] + :return: An instance of LROPoller that returns either ThroughputSettingsGetResults or the + result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.ThroughputSettingsGetResults] :raises ~azure.core.exceptions.HttpResponseError: """ @overload - def begin_mongo_db_database_redistribute_throughput( # pylint: disable=name-too-long + def begin_update_mongo_db_collection_throughput( # pylint: disable=name-too-long self, resource_group_name: str, account_name: str, database_name: str, - redistribute_throughput_parameters: IO[bytes], + collection_name: str, + update_throughput_parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> LROPoller[_models.PhysicalPartitionThroughputInfoResult]: - """Redistribute throughput for an Azure Cosmos DB MongoDB database. + ) -> LROPoller[_models.ThroughputSettingsGetResults]: + """Update the RUs per second of an Azure Cosmos DB MongoDB collection. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -2615,29 +2960,31 @@ def begin_mongo_db_database_redistribute_throughput( # pylint: disable=name-too :type account_name: str :param database_name: Cosmos DB database name. Required. :type database_name: str - :param redistribute_throughput_parameters: The parameters to provide for redistributing - throughput for the current MongoDB database. Required. - :type redistribute_throughput_parameters: IO[bytes] + :param collection_name: Cosmos DB collection name. Required. + :type collection_name: str + :param update_throughput_parameters: The RUs per second of the parameters to provide for the + current MongoDB collection. Required. + :type update_throughput_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 PhysicalPartitionThroughputInfoResult or - the result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.PhysicalPartitionThroughputInfoResult] + :return: An instance of LROPoller that returns either ThroughputSettingsGetResults or the + result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.ThroughputSettingsGetResults] :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace - def begin_mongo_db_database_redistribute_throughput( # pylint: disable=name-too-long + def begin_update_mongo_db_collection_throughput( # pylint: disable=name-too-long self, resource_group_name: str, account_name: str, database_name: str, - redistribute_throughput_parameters: Union[_models.RedistributeThroughputParameters, IO[bytes]], + collection_name: str, + update_throughput_parameters: Union[_models.ThroughputSettingsUpdateParameters, IO[bytes]], **kwargs: Any - ) -> LROPoller[_models.PhysicalPartitionThroughputInfoResult]: - """Redistribute throughput for an Azure Cosmos DB MongoDB database. + ) -> LROPoller[_models.ThroughputSettingsGetResults]: + """Update the RUs per second of an Azure Cosmos DB MongoDB collection. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -2646,15 +2993,16 @@ def begin_mongo_db_database_redistribute_throughput( # pylint: disable=name-too :type account_name: str :param database_name: Cosmos DB database name. Required. :type database_name: str - :param redistribute_throughput_parameters: The parameters to provide for redistributing - throughput for the current MongoDB database. Is either a RedistributeThroughputParameters type - or a IO[bytes] type. Required. - :type redistribute_throughput_parameters: - ~azure.mgmt.cosmosdb.models.RedistributeThroughputParameters or IO[bytes] - :return: An instance of LROPoller that returns either PhysicalPartitionThroughputInfoResult or - the result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.PhysicalPartitionThroughputInfoResult] + :param collection_name: Cosmos DB collection name. Required. + :type collection_name: str + :param update_throughput_parameters: The RUs per second of the parameters to provide for the + current MongoDB collection. Is either a ThroughputSettingsUpdateParameters type or a IO[bytes] + type. Required. + :type update_throughput_parameters: + ~azure.mgmt.cosmosdb.models.ThroughputSettingsUpdateParameters or IO[bytes] + :return: An instance of LROPoller that returns either ThroughputSettingsGetResults or the + result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.ThroughputSettingsGetResults] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -2662,16 +3010,17 @@ def begin_mongo_db_database_redistribute_throughput( # pylint: disable=name-too 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.PhysicalPartitionThroughputInfoResult] = kwargs.pop("cls", None) + cls: ClsType[_models.ThroughputSettingsGetResults] = 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._mongo_db_database_redistribute_throughput_initial( + raw_result = self._update_mongo_db_collection_throughput_initial( resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, - redistribute_throughput_parameters=redistribute_throughput_parameters, + collection_name=collection_name, + update_throughput_parameters=update_throughput_parameters, api_version=api_version, content_type=content_type, cls=lambda x, y, z: x, @@ -2683,7 +3032,7 @@ def begin_mongo_db_database_redistribute_throughput( # pylint: disable=name-too kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("PhysicalPartitionThroughputInfoResult", pipeline_response.http_response) + deserialized = self._deserialize("ThroughputSettingsGetResults", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized @@ -2697,24 +3046,18 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller[_models.PhysicalPartitionThroughputInfoResult].from_continuation_token( + return LROPoller[_models.ThroughputSettingsGetResults].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller[_models.PhysicalPartitionThroughputInfoResult]( + return LROPoller[_models.ThroughputSettingsGetResults]( self._client, raw_result, get_long_running_output, polling_method # type: ignore ) - def _mongo_db_container_retrieve_throughput_distribution_initial( # pylint: disable=name-too-long - self, - resource_group_name: str, - account_name: str, - database_name: str, - collection_name: str, - retrieve_throughput_parameters: Union[_models.RetrieveThroughputParameters, IO[bytes]], - **kwargs: Any + def _migrate_mongo_db_collection_to_autoscale_initial( # pylint: disable=name-too-long + self, resource_group_name: str, account_name: str, database_name: str, collection_name: str, **kwargs: Any ) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -2724,31 +3067,19 @@ def _mongo_db_container_retrieve_throughput_distribution_initial( # pylint: dis } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = case_insensitive_dict(kwargs.pop("headers", {}) 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)) - 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(retrieve_throughput_parameters, (IOBase, bytes)): - _content = retrieve_throughput_parameters - else: - _json = self._serialize.body(retrieve_throughput_parameters, "RetrieveThroughputParameters") - - _request = build_mongo_db_container_retrieve_throughput_distribution_request( + _request = build_migrate_mongo_db_collection_to_autoscale_request( resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, collection_name=collection_name, subscription_id=self._config.subscription_id, api_version=api_version, - content_type=content_type, - json=_json, - content=_content, headers=_headers, params=_params, ) @@ -2772,10 +3103,11 @@ def _mongo_db_container_retrieve_throughput_distribution_initial( # pylint: dis response_headers = {} if response.status_code == 202: - response_headers["azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("azure-AsyncOperation") + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") ) - response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) @@ -2784,19 +3116,11 @@ def _mongo_db_container_retrieve_throughput_distribution_initial( # pylint: dis return deserialized # type: ignore - @overload - def begin_mongo_db_container_retrieve_throughput_distribution( # pylint: disable=name-too-long - self, - resource_group_name: str, - account_name: str, - database_name: str, - collection_name: str, - retrieve_throughput_parameters: _models.RetrieveThroughputParameters, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.PhysicalPartitionThroughputInfoResult]: - """Retrieve throughput distribution for an Azure Cosmos DB MongoDB container. + @distributed_trace + def begin_migrate_mongo_db_collection_to_autoscale( # pylint: disable=name-too-long + self, resource_group_name: str, account_name: str, database_name: str, collection_name: str, **kwargs: Any + ) -> LROPoller[_models.ThroughputSettingsGetResults]: + """Migrate an Azure Cosmos DB MongoDB collection from manual throughput to autoscale. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -2807,66 +3131,124 @@ def begin_mongo_db_container_retrieve_throughput_distribution( # pylint: disabl :type database_name: str :param collection_name: Cosmos DB collection name. Required. :type collection_name: str - :param retrieve_throughput_parameters: The parameters to provide for retrieving throughput - distribution for the current MongoDB container. Required. - :type retrieve_throughput_parameters: ~azure.mgmt.cosmosdb.models.RetrieveThroughputParameters - :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 PhysicalPartitionThroughputInfoResult or - the result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.PhysicalPartitionThroughputInfoResult] + :return: An instance of LROPoller that returns either ThroughputSettingsGetResults or the + result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.ThroughputSettingsGetResults] :raises ~azure.core.exceptions.HttpResponseError: """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - @overload - def begin_mongo_db_container_retrieve_throughput_distribution( # pylint: disable=name-too-long - self, - resource_group_name: str, - account_name: str, - database_name: str, - collection_name: str, - retrieve_throughput_parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.PhysicalPartitionThroughputInfoResult]: - """Retrieve throughput distribution for an Azure Cosmos DB MongoDB container. + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.ThroughputSettingsGetResults] = 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_mongo_db_collection_to_autoscale_initial( + resource_group_name=resource_group_name, + account_name=account_name, + database_name=database_name, + collection_name=collection_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) - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param account_name: Cosmos DB database account name. Required. - :type account_name: str - :param database_name: Cosmos DB database name. Required. - :type database_name: str - :param collection_name: Cosmos DB collection name. Required. - :type collection_name: str - :param retrieve_throughput_parameters: The parameters to provide for retrieving throughput - distribution for the current MongoDB container. Required. - :type retrieve_throughput_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 PhysicalPartitionThroughputInfoResult or - the result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.PhysicalPartitionThroughputInfoResult] - :raises ~azure.core.exceptions.HttpResponseError: - """ + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("ThroughputSettingsGetResults", 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": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.ThroughputSettingsGetResults].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.ThroughputSettingsGetResults]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + def _migrate_mongo_db_collection_to_manual_throughput_initial( # pylint: disable=name-too-long + self, resource_group_name: str, account_name: str, database_name: str, collection_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_migrate_mongo_db_collection_to_manual_throughput_request( + resource_group_name=resource_group_name, + account_name=account_name, + database_name=database_name, + collection_name=collection_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) + raise HttpResponseError(response=response, 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.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_mongo_db_container_retrieve_throughput_distribution( # pylint: disable=name-too-long - self, - resource_group_name: str, - account_name: str, - database_name: str, - collection_name: str, - retrieve_throughput_parameters: Union[_models.RetrieveThroughputParameters, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.PhysicalPartitionThroughputInfoResult]: - """Retrieve throughput distribution for an Azure Cosmos DB MongoDB container. + def begin_migrate_mongo_db_collection_to_manual_throughput( # pylint: disable=name-too-long + self, resource_group_name: str, account_name: str, database_name: str, collection_name: str, **kwargs: Any + ) -> LROPoller[_models.ThroughputSettingsGetResults]: + """Migrate an Azure Cosmos DB MongoDB collection from autoscale to manual throughput. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -2877,35 +3259,26 @@ def begin_mongo_db_container_retrieve_throughput_distribution( # pylint: disabl :type database_name: str :param collection_name: Cosmos DB collection name. Required. :type collection_name: str - :param retrieve_throughput_parameters: The parameters to provide for retrieving throughput - distribution for the current MongoDB container. Is either a RetrieveThroughputParameters type - or a IO[bytes] type. Required. - :type retrieve_throughput_parameters: ~azure.mgmt.cosmosdb.models.RetrieveThroughputParameters - or IO[bytes] - :return: An instance of LROPoller that returns either PhysicalPartitionThroughputInfoResult or - the result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.PhysicalPartitionThroughputInfoResult] + :return: An instance of LROPoller that returns either ThroughputSettingsGetResults or the + result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.ThroughputSettingsGetResults] :raises ~azure.core.exceptions.HttpResponseError: """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) 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)) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.PhysicalPartitionThroughputInfoResult] = kwargs.pop("cls", None) + cls: ClsType[_models.ThroughputSettingsGetResults] = 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._mongo_db_container_retrieve_throughput_distribution_initial( + raw_result = self._migrate_mongo_db_collection_to_manual_throughput_initial( resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, collection_name=collection_name, - retrieve_throughput_parameters=retrieve_throughput_parameters, api_version=api_version, - content_type=content_type, cls=lambda x, y, z: x, headers=_headers, params=_params, @@ -2915,7 +3288,7 @@ def begin_mongo_db_container_retrieve_throughput_distribution( # pylint: disabl kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("PhysicalPartitionThroughputInfoResult", pipeline_response.http_response) + deserialized = self._deserialize("ThroughputSettingsGetResults", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized @@ -2929,13 +3302,13 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller[_models.PhysicalPartitionThroughputInfoResult].from_continuation_token( + return LROPoller[_models.ThroughputSettingsGetResults].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller[_models.PhysicalPartitionThroughputInfoResult]( + return LROPoller[_models.ThroughputSettingsGetResults]( self._client, raw_result, get_long_running_output, polling_method # type: ignore ) @@ -3004,10 +3377,11 @@ def _mongo_db_container_redistribute_throughput_initial( # pylint: disable=name response_headers = {} if response.status_code == 202: - response_headers["azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("azure-AsyncOperation") + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") ) - response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) @@ -3172,30 +3546,15 @@ def get_long_running_output(pipeline_response): self._client, raw_result, get_long_running_output, polling_method # type: ignore ) - @distributed_trace - def list_mongo_db_collections( - self, resource_group_name: str, account_name: str, database_name: str, **kwargs: Any - ) -> ItemPaged["_models.MongoDBCollectionGetResults"]: - """Lists the MongoDB collection under an existing Azure Cosmos DB database account. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param account_name: Cosmos DB database account name. Required. - :type account_name: str - :param database_name: Cosmos DB database name. Required. - :type database_name: str - :return: An iterator like instance of either MongoDBCollectionGetResults or the result of - cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cosmosdb.models.MongoDBCollectionGetResults] - :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.MongoDBCollectionListResult] = kwargs.pop("cls", None) - + def _mongo_db_container_retrieve_throughput_distribution_initial( # pylint: disable=name-too-long + self, + resource_group_name: str, + account_name: str, + database_name: str, + collection_name: str, + retrieve_throughput_parameters: Union[_models.RetrieveThroughputParameters, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -3204,143 +3563,8 @@ def list_mongo_db_collections( } error_map.update(kwargs.pop("error_map", {}) or {}) - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_mongo_db_collections_request( - resource_group_name=resource_group_name, - account_name=account_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) - - 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("MongoDBCollectionListResult", 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def get_mongo_db_collection( - self, resource_group_name: str, account_name: str, database_name: str, collection_name: str, **kwargs: Any - ) -> _models.MongoDBCollectionGetResults: - """Gets the MongoDB collection under an existing Azure Cosmos DB database account. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param account_name: Cosmos DB database account name. Required. - :type account_name: str - :param database_name: Cosmos DB database name. Required. - :type database_name: str - :param collection_name: Cosmos DB collection name. Required. - :type collection_name: str - :return: MongoDBCollectionGetResults or the result of cls(response) - :rtype: ~azure.mgmt.cosmosdb.models.MongoDBCollectionGetResults - :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.MongoDBCollectionGetResults] = kwargs.pop("cls", None) - - _request = build_get_mongo_db_collection_request( - resource_group_name=resource_group_name, - account_name=account_name, - database_name=database_name, - collection_name=collection_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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("MongoDBCollectionGetResults", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - def _create_update_mongo_db_collection_initial( # pylint: disable=name-too-long - self, - resource_group_name: str, - account_name: str, - database_name: str, - collection_name: str, - create_update_mongo_db_collection_parameters: Union[_models.MongoDBCollectionCreateUpdateParameters, 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 {}) + _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)) @@ -3349,14 +3573,12 @@ def _create_update_mongo_db_collection_initial( # pylint: disable=name-too-long content_type = content_type or "application/json" _json = None _content = None - if isinstance(create_update_mongo_db_collection_parameters, (IOBase, bytes)): - _content = create_update_mongo_db_collection_parameters + if isinstance(retrieve_throughput_parameters, (IOBase, bytes)): + _content = retrieve_throughput_parameters else: - _json = self._serialize.body( - create_update_mongo_db_collection_parameters, "MongoDBCollectionCreateUpdateParameters" - ) + _json = self._serialize.body(retrieve_throughput_parameters, "RetrieveThroughputParameters") - _request = build_create_update_mongo_db_collection_request( + _request = build_mongo_db_container_retrieve_throughput_distribution_request( resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, @@ -3389,10 +3611,11 @@ def _create_update_mongo_db_collection_initial( # pylint: disable=name-too-long response_headers = {} if response.status_code == 202: - response_headers["azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("azure-AsyncOperation") + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") ) - response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) @@ -3402,18 +3625,18 @@ def _create_update_mongo_db_collection_initial( # pylint: disable=name-too-long return deserialized # type: ignore @overload - def begin_create_update_mongo_db_collection( + def begin_mongo_db_container_retrieve_throughput_distribution( # pylint: disable=name-too-long self, resource_group_name: str, account_name: str, database_name: str, collection_name: str, - create_update_mongo_db_collection_parameters: _models.MongoDBCollectionCreateUpdateParameters, + retrieve_throughput_parameters: _models.RetrieveThroughputParameters, *, content_type: str = "application/json", **kwargs: Any - ) -> LROPoller[_models.MongoDBCollectionGetResults]: - """Create or update an Azure Cosmos DB MongoDB Collection. + ) -> LROPoller[_models.PhysicalPartitionThroughputInfoResult]: + """Retrieve throughput distribution for an Azure Cosmos DB MongoDB container. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -3424,32 +3647,32 @@ def begin_create_update_mongo_db_collection( :type database_name: str :param collection_name: Cosmos DB collection name. Required. :type collection_name: str - :param create_update_mongo_db_collection_parameters: The parameters to provide for the current - MongoDB Collection. Required. - :type create_update_mongo_db_collection_parameters: - ~azure.mgmt.cosmosdb.models.MongoDBCollectionCreateUpdateParameters + :param retrieve_throughput_parameters: The parameters to provide for retrieving throughput + distribution for the current MongoDB container. Required. + :type retrieve_throughput_parameters: ~azure.mgmt.cosmosdb.models.RetrieveThroughputParameters :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 MongoDBCollectionGetResults or the result - of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.MongoDBCollectionGetResults] + :return: An instance of LROPoller that returns either PhysicalPartitionThroughputInfoResult or + the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.PhysicalPartitionThroughputInfoResult] :raises ~azure.core.exceptions.HttpResponseError: """ @overload - def begin_create_update_mongo_db_collection( + def begin_mongo_db_container_retrieve_throughput_distribution( # pylint: disable=name-too-long self, resource_group_name: str, account_name: str, database_name: str, collection_name: str, - create_update_mongo_db_collection_parameters: IO[bytes], + retrieve_throughput_parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> LROPoller[_models.MongoDBCollectionGetResults]: - """Create or update an Azure Cosmos DB MongoDB Collection. + ) -> LROPoller[_models.PhysicalPartitionThroughputInfoResult]: + """Retrieve throughput distribution for an Azure Cosmos DB MongoDB container. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -3460,29 +3683,30 @@ def begin_create_update_mongo_db_collection( :type database_name: str :param collection_name: Cosmos DB collection name. Required. :type collection_name: str - :param create_update_mongo_db_collection_parameters: The parameters to provide for the current - MongoDB Collection. Required. - :type create_update_mongo_db_collection_parameters: IO[bytes] + :param retrieve_throughput_parameters: The parameters to provide for retrieving throughput + distribution for the current MongoDB container. Required. + :type retrieve_throughput_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 MongoDBCollectionGetResults or the result - of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.MongoDBCollectionGetResults] + :return: An instance of LROPoller that returns either PhysicalPartitionThroughputInfoResult or + the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.PhysicalPartitionThroughputInfoResult] :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace - def begin_create_update_mongo_db_collection( + def begin_mongo_db_container_retrieve_throughput_distribution( # pylint: disable=name-too-long self, resource_group_name: str, account_name: str, database_name: str, collection_name: str, - create_update_mongo_db_collection_parameters: Union[_models.MongoDBCollectionCreateUpdateParameters, IO[bytes]], + retrieve_throughput_parameters: Union[_models.RetrieveThroughputParameters, IO[bytes]], **kwargs: Any - ) -> LROPoller[_models.MongoDBCollectionGetResults]: - """Create or update an Azure Cosmos DB MongoDB Collection. + ) -> LROPoller[_models.PhysicalPartitionThroughputInfoResult]: + """Retrieve throughput distribution for an Azure Cosmos DB MongoDB container. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -3493,14 +3717,15 @@ def begin_create_update_mongo_db_collection( :type database_name: str :param collection_name: Cosmos DB collection name. Required. :type collection_name: str - :param create_update_mongo_db_collection_parameters: The parameters to provide for the current - MongoDB Collection. Is either a MongoDBCollectionCreateUpdateParameters type or a IO[bytes] - type. Required. - :type create_update_mongo_db_collection_parameters: - ~azure.mgmt.cosmosdb.models.MongoDBCollectionCreateUpdateParameters or IO[bytes] - :return: An instance of LROPoller that returns either MongoDBCollectionGetResults or the result - of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.MongoDBCollectionGetResults] + :param retrieve_throughput_parameters: The parameters to provide for retrieving throughput + distribution for the current MongoDB container. Is either a RetrieveThroughputParameters type + or a IO[bytes] type. Required. + :type retrieve_throughput_parameters: ~azure.mgmt.cosmosdb.models.RetrieveThroughputParameters + or IO[bytes] + :return: An instance of LROPoller that returns either PhysicalPartitionThroughputInfoResult or + the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.PhysicalPartitionThroughputInfoResult] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -3508,17 +3733,17 @@ def begin_create_update_mongo_db_collection( 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.MongoDBCollectionGetResults] = kwargs.pop("cls", None) + cls: ClsType[_models.PhysicalPartitionThroughputInfoResult] = 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_update_mongo_db_collection_initial( + raw_result = self._mongo_db_container_retrieve_throughput_distribution_initial( resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, collection_name=collection_name, - create_update_mongo_db_collection_parameters=create_update_mongo_db_collection_parameters, + retrieve_throughput_parameters=retrieve_throughput_parameters, api_version=api_version, content_type=content_type, cls=lambda x, y, z: x, @@ -3530,30 +3755,37 @@ def begin_create_update_mongo_db_collection( kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("MongoDBCollectionGetResults", pipeline_response.http_response) + deserialized = self._deserialize("PhysicalPartitionThroughputInfoResult", 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, **kwargs)) + 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.MongoDBCollectionGetResults].from_continuation_token( + return LROPoller[_models.PhysicalPartitionThroughputInfoResult].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller[_models.MongoDBCollectionGetResults]( + return LROPoller[_models.PhysicalPartitionThroughputInfoResult]( self._client, raw_result, get_long_running_output, polling_method # type: ignore ) - def _delete_mongo_db_collection_initial( - self, resource_group_name: str, account_name: str, database_name: str, collection_name: str, **kwargs: Any + def _mongo_db_database_partition_merge_initial( # pylint: disable=name-too-long + self, + resource_group_name: str, + account_name: str, + database_name: str, + merge_parameters: Union[_models.MergeParameters, IO[bytes]], + **kwargs: Any ) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -3563,19 +3795,30 @@ def _delete_mongo_db_collection_initial( } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) 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) - _request = build_delete_mongo_db_collection_request( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(merge_parameters, (IOBase, bytes)): + _content = merge_parameters + else: + _json = self._serialize.body(merge_parameters, "MergeParameters") + + _request = build_mongo_db_database_partition_merge_request( resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, - collection_name=collection_name, subscription_id=self._config.subscription_id, api_version=api_version, + content_type=content_type, + json=_json, + content=_content, headers=_headers, params=_params, ) @@ -3589,7 +3832,7 @@ def _delete_mongo_db_collection_initial( response = pipeline_response.http_response - if response.status_code not in [202, 204]: + if response.status_code not in [200, 202]: try: response.read() # Load the body in memory and close the socket except (StreamConsumedError, StreamClosedError): @@ -3599,146 +3842,11 @@ def _delete_mongo_db_collection_initial( response_headers = {} if response.status_code == 202: - response_headers["azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("azure-AsyncOperation") + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") ) - response_headers["location"] = self._deserialize("str", response.headers.get("location")) - - 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_mongo_db_collection( - self, resource_group_name: str, account_name: str, database_name: str, collection_name: str, **kwargs: Any - ) -> LROPoller[None]: - """Deletes an existing Azure Cosmos DB MongoDB Collection. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param account_name: Cosmos DB database account name. Required. - :type account_name: str - :param database_name: Cosmos DB database name. Required. - :type database_name: str - :param collection_name: Cosmos DB collection name. Required. - :type collection_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_mongo_db_collection_initial( - resource_group_name=resource_group_name, - account_name=account_name, - database_name=database_name, - collection_name=collection_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, **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 _mongo_db_database_partition_merge_initial( # pylint: disable=name-too-long - self, - resource_group_name: str, - account_name: str, - database_name: str, - merge_parameters: Union[_models.MergeParameters, 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(merge_parameters, (IOBase, bytes)): - _content = merge_parameters - else: - _json = self._serialize.body(merge_parameters, "MergeParameters") - - _request = build_mongo_db_database_partition_merge_request( - resource_group_name=resource_group_name, - account_name=account_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) - raise HttpResponseError(response=response, 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["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) @@ -3888,13 +3996,77 @@ def get_long_running_output(pipeline_response): self._client, raw_result, get_long_running_output, polling_method # type: ignore ) - def _list_mongo_db_collection_partition_merge_initial( # pylint: disable=name-too-long + @distributed_trace + def get_mongo_db_database_throughput( + self, resource_group_name: str, account_name: str, database_name: str, **kwargs: Any + ) -> _models.ThroughputSettingsGetResults: + """Gets the RUs per second of the MongoDB database under an existing Azure Cosmos DB database + account with the provided name. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param database_name: Cosmos DB database name. Required. + :type database_name: str + :return: ThroughputSettingsGetResults or the result of cls(response) + :rtype: ~azure.mgmt.cosmosdb.models.ThroughputSettingsGetResults + :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.ThroughputSettingsGetResults] = kwargs.pop("cls", None) + + _request = build_get_mongo_db_database_throughput_request( + resource_group_name=resource_group_name, + account_name=account_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("ThroughputSettingsGetResults", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + def _update_mongo_db_database_throughput_initial( # pylint: disable=name-too-long self, resource_group_name: str, account_name: str, database_name: str, - collection_name: str, - merge_parameters: Union[_models.MergeParameters, IO[bytes]], + update_throughput_parameters: Union[_models.ThroughputSettingsUpdateParameters, IO[bytes]], **kwargs: Any ) -> Iterator[bytes]: error_map: MutableMapping = { @@ -3915,16 +4087,15 @@ def _list_mongo_db_collection_partition_merge_initial( # pylint: disable=name-t content_type = content_type or "application/json" _json = None _content = None - if isinstance(merge_parameters, (IOBase, bytes)): - _content = merge_parameters + if isinstance(update_throughput_parameters, (IOBase, bytes)): + _content = update_throughput_parameters else: - _json = self._serialize.body(merge_parameters, "MergeParameters") + _json = self._serialize.body(update_throughput_parameters, "ThroughputSettingsUpdateParameters") - _request = build_list_mongo_db_collection_partition_merge_request( + _request = build_update_mongo_db_database_throughput_request( resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, - collection_name=collection_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, @@ -3953,10 +4124,11 @@ def _list_mongo_db_collection_partition_merge_initial( # pylint: disable=name-t response_headers = {} if response.status_code == 202: - response_headers["azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("azure-AsyncOperation") + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") ) - response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) @@ -3966,18 +4138,17 @@ def _list_mongo_db_collection_partition_merge_initial( # pylint: disable=name-t return deserialized # type: ignore @overload - def begin_list_mongo_db_collection_partition_merge( # pylint: disable=name-too-long + def begin_update_mongo_db_database_throughput( # pylint: disable=name-too-long self, resource_group_name: str, account_name: str, database_name: str, - collection_name: str, - merge_parameters: _models.MergeParameters, + update_throughput_parameters: _models.ThroughputSettingsUpdateParameters, *, content_type: str = "application/json", **kwargs: Any - ) -> LROPoller[_models.PhysicalPartitionStorageInfoCollection]: - """Merges the partitions of a MongoDB Collection. + ) -> LROPoller[_models.ThroughputSettingsGetResults]: + """Update RUs per second of the an Azure Cosmos DB MongoDB database. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -3986,33 +4157,31 @@ def begin_list_mongo_db_collection_partition_merge( # pylint: disable=name-too- :type account_name: str :param database_name: Cosmos DB database name. Required. :type database_name: str - :param collection_name: Cosmos DB collection name. Required. - :type collection_name: str - :param merge_parameters: The parameters for the merge operation. Required. - :type merge_parameters: ~azure.mgmt.cosmosdb.models.MergeParameters + :param update_throughput_parameters: The RUs per second of the parameters to provide for the + current MongoDB database. Required. + :type update_throughput_parameters: + ~azure.mgmt.cosmosdb.models.ThroughputSettingsUpdateParameters :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 PhysicalPartitionStorageInfoCollection or - the result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.PhysicalPartitionStorageInfoCollection] + :return: An instance of LROPoller that returns either ThroughputSettingsGetResults or the + result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.ThroughputSettingsGetResults] :raises ~azure.core.exceptions.HttpResponseError: """ @overload - def begin_list_mongo_db_collection_partition_merge( # pylint: disable=name-too-long + def begin_update_mongo_db_database_throughput( # pylint: disable=name-too-long self, resource_group_name: str, account_name: str, database_name: str, - collection_name: str, - merge_parameters: IO[bytes], + update_throughput_parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> LROPoller[_models.PhysicalPartitionStorageInfoCollection]: - """Merges the partitions of a MongoDB Collection. + ) -> LROPoller[_models.ThroughputSettingsGetResults]: + """Update RUs per second of the an Azure Cosmos DB MongoDB database. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -4021,31 +4190,28 @@ def begin_list_mongo_db_collection_partition_merge( # pylint: disable=name-too- :type account_name: str :param database_name: Cosmos DB database name. Required. :type database_name: str - :param collection_name: Cosmos DB collection name. Required. - :type collection_name: str - :param merge_parameters: The parameters for the merge operation. Required. - :type merge_parameters: IO[bytes] + :param update_throughput_parameters: The RUs per second of the parameters to provide for the + current MongoDB database. Required. + :type update_throughput_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 PhysicalPartitionStorageInfoCollection or - the result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.PhysicalPartitionStorageInfoCollection] + :return: An instance of LROPoller that returns either ThroughputSettingsGetResults or the + result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.ThroughputSettingsGetResults] :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace - def begin_list_mongo_db_collection_partition_merge( # pylint: disable=name-too-long + def begin_update_mongo_db_database_throughput( # pylint: disable=name-too-long self, resource_group_name: str, account_name: str, database_name: str, - collection_name: str, - merge_parameters: Union[_models.MergeParameters, IO[bytes]], + update_throughput_parameters: Union[_models.ThroughputSettingsUpdateParameters, IO[bytes]], **kwargs: Any - ) -> LROPoller[_models.PhysicalPartitionStorageInfoCollection]: - """Merges the partitions of a MongoDB Collection. + ) -> LROPoller[_models.ThroughputSettingsGetResults]: + """Update RUs per second of the an Azure Cosmos DB MongoDB database. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -4054,15 +4220,14 @@ def begin_list_mongo_db_collection_partition_merge( # pylint: disable=name-too- :type account_name: str :param database_name: Cosmos DB database name. Required. :type database_name: str - :param collection_name: Cosmos DB collection name. Required. - :type collection_name: str - :param merge_parameters: The parameters for the merge operation. Is either a MergeParameters - type or a IO[bytes] type. Required. - :type merge_parameters: ~azure.mgmt.cosmosdb.models.MergeParameters or IO[bytes] - :return: An instance of LROPoller that returns either PhysicalPartitionStorageInfoCollection or - the result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.PhysicalPartitionStorageInfoCollection] + :param update_throughput_parameters: The RUs per second of the parameters to provide for the + current MongoDB database. Is either a ThroughputSettingsUpdateParameters type or a IO[bytes] + type. Required. + :type update_throughput_parameters: + ~azure.mgmt.cosmosdb.models.ThroughputSettingsUpdateParameters or IO[bytes] + :return: An instance of LROPoller that returns either ThroughputSettingsGetResults or the + result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.ThroughputSettingsGetResults] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -4070,17 +4235,16 @@ def begin_list_mongo_db_collection_partition_merge( # pylint: disable=name-too- 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.PhysicalPartitionStorageInfoCollection] = kwargs.pop("cls", None) + cls: ClsType[_models.ThroughputSettingsGetResults] = 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._list_mongo_db_collection_partition_merge_initial( + raw_result = self._update_mongo_db_database_throughput_initial( resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, - collection_name=collection_name, - merge_parameters=merge_parameters, + update_throughput_parameters=update_throughput_parameters, api_version=api_version, content_type=content_type, cls=lambda x, y, z: x, @@ -4092,7 +4256,7 @@ def begin_list_mongo_db_collection_partition_merge( # pylint: disable=name-too- kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("PhysicalPartitionStorageInfoCollection", pipeline_response.http_response) + deserialized = self._deserialize("ThroughputSettingsGetResults", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized @@ -4106,88 +4270,18 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller[_models.PhysicalPartitionStorageInfoCollection].from_continuation_token( + return LROPoller[_models.ThroughputSettingsGetResults].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller[_models.PhysicalPartitionStorageInfoCollection]( + return LROPoller[_models.ThroughputSettingsGetResults]( self._client, raw_result, get_long_running_output, polling_method # type: ignore ) - @distributed_trace - def get_mongo_db_collection_throughput( - self, resource_group_name: str, account_name: str, database_name: str, collection_name: str, **kwargs: Any - ) -> _models.ThroughputSettingsGetResults: - """Gets the RUs per second of the MongoDB collection under an existing Azure Cosmos DB database - account with the provided name. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param account_name: Cosmos DB database account name. Required. - :type account_name: str - :param database_name: Cosmos DB database name. Required. - :type database_name: str - :param collection_name: Cosmos DB collection name. Required. - :type collection_name: str - :return: ThroughputSettingsGetResults or the result of cls(response) - :rtype: ~azure.mgmt.cosmosdb.models.ThroughputSettingsGetResults - :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.ThroughputSettingsGetResults] = kwargs.pop("cls", None) - - _request = build_get_mongo_db_collection_throughput_request( - resource_group_name=resource_group_name, - account_name=account_name, - database_name=database_name, - collection_name=collection_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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("ThroughputSettingsGetResults", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - def _update_mongo_db_collection_throughput_initial( # pylint: disable=name-too-long - self, - resource_group_name: str, - account_name: str, - database_name: str, - collection_name: str, - update_throughput_parameters: Union[_models.ThroughputSettingsUpdateParameters, IO[bytes]], - **kwargs: Any + def _migrate_mongo_db_database_to_autoscale_initial( # pylint: disable=name-too-long + self, resource_group_name: str, account_name: str, database_name: str, **kwargs: Any ) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -4197,31 +4291,18 @@ def _update_mongo_db_collection_throughput_initial( # pylint: disable=name-too- } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = case_insensitive_dict(kwargs.pop("headers", {}) 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)) - 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(update_throughput_parameters, (IOBase, bytes)): - _content = update_throughput_parameters - else: - _json = self._serialize.body(update_throughput_parameters, "ThroughputSettingsUpdateParameters") - - _request = build_update_mongo_db_collection_throughput_request( + _request = build_migrate_mongo_db_database_to_autoscale_request( resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, - collection_name=collection_name, subscription_id=self._config.subscription_id, api_version=api_version, - content_type=content_type, - json=_json, - content=_content, headers=_headers, params=_params, ) @@ -4245,10 +4326,11 @@ def _update_mongo_db_collection_throughput_initial( # pylint: disable=name-too- response_headers = {} if response.status_code == 202: - response_headers["azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("azure-AsyncOperation") + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") ) - response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) @@ -4257,88 +4339,11 @@ def _update_mongo_db_collection_throughput_initial( # pylint: disable=name-too- return deserialized # type: ignore - @overload - def begin_update_mongo_db_collection_throughput( # pylint: disable=name-too-long - self, - resource_group_name: str, - account_name: str, - database_name: str, - collection_name: str, - update_throughput_parameters: _models.ThroughputSettingsUpdateParameters, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.ThroughputSettingsGetResults]: - """Update the RUs per second of an Azure Cosmos DB MongoDB collection. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param account_name: Cosmos DB database account name. Required. - :type account_name: str - :param database_name: Cosmos DB database name. Required. - :type database_name: str - :param collection_name: Cosmos DB collection name. Required. - :type collection_name: str - :param update_throughput_parameters: The RUs per second of the parameters to provide for the - current MongoDB collection. Required. - :type update_throughput_parameters: - ~azure.mgmt.cosmosdb.models.ThroughputSettingsUpdateParameters - :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 ThroughputSettingsGetResults or the - result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.ThroughputSettingsGetResults] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_update_mongo_db_collection_throughput( # pylint: disable=name-too-long - self, - resource_group_name: str, - account_name: str, - database_name: str, - collection_name: str, - update_throughput_parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.ThroughputSettingsGetResults]: - """Update the RUs per second of an Azure Cosmos DB MongoDB collection. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param account_name: Cosmos DB database account name. Required. - :type account_name: str - :param database_name: Cosmos DB database name. Required. - :type database_name: str - :param collection_name: Cosmos DB collection name. Required. - :type collection_name: str - :param update_throughput_parameters: The RUs per second of the parameters to provide for the - current MongoDB collection. Required. - :type update_throughput_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 ThroughputSettingsGetResults or the - result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.ThroughputSettingsGetResults] - :raises ~azure.core.exceptions.HttpResponseError: - """ - @distributed_trace - def begin_update_mongo_db_collection_throughput( # pylint: disable=name-too-long - self, - resource_group_name: str, - account_name: str, - database_name: str, - collection_name: str, - update_throughput_parameters: Union[_models.ThroughputSettingsUpdateParameters, IO[bytes]], - **kwargs: Any + def begin_migrate_mongo_db_database_to_autoscale( # pylint: disable=name-too-long + self, resource_group_name: str, account_name: str, database_name: str, **kwargs: Any ) -> LROPoller[_models.ThroughputSettingsGetResults]: - """Update the RUs per second of an Azure Cosmos DB MongoDB collection. + """Migrate an Azure Cosmos DB MongoDB database from manual throughput to autoscale. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -4347,36 +4352,25 @@ def begin_update_mongo_db_collection_throughput( # pylint: disable=name-too-lon :type account_name: str :param database_name: Cosmos DB database name. Required. :type database_name: str - :param collection_name: Cosmos DB collection name. Required. - :type collection_name: str - :param update_throughput_parameters: The RUs per second of the parameters to provide for the - current MongoDB collection. Is either a ThroughputSettingsUpdateParameters type or a IO[bytes] - type. Required. - :type update_throughput_parameters: - ~azure.mgmt.cosmosdb.models.ThroughputSettingsUpdateParameters or IO[bytes] :return: An instance of LROPoller that returns either ThroughputSettingsGetResults or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.ThroughputSettingsGetResults] :raises ~azure.core.exceptions.HttpResponseError: """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) 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)) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.ThroughputSettingsGetResults] = 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_mongo_db_collection_throughput_initial( + raw_result = self._migrate_mongo_db_database_to_autoscale_initial( resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, - collection_name=collection_name, - update_throughput_parameters=update_throughput_parameters, api_version=api_version, - content_type=content_type, cls=lambda x, y, z: x, headers=_headers, params=_params, @@ -4392,7 +4386,9 @@ def get_long_running_output(pipeline_response): return deserialized if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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: @@ -4408,8 +4404,8 @@ def get_long_running_output(pipeline_response): self._client, raw_result, get_long_running_output, polling_method # type: ignore ) - def _migrate_mongo_db_collection_to_autoscale_initial( # pylint: disable=name-too-long - self, resource_group_name: str, account_name: str, database_name: str, collection_name: str, **kwargs: Any + def _migrate_mongo_db_database_to_manual_throughput_initial( # pylint: disable=name-too-long + self, resource_group_name: str, account_name: str, database_name: str, **kwargs: Any ) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -4425,11 +4421,10 @@ def _migrate_mongo_db_collection_to_autoscale_initial( # pylint: disable=name-t 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_migrate_mongo_db_collection_to_autoscale_request( + _request = build_migrate_mongo_db_database_to_manual_throughput_request( resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, - collection_name=collection_name, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, @@ -4455,10 +4450,11 @@ def _migrate_mongo_db_collection_to_autoscale_initial( # pylint: disable=name-t response_headers = {} if response.status_code == 202: - response_headers["azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("azure-AsyncOperation") + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") ) - response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) @@ -4468,10 +4464,10 @@ def _migrate_mongo_db_collection_to_autoscale_initial( # pylint: disable=name-t return deserialized # type: ignore @distributed_trace - def begin_migrate_mongo_db_collection_to_autoscale( # pylint: disable=name-too-long - self, resource_group_name: str, account_name: str, database_name: str, collection_name: str, **kwargs: Any + def begin_migrate_mongo_db_database_to_manual_throughput( # pylint: disable=name-too-long + self, resource_group_name: str, account_name: str, database_name: str, **kwargs: Any ) -> LROPoller[_models.ThroughputSettingsGetResults]: - """Migrate an Azure Cosmos DB MongoDB collection from manual throughput to autoscale. + """Migrate an Azure Cosmos DB MongoDB database from autoscale to manual throughput. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -4480,8 +4476,6 @@ def begin_migrate_mongo_db_collection_to_autoscale( # pylint: disable=name-too- :type account_name: str :param database_name: Cosmos DB database name. Required. :type database_name: str - :param collection_name: Cosmos DB collection name. Required. - :type collection_name: str :return: An instance of LROPoller that returns either ThroughputSettingsGetResults or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.ThroughputSettingsGetResults] @@ -4496,11 +4490,10 @@ def begin_migrate_mongo_db_collection_to_autoscale( # pylint: disable=name-too- 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_mongo_db_collection_to_autoscale_initial( + raw_result = self._migrate_mongo_db_database_to_manual_throughput_initial( resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, - collection_name=collection_name, api_version=api_version, cls=lambda x, y, z: x, headers=_headers, @@ -4517,7 +4510,9 @@ def get_long_running_output(pipeline_response): return deserialized if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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: @@ -4533,8 +4528,13 @@ def get_long_running_output(pipeline_response): self._client, raw_result, get_long_running_output, polling_method # type: ignore ) - def _migrate_mongo_db_collection_to_manual_throughput_initial( # pylint: disable=name-too-long - self, resource_group_name: str, account_name: str, database_name: str, collection_name: str, **kwargs: Any + def _mongo_db_database_redistribute_throughput_initial( # pylint: disable=name-too-long + self, + resource_group_name: str, + account_name: str, + database_name: str, + redistribute_throughput_parameters: Union[_models.RedistributeThroughputParameters, IO[bytes]], + **kwargs: Any ) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -4544,19 +4544,30 @@ def _migrate_mongo_db_collection_to_manual_throughput_initial( # pylint: disabl } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) 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) - _request = build_migrate_mongo_db_collection_to_manual_throughput_request( - resource_group_name=resource_group_name, - account_name=account_name, - database_name=database_name, - collection_name=collection_name, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(redistribute_throughput_parameters, (IOBase, bytes)): + _content = redistribute_throughput_parameters + else: + _json = self._serialize.body(redistribute_throughput_parameters, "RedistributeThroughputParameters") + + _request = build_mongo_db_database_redistribute_throughput_request( + resource_group_name=resource_group_name, + account_name=account_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, ) @@ -4580,10 +4591,11 @@ def _migrate_mongo_db_collection_to_manual_throughput_initial( # pylint: disabl response_headers = {} if response.status_code == 202: - response_headers["azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("azure-AsyncOperation") + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") ) - response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) @@ -4592,11 +4604,83 @@ def _migrate_mongo_db_collection_to_manual_throughput_initial( # pylint: disabl return deserialized # type: ignore + @overload + def begin_mongo_db_database_redistribute_throughput( # pylint: disable=name-too-long + self, + resource_group_name: str, + account_name: str, + database_name: str, + redistribute_throughput_parameters: _models.RedistributeThroughputParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.PhysicalPartitionThroughputInfoResult]: + """Redistribute throughput for an Azure Cosmos DB MongoDB database. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param database_name: Cosmos DB database name. Required. + :type database_name: str + :param redistribute_throughput_parameters: The parameters to provide for redistributing + throughput for the current MongoDB database. Required. + :type redistribute_throughput_parameters: + ~azure.mgmt.cosmosdb.models.RedistributeThroughputParameters + :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 PhysicalPartitionThroughputInfoResult or + the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.PhysicalPartitionThroughputInfoResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_mongo_db_database_redistribute_throughput( # pylint: disable=name-too-long + self, + resource_group_name: str, + account_name: str, + database_name: str, + redistribute_throughput_parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.PhysicalPartitionThroughputInfoResult]: + """Redistribute throughput for an Azure Cosmos DB MongoDB database. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param database_name: Cosmos DB database name. Required. + :type database_name: str + :param redistribute_throughput_parameters: The parameters to provide for redistributing + throughput for the current MongoDB database. Required. + :type redistribute_throughput_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 PhysicalPartitionThroughputInfoResult or + the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.PhysicalPartitionThroughputInfoResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + @distributed_trace - def begin_migrate_mongo_db_collection_to_manual_throughput( # pylint: disable=name-too-long - self, resource_group_name: str, account_name: str, database_name: str, collection_name: str, **kwargs: Any - ) -> LROPoller[_models.ThroughputSettingsGetResults]: - """Migrate an Azure Cosmos DB MongoDB collection from autoscale to manual throughput. + def begin_mongo_db_database_redistribute_throughput( # pylint: disable=name-too-long + self, + resource_group_name: str, + account_name: str, + database_name: str, + redistribute_throughput_parameters: Union[_models.RedistributeThroughputParameters, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.PhysicalPartitionThroughputInfoResult]: + """Redistribute throughput for an Azure Cosmos DB MongoDB database. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -4605,28 +4689,34 @@ def begin_migrate_mongo_db_collection_to_manual_throughput( # pylint: disable=n :type account_name: str :param database_name: Cosmos DB database name. Required. :type database_name: str - :param collection_name: Cosmos DB collection name. Required. - :type collection_name: str - :return: An instance of LROPoller that returns either ThroughputSettingsGetResults or the - result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.ThroughputSettingsGetResults] + :param redistribute_throughput_parameters: The parameters to provide for redistributing + throughput for the current MongoDB database. Is either a RedistributeThroughputParameters type + or a IO[bytes] type. Required. + :type redistribute_throughput_parameters: + ~azure.mgmt.cosmosdb.models.RedistributeThroughputParameters or IO[bytes] + :return: An instance of LROPoller that returns either PhysicalPartitionThroughputInfoResult or + the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.PhysicalPartitionThroughputInfoResult] :raises ~azure.core.exceptions.HttpResponseError: """ - _headers = kwargs.pop("headers", {}) 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)) - cls: ClsType[_models.ThroughputSettingsGetResults] = kwargs.pop("cls", None) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.PhysicalPartitionThroughputInfoResult] = 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_mongo_db_collection_to_manual_throughput_initial( + raw_result = self._mongo_db_database_redistribute_throughput_initial( resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, - collection_name=collection_name, + redistribute_throughput_parameters=redistribute_throughput_parameters, api_version=api_version, + content_type=content_type, cls=lambda x, y, z: x, headers=_headers, params=_params, @@ -4636,97 +4726,36 @@ def begin_migrate_mongo_db_collection_to_manual_throughput( # pylint: disable=n kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ThroughputSettingsGetResults", pipeline_response.http_response) + deserialized = self._deserialize("PhysicalPartitionThroughputInfoResult", 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, **kwargs)) + 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.ThroughputSettingsGetResults].from_continuation_token( + return LROPoller[_models.PhysicalPartitionThroughputInfoResult].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller[_models.ThroughputSettingsGetResults]( + return LROPoller[_models.PhysicalPartitionThroughputInfoResult]( self._client, raw_result, get_long_running_output, polling_method # type: ignore ) - @distributed_trace - def get_mongo_role_definition( - self, mongo_role_definition_id: str, resource_group_name: str, account_name: str, **kwargs: Any - ) -> _models.MongoRoleDefinitionGetResults: - """Retrieves the properties of an existing Azure Cosmos DB Mongo Role Definition with the given - Id. - - :param mongo_role_definition_id: The ID for the Role Definition {dbName.roleName}. Required. - :type mongo_role_definition_id: str - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param account_name: Cosmos DB database account name. Required. - :type account_name: str - :return: MongoRoleDefinitionGetResults or the result of cls(response) - :rtype: ~azure.mgmt.cosmosdb.models.MongoRoleDefinitionGetResults - :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.MongoRoleDefinitionGetResults] = kwargs.pop("cls", None) - - _request = build_get_mongo_role_definition_request( - mongo_role_definition_id=mongo_role_definition_id, - resource_group_name=resource_group_name, - account_name=account_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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("MongoRoleDefinitionGetResults", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - def _create_update_mongo_role_definition_initial( # pylint: disable=name-too-long + def _mongo_db_database_retrieve_throughput_distribution_initial( # pylint: disable=name-too-long self, - mongo_role_definition_id: str, resource_group_name: str, account_name: str, - create_update_mongo_role_definition_parameters: Union[ - _models.MongoRoleDefinitionCreateUpdateParameters, IO[bytes] - ], + database_name: str, + retrieve_throughput_parameters: Union[_models.RetrieveThroughputParameters, IO[bytes]], **kwargs: Any ) -> Iterator[bytes]: error_map: MutableMapping = { @@ -4747,17 +4776,15 @@ def _create_update_mongo_role_definition_initial( # pylint: disable=name-too-lo content_type = content_type or "application/json" _json = None _content = None - if isinstance(create_update_mongo_role_definition_parameters, (IOBase, bytes)): - _content = create_update_mongo_role_definition_parameters + if isinstance(retrieve_throughput_parameters, (IOBase, bytes)): + _content = retrieve_throughput_parameters else: - _json = self._serialize.body( - create_update_mongo_role_definition_parameters, "MongoRoleDefinitionCreateUpdateParameters" - ) + _json = self._serialize.body(retrieve_throughput_parameters, "RetrieveThroughputParameters") - _request = build_create_update_mongo_role_definition_request( - mongo_role_definition_id=mongo_role_definition_id, + _request = build_mongo_db_database_retrieve_throughput_distribution_request( resource_group_name=resource_group_name, account_name=account_name, + database_name=database_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, @@ -4784,109 +4811,114 @@ def _create_update_mongo_role_definition_initial( # pylint: disable=name-too-lo map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, 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.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @overload - def begin_create_update_mongo_role_definition( # pylint: disable=name-too-long + def begin_mongo_db_database_retrieve_throughput_distribution( # pylint: disable=name-too-long self, - mongo_role_definition_id: str, resource_group_name: str, account_name: str, - create_update_mongo_role_definition_parameters: _models.MongoRoleDefinitionCreateUpdateParameters, + database_name: str, + retrieve_throughput_parameters: _models.RetrieveThroughputParameters, *, content_type: str = "application/json", **kwargs: Any - ) -> LROPoller[_models.MongoRoleDefinitionGetResults]: - """Creates or updates an Azure Cosmos DB Mongo Role Definition. + ) -> LROPoller[_models.PhysicalPartitionThroughputInfoResult]: + """Retrieve throughput distribution for an Azure Cosmos DB MongoDB database. - :param mongo_role_definition_id: The ID for the Role Definition {dbName.roleName}. Required. - :type mongo_role_definition_id: str :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param create_update_mongo_role_definition_parameters: The properties required to create or - update a Role Definition. Required. - :type create_update_mongo_role_definition_parameters: - ~azure.mgmt.cosmosdb.models.MongoRoleDefinitionCreateUpdateParameters + :param database_name: Cosmos DB database name. Required. + :type database_name: str + :param retrieve_throughput_parameters: The parameters to provide for retrieving throughput + distribution for the current MongoDB database. Required. + :type retrieve_throughput_parameters: ~azure.mgmt.cosmosdb.models.RetrieveThroughputParameters :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 MongoRoleDefinitionGetResults or the - result of cls(response) + :return: An instance of LROPoller that returns either PhysicalPartitionThroughputInfoResult or + the result of cls(response) :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.MongoRoleDefinitionGetResults] + ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.PhysicalPartitionThroughputInfoResult] :raises ~azure.core.exceptions.HttpResponseError: """ @overload - def begin_create_update_mongo_role_definition( # pylint: disable=name-too-long + def begin_mongo_db_database_retrieve_throughput_distribution( # pylint: disable=name-too-long self, - mongo_role_definition_id: str, resource_group_name: str, account_name: str, - create_update_mongo_role_definition_parameters: IO[bytes], + database_name: str, + retrieve_throughput_parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> LROPoller[_models.MongoRoleDefinitionGetResults]: - """Creates or updates an Azure Cosmos DB Mongo Role Definition. + ) -> LROPoller[_models.PhysicalPartitionThroughputInfoResult]: + """Retrieve throughput distribution for an Azure Cosmos DB MongoDB database. - :param mongo_role_definition_id: The ID for the Role Definition {dbName.roleName}. Required. - :type mongo_role_definition_id: str :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param create_update_mongo_role_definition_parameters: The properties required to create or - update a Role Definition. Required. - :type create_update_mongo_role_definition_parameters: IO[bytes] + :param database_name: Cosmos DB database name. Required. + :type database_name: str + :param retrieve_throughput_parameters: The parameters to provide for retrieving throughput + distribution for the current MongoDB database. Required. + :type retrieve_throughput_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 MongoRoleDefinitionGetResults or the - result of cls(response) + :return: An instance of LROPoller that returns either PhysicalPartitionThroughputInfoResult or + the result of cls(response) :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.MongoRoleDefinitionGetResults] + ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.PhysicalPartitionThroughputInfoResult] :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace - def begin_create_update_mongo_role_definition( # pylint: disable=name-too-long + def begin_mongo_db_database_retrieve_throughput_distribution( # pylint: disable=name-too-long self, - mongo_role_definition_id: str, resource_group_name: str, account_name: str, - create_update_mongo_role_definition_parameters: Union[ - _models.MongoRoleDefinitionCreateUpdateParameters, IO[bytes] - ], + database_name: str, + retrieve_throughput_parameters: Union[_models.RetrieveThroughputParameters, IO[bytes]], **kwargs: Any - ) -> LROPoller[_models.MongoRoleDefinitionGetResults]: - """Creates or updates an Azure Cosmos DB Mongo Role Definition. + ) -> LROPoller[_models.PhysicalPartitionThroughputInfoResult]: + """Retrieve throughput distribution for an Azure Cosmos DB MongoDB database. - :param mongo_role_definition_id: The ID for the Role Definition {dbName.roleName}. Required. - :type mongo_role_definition_id: str :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param create_update_mongo_role_definition_parameters: The properties required to create or - update a Role Definition. Is either a MongoRoleDefinitionCreateUpdateParameters type or a - IO[bytes] type. Required. - :type create_update_mongo_role_definition_parameters: - ~azure.mgmt.cosmosdb.models.MongoRoleDefinitionCreateUpdateParameters or IO[bytes] - :return: An instance of LROPoller that returns either MongoRoleDefinitionGetResults or the - result of cls(response) + :param database_name: Cosmos DB database name. Required. + :type database_name: str + :param retrieve_throughput_parameters: The parameters to provide for retrieving throughput + distribution for the current MongoDB database. Is either a RetrieveThroughputParameters type or + a IO[bytes] type. Required. + :type retrieve_throughput_parameters: ~azure.mgmt.cosmosdb.models.RetrieveThroughputParameters + or IO[bytes] + :return: An instance of LROPoller that returns either PhysicalPartitionThroughputInfoResult or + the result of cls(response) :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.MongoRoleDefinitionGetResults] + ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.PhysicalPartitionThroughputInfoResult] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -4894,16 +4926,16 @@ def begin_create_update_mongo_role_definition( # pylint: disable=name-too-long 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.MongoRoleDefinitionGetResults] = kwargs.pop("cls", None) + cls: ClsType[_models.PhysicalPartitionThroughputInfoResult] = 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_update_mongo_role_definition_initial( - mongo_role_definition_id=mongo_role_definition_id, + raw_result = self._mongo_db_database_retrieve_throughput_distribution_initial( resource_group_name=resource_group_name, account_name=account_name, - create_update_mongo_role_definition_parameters=create_update_mongo_role_definition_parameters, + database_name=database_name, + retrieve_throughput_parameters=retrieve_throughput_parameters, api_version=api_version, content_type=content_type, cls=lambda x, y, z: x, @@ -4915,137 +4947,30 @@ def begin_create_update_mongo_role_definition( # pylint: disable=name-too-long kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("MongoRoleDefinitionGetResults", pipeline_response.http_response) + deserialized = self._deserialize("PhysicalPartitionThroughputInfoResult", 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, **kwargs)) + 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.MongoRoleDefinitionGetResults].from_continuation_token( + return LROPoller[_models.PhysicalPartitionThroughputInfoResult].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller[_models.MongoRoleDefinitionGetResults]( + return LROPoller[_models.PhysicalPartitionThroughputInfoResult]( self._client, raw_result, get_long_running_output, polling_method # type: ignore ) - def _delete_mongo_role_definition_initial( - self, mongo_role_definition_id: str, resource_group_name: str, account_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_mongo_role_definition_request( - mongo_role_definition_id=mongo_role_definition_id, - resource_group_name=resource_group_name, - account_name=account_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, 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def begin_delete_mongo_role_definition( - self, mongo_role_definition_id: str, resource_group_name: str, account_name: str, **kwargs: Any - ) -> LROPoller[None]: - """Deletes an existing Azure Cosmos DB Mongo Role Definition. - - :param mongo_role_definition_id: The ID for the Role Definition {dbName.roleName}. Required. - :type mongo_role_definition_id: str - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param account_name: Cosmos DB database account name. Required. - :type account_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_mongo_role_definition_initial( - mongo_role_definition_id=mongo_role_definition_id, - resource_group_name=resource_group_name, - account_name=account_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, **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_mongo_role_definitions( self, resource_group_name: str, account_name: str, **kwargs: Any @@ -5111,7 +5036,7 @@ def extract_data(pipeline_response): list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore - return None, iter(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): _request = prepare_request(next_link) @@ -5131,21 +5056,21 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) @distributed_trace - def get_mongo_user_definition( - self, mongo_user_definition_id: str, resource_group_name: str, account_name: str, **kwargs: Any - ) -> _models.MongoUserDefinitionGetResults: - """Retrieves the properties of an existing Azure Cosmos DB Mongo User Definition with the given + def get_mongo_role_definition( + self, resource_group_name: str, account_name: str, mongo_role_definition_id: str, **kwargs: Any + ) -> _models.MongoRoleDefinitionGetResults: + """Retrieves the properties of an existing Azure Cosmos DB Mongo Role Definition with the given Id. - :param mongo_user_definition_id: The ID for the User Definition {dbName.userName}. Required. - :type mongo_user_definition_id: str :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param account_name: Cosmos DB database account name. Required. :type account_name: str - :return: MongoUserDefinitionGetResults or the result of cls(response) - :rtype: ~azure.mgmt.cosmosdb.models.MongoUserDefinitionGetResults + :param mongo_role_definition_id: The ID for the Role Definition {dbName.roleName}. Required. + :type mongo_role_definition_id: str + :return: MongoRoleDefinitionGetResults or the result of cls(response) + :rtype: ~azure.mgmt.cosmosdb.models.MongoRoleDefinitionGetResults :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -5160,12 +5085,12 @@ def get_mongo_user_definition( _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.MongoUserDefinitionGetResults] = kwargs.pop("cls", None) + cls: ClsType[_models.MongoRoleDefinitionGetResults] = kwargs.pop("cls", None) - _request = build_get_mongo_user_definition_request( - mongo_user_definition_id=mongo_user_definition_id, + _request = build_get_mongo_role_definition_request( resource_group_name=resource_group_name, account_name=account_name, + mongo_role_definition_id=mongo_role_definition_id, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, @@ -5184,20 +5109,20 @@ def get_mongo_user_definition( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("MongoUserDefinitionGetResults", pipeline_response.http_response) + deserialized = self._deserialize("MongoRoleDefinitionGetResults", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - def _create_update_mongo_user_definition_initial( # pylint: disable=name-too-long + def _create_update_mongo_role_definition_initial( # pylint: disable=name-too-long self, - mongo_user_definition_id: str, resource_group_name: str, account_name: str, - create_update_mongo_user_definition_parameters: Union[ - _models.MongoUserDefinitionCreateUpdateParameters, IO[bytes] + mongo_role_definition_id: str, + create_update_mongo_role_definition_parameters: Union[ + _models.MongoRoleDefinitionCreateUpdateParameters, IO[bytes] ], **kwargs: Any ) -> Iterator[bytes]: @@ -5219,17 +5144,17 @@ def _create_update_mongo_user_definition_initial( # pylint: disable=name-too-lo content_type = content_type or "application/json" _json = None _content = None - if isinstance(create_update_mongo_user_definition_parameters, (IOBase, bytes)): - _content = create_update_mongo_user_definition_parameters + if isinstance(create_update_mongo_role_definition_parameters, (IOBase, bytes)): + _content = create_update_mongo_role_definition_parameters else: _json = self._serialize.body( - create_update_mongo_user_definition_parameters, "MongoUserDefinitionCreateUpdateParameters" + create_update_mongo_role_definition_parameters, "MongoRoleDefinitionCreateUpdateParameters" ) - _request = build_create_update_mongo_user_definition_request( - mongo_user_definition_id=mongo_user_definition_id, + _request = build_create_update_mongo_role_definition_request( resource_group_name=resource_group_name, account_name=account_name, + mongo_role_definition_id=mongo_role_definition_id, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, @@ -5256,109 +5181,114 @@ def _create_update_mongo_user_definition_initial( # pylint: disable=name-too-lo map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @overload - def begin_create_update_mongo_user_definition( # pylint: disable=name-too-long + def begin_create_update_mongo_role_definition( # pylint: disable=name-too-long self, - mongo_user_definition_id: str, resource_group_name: str, account_name: str, - create_update_mongo_user_definition_parameters: _models.MongoUserDefinitionCreateUpdateParameters, + mongo_role_definition_id: str, + create_update_mongo_role_definition_parameters: _models.MongoRoleDefinitionCreateUpdateParameters, *, content_type: str = "application/json", **kwargs: Any - ) -> LROPoller[_models.MongoUserDefinitionGetResults]: - """Creates or updates an Azure Cosmos DB Mongo User Definition. + ) -> LROPoller[_models.MongoRoleDefinitionGetResults]: + """Creates or updates an Azure Cosmos DB Mongo Role Definition. - :param mongo_user_definition_id: The ID for the User Definition {dbName.userName}. Required. - :type mongo_user_definition_id: str :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param create_update_mongo_user_definition_parameters: The properties required to create or - update a User Definition. Required. - :type create_update_mongo_user_definition_parameters: - ~azure.mgmt.cosmosdb.models.MongoUserDefinitionCreateUpdateParameters + :param mongo_role_definition_id: The ID for the Role Definition {dbName.roleName}. Required. + :type mongo_role_definition_id: str + :param create_update_mongo_role_definition_parameters: The properties required to create or + update a Role Definition. Required. + :type create_update_mongo_role_definition_parameters: + ~azure.mgmt.cosmosdb.models.MongoRoleDefinitionCreateUpdateParameters :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 MongoUserDefinitionGetResults or the + :return: An instance of LROPoller that returns either MongoRoleDefinitionGetResults or the result of cls(response) :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.MongoUserDefinitionGetResults] + ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.MongoRoleDefinitionGetResults] :raises ~azure.core.exceptions.HttpResponseError: """ @overload - def begin_create_update_mongo_user_definition( # pylint: disable=name-too-long + def begin_create_update_mongo_role_definition( # pylint: disable=name-too-long self, - mongo_user_definition_id: str, resource_group_name: str, account_name: str, - create_update_mongo_user_definition_parameters: IO[bytes], + mongo_role_definition_id: str, + create_update_mongo_role_definition_parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> LROPoller[_models.MongoUserDefinitionGetResults]: - """Creates or updates an Azure Cosmos DB Mongo User Definition. + ) -> LROPoller[_models.MongoRoleDefinitionGetResults]: + """Creates or updates an Azure Cosmos DB Mongo Role Definition. - :param mongo_user_definition_id: The ID for the User Definition {dbName.userName}. Required. - :type mongo_user_definition_id: str :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param create_update_mongo_user_definition_parameters: The properties required to create or - update a User Definition. Required. - :type create_update_mongo_user_definition_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 MongoUserDefinitionGetResults or the + :param mongo_role_definition_id: The ID for the Role Definition {dbName.roleName}. Required. + :type mongo_role_definition_id: str + :param create_update_mongo_role_definition_parameters: The properties required to create or + update a Role Definition. Required. + :type create_update_mongo_role_definition_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 MongoRoleDefinitionGetResults or the result of cls(response) :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.MongoUserDefinitionGetResults] + ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.MongoRoleDefinitionGetResults] :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace - def begin_create_update_mongo_user_definition( # pylint: disable=name-too-long + def begin_create_update_mongo_role_definition( # pylint: disable=name-too-long self, - mongo_user_definition_id: str, resource_group_name: str, account_name: str, - create_update_mongo_user_definition_parameters: Union[ - _models.MongoUserDefinitionCreateUpdateParameters, IO[bytes] + mongo_role_definition_id: str, + create_update_mongo_role_definition_parameters: Union[ + _models.MongoRoleDefinitionCreateUpdateParameters, IO[bytes] ], **kwargs: Any - ) -> LROPoller[_models.MongoUserDefinitionGetResults]: - """Creates or updates an Azure Cosmos DB Mongo User Definition. + ) -> LROPoller[_models.MongoRoleDefinitionGetResults]: + """Creates or updates an Azure Cosmos DB Mongo Role Definition. - :param mongo_user_definition_id: The ID for the User Definition {dbName.userName}. Required. - :type mongo_user_definition_id: str :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param create_update_mongo_user_definition_parameters: The properties required to create or - update a User Definition. Is either a MongoUserDefinitionCreateUpdateParameters type or a + :param mongo_role_definition_id: The ID for the Role Definition {dbName.roleName}. Required. + :type mongo_role_definition_id: str + :param create_update_mongo_role_definition_parameters: The properties required to create or + update a Role Definition. Is either a MongoRoleDefinitionCreateUpdateParameters type or a IO[bytes] type. Required. - :type create_update_mongo_user_definition_parameters: - ~azure.mgmt.cosmosdb.models.MongoUserDefinitionCreateUpdateParameters or IO[bytes] - :return: An instance of LROPoller that returns either MongoUserDefinitionGetResults or the + :type create_update_mongo_role_definition_parameters: + ~azure.mgmt.cosmosdb.models.MongoRoleDefinitionCreateUpdateParameters or IO[bytes] + :return: An instance of LROPoller that returns either MongoRoleDefinitionGetResults or the result of cls(response) :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.MongoUserDefinitionGetResults] + ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.MongoRoleDefinitionGetResults] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -5366,16 +5296,16 @@ def begin_create_update_mongo_user_definition( # pylint: disable=name-too-long 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.MongoUserDefinitionGetResults] = kwargs.pop("cls", None) + cls: ClsType[_models.MongoRoleDefinitionGetResults] = 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_update_mongo_user_definition_initial( - mongo_user_definition_id=mongo_user_definition_id, + raw_result = self._create_update_mongo_role_definition_initial( resource_group_name=resource_group_name, account_name=account_name, - create_update_mongo_user_definition_parameters=create_update_mongo_user_definition_parameters, + mongo_role_definition_id=mongo_role_definition_id, + create_update_mongo_role_definition_parameters=create_update_mongo_role_definition_parameters, api_version=api_version, content_type=content_type, cls=lambda x, y, z: x, @@ -5387,30 +5317,32 @@ def begin_create_update_mongo_user_definition( # pylint: disable=name-too-long kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("MongoUserDefinitionGetResults", pipeline_response.http_response) + deserialized = self._deserialize("MongoRoleDefinitionGetResults", 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, **kwargs)) + 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.MongoUserDefinitionGetResults].from_continuation_token( + return LROPoller[_models.MongoRoleDefinitionGetResults].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller[_models.MongoUserDefinitionGetResults]( + return LROPoller[_models.MongoRoleDefinitionGetResults]( self._client, raw_result, get_long_running_output, polling_method # type: ignore ) - def _delete_mongo_user_definition_initial( - self, mongo_user_definition_id: str, resource_group_name: str, account_name: str, **kwargs: Any + def _delete_mongo_role_definition_initial( + self, resource_group_name: str, account_name: str, mongo_role_definition_id: str, **kwargs: Any ) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -5426,10 +5358,10 @@ def _delete_mongo_user_definition_initial( 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_mongo_user_definition_request( - mongo_user_definition_id=mongo_user_definition_id, + _request = build_delete_mongo_role_definition_request( resource_group_name=resource_group_name, account_name=account_name, + mongo_role_definition_id=mongo_role_definition_id, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, @@ -5453,26 +5385,31 @@ def _delete_mongo_user_definition_initial( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @distributed_trace - def begin_delete_mongo_user_definition( - self, mongo_user_definition_id: str, resource_group_name: str, account_name: str, **kwargs: Any + def begin_delete_mongo_role_definition( + self, resource_group_name: str, account_name: str, mongo_role_definition_id: str, **kwargs: Any ) -> LROPoller[None]: - """Deletes an existing Azure Cosmos DB Mongo User Definition. + """Deletes an existing Azure Cosmos DB Mongo Role Definition. - :param mongo_user_definition_id: The ID for the User Definition {dbName.userName}. Required. - :type mongo_user_definition_id: str :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param account_name: Cosmos DB database account name. Required. :type account_name: str + :param mongo_role_definition_id: The ID for the Role Definition {dbName.roleName}. Required. + :type mongo_role_definition_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: @@ -5486,10 +5423,10 @@ def begin_delete_mongo_user_definition( 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_mongo_user_definition_initial( - mongo_user_definition_id=mongo_user_definition_id, + raw_result = self._delete_mongo_role_definition_initial( resource_group_name=resource_group_name, account_name=account_name, + mongo_role_definition_id=mongo_role_definition_id, api_version=api_version, cls=lambda x, y, z: x, headers=_headers, @@ -5504,7 +5441,9 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- return cls(pipeline_response, None, {}) # type: ignore if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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: @@ -5583,7 +5522,7 @@ def extract_data(pipeline_response): list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore - return None, iter(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): _request = prepare_request(next_link) @@ -5602,13 +5541,75 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - def _retrieve_continuous_backup_information_initial( # pylint: disable=name-too-long + @distributed_trace + def get_mongo_user_definition( + self, resource_group_name: str, account_name: str, mongo_user_definition_id: str, **kwargs: Any + ) -> _models.MongoUserDefinitionGetResults: + """Retrieves the properties of an existing Azure Cosmos DB Mongo User Definition with the given + Id. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param mongo_user_definition_id: The ID for the User Definition {dbName.userName}. Required. + :type mongo_user_definition_id: str + :return: MongoUserDefinitionGetResults or the result of cls(response) + :rtype: ~azure.mgmt.cosmosdb.models.MongoUserDefinitionGetResults + :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.MongoUserDefinitionGetResults] = kwargs.pop("cls", None) + + _request = build_get_mongo_user_definition_request( + resource_group_name=resource_group_name, + account_name=account_name, + mongo_user_definition_id=mongo_user_definition_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("MongoUserDefinitionGetResults", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + def _create_update_mongo_user_definition_initial( # pylint: disable=name-too-long self, resource_group_name: str, account_name: str, - database_name: str, - collection_name: str, - location: Union[_models.ContinuousBackupRestoreLocation, IO[bytes]], + mongo_user_definition_id: str, + create_update_mongo_user_definition_parameters: Union[ + _models.MongoUserDefinitionCreateUpdateParameters, IO[bytes] + ], **kwargs: Any ) -> Iterator[bytes]: error_map: MutableMapping = { @@ -5629,16 +5630,17 @@ def _retrieve_continuous_backup_information_initial( # pylint: disable=name-too content_type = content_type or "application/json" _json = None _content = None - if isinstance(location, (IOBase, bytes)): - _content = location + if isinstance(create_update_mongo_user_definition_parameters, (IOBase, bytes)): + _content = create_update_mongo_user_definition_parameters else: - _json = self._serialize.body(location, "ContinuousBackupRestoreLocation") + _json = self._serialize.body( + create_update_mongo_user_definition_parameters, "MongoUserDefinitionCreateUpdateParameters" + ) - _request = build_retrieve_continuous_backup_information_request( + _request = build_create_update_mongo_user_definition_request( resource_group_name=resource_group_name, account_name=account_name, - database_name=database_name, - collection_name=collection_name, + mongo_user_definition_id=mongo_user_definition_id, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, @@ -5665,108 +5667,114 @@ def _retrieve_continuous_backup_information_initial( # pylint: disable=name-too map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @overload - def begin_retrieve_continuous_backup_information( # pylint: disable=name-too-long + def begin_create_update_mongo_user_definition( # pylint: disable=name-too-long self, resource_group_name: str, account_name: str, - database_name: str, - collection_name: str, - location: _models.ContinuousBackupRestoreLocation, + mongo_user_definition_id: str, + create_update_mongo_user_definition_parameters: _models.MongoUserDefinitionCreateUpdateParameters, *, content_type: str = "application/json", **kwargs: Any - ) -> LROPoller[_models.BackupInformation]: - """Retrieves continuous backup information for a Mongodb collection. + ) -> LROPoller[_models.MongoUserDefinitionGetResults]: + """Creates or updates an Azure Cosmos DB Mongo User Definition. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param database_name: Cosmos DB database name. Required. - :type database_name: str - :param collection_name: Cosmos DB collection name. Required. - :type collection_name: str - :param location: The name of the continuous backup restore location. Required. - :type location: ~azure.mgmt.cosmosdb.models.ContinuousBackupRestoreLocation + :param mongo_user_definition_id: The ID for the User Definition {dbName.userName}. Required. + :type mongo_user_definition_id: str + :param create_update_mongo_user_definition_parameters: The properties required to create or + update a User Definition. Required. + :type create_update_mongo_user_definition_parameters: + ~azure.mgmt.cosmosdb.models.MongoUserDefinitionCreateUpdateParameters :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 BackupInformation or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.BackupInformation] + :return: An instance of LROPoller that returns either MongoUserDefinitionGetResults or the + result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.MongoUserDefinitionGetResults] :raises ~azure.core.exceptions.HttpResponseError: """ @overload - def begin_retrieve_continuous_backup_information( # pylint: disable=name-too-long + def begin_create_update_mongo_user_definition( # pylint: disable=name-too-long self, resource_group_name: str, account_name: str, - database_name: str, - collection_name: str, - location: IO[bytes], + mongo_user_definition_id: str, + create_update_mongo_user_definition_parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> LROPoller[_models.BackupInformation]: - """Retrieves continuous backup information for a Mongodb collection. + ) -> LROPoller[_models.MongoUserDefinitionGetResults]: + """Creates or updates an Azure Cosmos DB Mongo User Definition. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param database_name: Cosmos DB database name. Required. - :type database_name: str - :param collection_name: Cosmos DB collection name. Required. - :type collection_name: str - :param location: The name of the continuous backup restore location. Required. - :type location: IO[bytes] + :param mongo_user_definition_id: The ID for the User Definition {dbName.userName}. Required. + :type mongo_user_definition_id: str + :param create_update_mongo_user_definition_parameters: The properties required to create or + update a User Definition. Required. + :type create_update_mongo_user_definition_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 BackupInformation or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.BackupInformation] + :return: An instance of LROPoller that returns either MongoUserDefinitionGetResults or the + result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.MongoUserDefinitionGetResults] :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace - def begin_retrieve_continuous_backup_information( # pylint: disable=name-too-long + def begin_create_update_mongo_user_definition( # pylint: disable=name-too-long self, resource_group_name: str, account_name: str, - database_name: str, - collection_name: str, - location: Union[_models.ContinuousBackupRestoreLocation, IO[bytes]], + mongo_user_definition_id: str, + create_update_mongo_user_definition_parameters: Union[ + _models.MongoUserDefinitionCreateUpdateParameters, IO[bytes] + ], **kwargs: Any - ) -> LROPoller[_models.BackupInformation]: - """Retrieves continuous backup information for a Mongodb collection. + ) -> LROPoller[_models.MongoUserDefinitionGetResults]: + """Creates or updates an Azure Cosmos DB Mongo User Definition. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param database_name: Cosmos DB database name. Required. - :type database_name: str - :param collection_name: Cosmos DB collection name. Required. - :type collection_name: str - :param location: The name of the continuous backup restore location. Is either a - ContinuousBackupRestoreLocation type or a IO[bytes] type. Required. - :type location: ~azure.mgmt.cosmosdb.models.ContinuousBackupRestoreLocation or IO[bytes] - :return: An instance of LROPoller that returns either BackupInformation or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.BackupInformation] + :param mongo_user_definition_id: The ID for the User Definition {dbName.userName}. Required. + :type mongo_user_definition_id: str + :param create_update_mongo_user_definition_parameters: The properties required to create or + update a User Definition. Is either a MongoUserDefinitionCreateUpdateParameters type or a + IO[bytes] type. Required. + :type create_update_mongo_user_definition_parameters: + ~azure.mgmt.cosmosdb.models.MongoUserDefinitionCreateUpdateParameters or IO[bytes] + :return: An instance of LROPoller that returns either MongoUserDefinitionGetResults or the + result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.MongoUserDefinitionGetResults] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -5774,17 +5782,16 @@ def begin_retrieve_continuous_backup_information( # pylint: disable=name-too-lo 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.BackupInformation] = kwargs.pop("cls", None) + cls: ClsType[_models.MongoUserDefinitionGetResults] = 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._retrieve_continuous_backup_information_initial( + raw_result = self._create_update_mongo_user_definition_initial( resource_group_name=resource_group_name, account_name=account_name, - database_name=database_name, - collection_name=collection_name, - location=location, + mongo_user_definition_id=mongo_user_definition_id, + create_update_mongo_user_definition_parameters=create_update_mongo_user_definition_parameters, api_version=api_version, content_type=content_type, cls=lambda x, y, z: x, @@ -5796,7 +5803,7 @@ def begin_retrieve_continuous_backup_information( # pylint: disable=name-too-lo kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("BackupInformation", pipeline_response.http_response) + deserialized = self._deserialize("MongoUserDefinitionGetResults", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized @@ -5810,12 +5817,128 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller[_models.BackupInformation].from_continuation_token( + return LROPoller[_models.MongoUserDefinitionGetResults].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller[_models.BackupInformation]( + return LROPoller[_models.MongoUserDefinitionGetResults]( self._client, raw_result, get_long_running_output, polling_method # type: ignore ) + + def _delete_mongo_user_definition_initial( + self, resource_group_name: str, account_name: str, mongo_user_definition_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_mongo_user_definition_request( + resource_group_name=resource_group_name, + account_name=account_name, + mongo_user_definition_id=mongo_user_definition_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 [200, 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + 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_mongo_user_definition( + self, resource_group_name: str, account_name: str, mongo_user_definition_id: str, **kwargs: Any + ) -> LROPoller[None]: + """Deletes an existing Azure Cosmos DB Mongo User Definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param mongo_user_definition_id: The ID for the User Definition {dbName.userName}. Required. + :type mongo_user_definition_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_mongo_user_definition_initial( + resource_group_name=resource_group_name, + account_name=account_name, + mongo_user_definition_id=mongo_user_definition_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 diff --git a/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/operations/_mongo_mi_resources_operations.py b/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/operations/_mongo_mi_resources_operations.py index 02567daee04..0a130b8004e 100644 --- a/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/operations/_mongo_mi_resources_operations.py +++ b/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/operations/_mongo_mi_resources_operations.py @@ -43,19 +43,19 @@ _SERIALIZER.client_side_validation = False -def build_get_mongo_mi_role_definition_request( # pylint: disable=name-too-long - resource_group_name: str, account_name: str, role_definition_id: str, subscription_id: str, **kwargs: Any +def build_list_mongo_mi_role_assignments_request( # pylint: disable=name-too-long + resource_group_name: str, account_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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongoMIRoleDefinitions/{roleDefinitionId}", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongoMIRoleAssignments", ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), @@ -65,7 +65,6 @@ def build_get_mongo_mi_role_definition_request( # pylint: disable=name-too-long "accountName": _SERIALIZER.url( "account_name", account_name, "str", max_length=50, min_length=3, pattern=r"^[a-z0-9]+(-[a-z0-9]+)*" ), - "roleDefinitionId": _SERIALIZER.url("role_definition_id", role_definition_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -79,20 +78,19 @@ def build_get_mongo_mi_role_definition_request( # pylint: disable=name-too-long return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_update_mongo_mi_role_definition_request( # pylint: disable=name-too-long - resource_group_name: str, account_name: str, role_definition_id: str, subscription_id: str, **kwargs: Any +def build_get_mongo_mi_role_assignment_request( # pylint: disable=name-too-long + resource_group_name: str, account_name: str, role_assignment_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-11-01-preview")) - 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-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongoMIRoleDefinitions/{roleDefinitionId}", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongoMIRoleAssignments/{roleAssignmentId}", ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), @@ -102,7 +100,7 @@ def build_create_update_mongo_mi_role_definition_request( # pylint: disable=nam "accountName": _SERIALIZER.url( "account_name", account_name, "str", max_length=50, min_length=3, pattern=r"^[a-z0-9]+(-[a-z0-9]+)*" ), - "roleDefinitionId": _SERIALIZER.url("role_definition_id", role_definition_id, "str"), + "roleAssignmentId": _SERIALIZER.url("role_assignment_id", role_assignment_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -111,26 +109,25 @@ def build_create_update_mongo_mi_role_definition_request( # pylint: disable=nam _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) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_delete_mongo_mi_role_definition_request( # pylint: disable=name-too-long - resource_group_name: str, account_name: str, role_definition_id: str, subscription_id: str, **kwargs: Any +def build_create_update_mongo_mi_role_assignment_request( # pylint: disable=name-too-long + resource_group_name: str, account_name: str, role_assignment_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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) + 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.DocumentDB/databaseAccounts/{accountName}/mongoMIRoleDefinitions/{roleDefinitionId}", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongoMIRoleAssignments/{roleAssignmentId}", ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), @@ -140,7 +137,7 @@ def build_delete_mongo_mi_role_definition_request( # pylint: disable=name-too-l "accountName": _SERIALIZER.url( "account_name", account_name, "str", max_length=50, min_length=3, pattern=r"^[a-z0-9]+(-[a-z0-9]+)*" ), - "roleDefinitionId": _SERIALIZER.url("role_definition_id", role_definition_id, "str"), + "roleAssignmentId": _SERIALIZER.url("role_assignment_id", role_assignment_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -149,24 +146,26 @@ def build_delete_mongo_mi_role_definition_request( # pylint: disable=name-too-l _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="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_mongo_mi_role_definitions_request( # pylint: disable=name-too-long - resource_group_name: str, account_name: str, subscription_id: str, **kwargs: Any +def build_delete_mongo_mi_role_assignment_request( # pylint: disable=name-too-long + resource_group_name: str, account_name: str, role_assignment_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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongoMIRoleDefinitions", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongoMIRoleAssignments/{roleAssignmentId}", ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), @@ -176,6 +175,7 @@ def build_list_mongo_mi_role_definitions_request( # pylint: disable=name-too-lo "accountName": _SERIALIZER.url( "account_name", account_name, "str", max_length=50, min_length=3, pattern=r"^[a-z0-9]+(-[a-z0-9]+)*" ), + "roleAssignmentId": _SERIALIZER.url("role_assignment_id", role_assignment_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -186,22 +186,22 @@ def build_list_mongo_mi_role_definitions_request( # pylint: disable=name-too-lo # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) -def build_get_mongo_mi_role_assignment_request( # pylint: disable=name-too-long - resource_group_name: str, account_name: str, role_assignment_id: str, subscription_id: str, **kwargs: Any +def build_list_mongo_mi_role_definitions_request( # pylint: disable=name-too-long + resource_group_name: str, account_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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongoMIRoleAssignments/{roleAssignmentId}", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongoMIRoleDefinitions", ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), @@ -211,7 +211,6 @@ def build_get_mongo_mi_role_assignment_request( # pylint: disable=name-too-long "accountName": _SERIALIZER.url( "account_name", account_name, "str", max_length=50, min_length=3, pattern=r"^[a-z0-9]+(-[a-z0-9]+)*" ), - "roleAssignmentId": _SERIALIZER.url("role_assignment_id", role_assignment_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -225,20 +224,19 @@ def build_get_mongo_mi_role_assignment_request( # pylint: disable=name-too-long return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_update_mongo_mi_role_assignment_request( # pylint: disable=name-too-long - resource_group_name: str, account_name: str, role_assignment_id: str, subscription_id: str, **kwargs: Any +def build_get_mongo_mi_role_definition_request( # pylint: disable=name-too-long + resource_group_name: str, account_name: str, role_definition_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-11-01-preview")) - 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-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongoMIRoleAssignments/{roleAssignmentId}", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongoMIRoleDefinitions/{roleDefinitionId}", ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), @@ -248,7 +246,7 @@ def build_create_update_mongo_mi_role_assignment_request( # pylint: disable=nam "accountName": _SERIALIZER.url( "account_name", account_name, "str", max_length=50, min_length=3, pattern=r"^[a-z0-9]+(-[a-z0-9]+)*" ), - "roleAssignmentId": _SERIALIZER.url("role_assignment_id", role_assignment_id, "str"), + "roleDefinitionId": _SERIALIZER.url("role_definition_id", role_definition_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -257,26 +255,25 @@ def build_create_update_mongo_mi_role_assignment_request( # pylint: disable=nam _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) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_delete_mongo_mi_role_assignment_request( # pylint: disable=name-too-long - resource_group_name: str, account_name: str, role_assignment_id: str, subscription_id: str, **kwargs: Any +def build_create_update_mongo_mi_role_definition_request( # pylint: disable=name-too-long + resource_group_name: str, account_name: str, role_definition_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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) + 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.DocumentDB/databaseAccounts/{accountName}/mongoMIRoleAssignments/{roleAssignmentId}", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongoMIRoleDefinitions/{roleDefinitionId}", ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), @@ -286,7 +283,7 @@ def build_delete_mongo_mi_role_assignment_request( # pylint: disable=name-too-l "accountName": _SERIALIZER.url( "account_name", account_name, "str", max_length=50, min_length=3, pattern=r"^[a-z0-9]+(-[a-z0-9]+)*" ), - "roleAssignmentId": _SERIALIZER.url("role_assignment_id", role_assignment_id, "str"), + "roleDefinitionId": _SERIALIZER.url("role_definition_id", role_definition_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -295,24 +292,26 @@ def build_delete_mongo_mi_role_assignment_request( # pylint: disable=name-too-l _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="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_mongo_mi_role_assignments_request( # pylint: disable=name-too-long - resource_group_name: str, account_name: str, subscription_id: str, **kwargs: Any +def build_delete_mongo_mi_role_definition_request( # pylint: disable=name-too-long + resource_group_name: str, account_name: str, role_definition_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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongoMIRoleAssignments", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongoMIRoleDefinitions/{roleDefinitionId}", ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), @@ -322,6 +321,7 @@ def build_list_mongo_mi_role_assignments_request( # pylint: disable=name-too-lo "accountName": _SERIALIZER.url( "account_name", account_name, "str", max_length=50, min_length=3, pattern=r"^[a-z0-9]+(-[a-z0-9]+)*" ), + "roleDefinitionId": _SERIALIZER.url("role_definition_id", role_definition_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -332,7 +332,7 @@ def build_list_mongo_mi_role_assignments_request( # pylint: disable=name-too-lo # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) class MongoMIResourcesOperations: @@ -355,10 +355,98 @@ def __init__(self, *args, **kwargs) -> None: self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def get_mongo_mi_role_definition( - self, resource_group_name: str, account_name: str, role_definition_id: str, **kwargs: Any - ) -> _models.MongoMIRoleDefinitionResource: - """Retrieves the properties of an existing Azure Cosmos DB MongoMI Role Definition with the given + def list_mongo_mi_role_assignments( + self, resource_group_name: str, account_name: str, **kwargs: Any + ) -> ItemPaged["_models.MongoMIRoleAssignmentResource"]: + """Retrieves the list of all Azure Cosmos DB MongoMI Role Assignments. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :return: An iterator like instance of either MongoMIRoleAssignmentResource or the result of + cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cosmosdb.models.MongoMIRoleAssignmentResource] + :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.MongoMIRoleAssignmentListResult] = 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_mongo_mi_role_assignments_request( + resource_group_name=resource_group_name, + account_name=account_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("MongoMIRoleAssignmentListResult", 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_mongo_mi_role_assignment( + self, resource_group_name: str, account_name: str, role_assignment_id: str, **kwargs: Any + ) -> _models.MongoMIRoleAssignmentResource: + """Retrieves the properties of an existing Azure Cosmos DB MongoMI Role Assignment with the given Id. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -366,10 +454,10 @@ def get_mongo_mi_role_definition( :type resource_group_name: str :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param role_definition_id: The GUID for the Role Definition. Required. - :type role_definition_id: str - :return: MongoMIRoleDefinitionResource or the result of cls(response) - :rtype: ~azure.mgmt.cosmosdb.models.MongoMIRoleDefinitionResource + :param role_assignment_id: The GUID for the Role Assignment. Required. + :type role_assignment_id: str + :return: MongoMIRoleAssignmentResource or the result of cls(response) + :rtype: ~azure.mgmt.cosmosdb.models.MongoMIRoleAssignmentResource :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -384,12 +472,12 @@ def get_mongo_mi_role_definition( _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.MongoMIRoleDefinitionResource] = kwargs.pop("cls", None) + cls: ClsType[_models.MongoMIRoleAssignmentResource] = kwargs.pop("cls", None) - _request = build_get_mongo_mi_role_definition_request( + _request = build_get_mongo_mi_role_assignment_request( resource_group_name=resource_group_name, account_name=account_name, - role_definition_id=role_definition_id, + role_assignment_id=role_assignment_id, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, @@ -412,19 +500,19 @@ def get_mongo_mi_role_definition( ) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("MongoMIRoleDefinitionResource", pipeline_response.http_response) + deserialized = self._deserialize("MongoMIRoleAssignmentResource", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - def _create_update_mongo_mi_role_definition_initial( # pylint: disable=name-too-long + def _create_update_mongo_mi_role_assignment_initial( # pylint: disable=name-too-long self, resource_group_name: str, account_name: str, - role_definition_id: str, - create_update_mongo_mi_role_definition_parameters: Union[_models.MongoMIRoleDefinitionResource, IO[bytes]], + role_assignment_id: str, + create_update_mongo_mi_role_assignment_parameters: Union[_models.MongoMIRoleAssignmentResource, IO[bytes]], **kwargs: Any ) -> Iterator[bytes]: error_map: MutableMapping = { @@ -445,17 +533,17 @@ def _create_update_mongo_mi_role_definition_initial( # pylint: disable=name-too content_type = content_type or "application/json" _json = None _content = None - if isinstance(create_update_mongo_mi_role_definition_parameters, (IOBase, bytes)): - _content = create_update_mongo_mi_role_definition_parameters + if isinstance(create_update_mongo_mi_role_assignment_parameters, (IOBase, bytes)): + _content = create_update_mongo_mi_role_assignment_parameters else: _json = self._serialize.body( - create_update_mongo_mi_role_definition_parameters, "MongoMIRoleDefinitionResource" + create_update_mongo_mi_role_assignment_parameters, "MongoMIRoleAssignmentResource" ) - _request = build_create_update_mongo_mi_role_definition_request( + _request = build_create_update_mongo_mi_role_assignment_request( resource_group_name=resource_group_name, account_name=account_name, - role_definition_id=role_definition_id, + role_assignment_id=role_assignment_id, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, @@ -488,10 +576,11 @@ def _create_update_mongo_mi_role_definition_initial( # pylint: disable=name-too response_headers = {} if response.status_code == 202: - response_headers["azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("azure-AsyncOperation") + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") ) - response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) @@ -501,99 +590,99 @@ def _create_update_mongo_mi_role_definition_initial( # pylint: disable=name-too return deserialized # type: ignore @overload - def begin_create_update_mongo_mi_role_definition( # pylint: disable=name-too-long + def begin_create_update_mongo_mi_role_assignment( # pylint: disable=name-too-long self, resource_group_name: str, account_name: str, - role_definition_id: str, - create_update_mongo_mi_role_definition_parameters: _models.MongoMIRoleDefinitionResource, + role_assignment_id: str, + create_update_mongo_mi_role_assignment_parameters: _models.MongoMIRoleAssignmentResource, *, content_type: str = "application/json", **kwargs: Any - ) -> LROPoller[_models.MongoMIRoleDefinitionResource]: - """Creates or updates an Azure Cosmos DB MongoMI Role Definition. + ) -> LROPoller[_models.MongoMIRoleAssignmentResource]: + """Creates or updates an Azure Cosmos DB MongoMI Role Assignment. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param role_definition_id: The GUID for the Role Definition. Required. - :type role_definition_id: str - :param create_update_mongo_mi_role_definition_parameters: The properties required to create or - update a Role Definition. Required. - :type create_update_mongo_mi_role_definition_parameters: - ~azure.mgmt.cosmosdb.models.MongoMIRoleDefinitionResource + :param role_assignment_id: The GUID for the Role Assignment. Required. + :type role_assignment_id: str + :param create_update_mongo_mi_role_assignment_parameters: The properties required to create or + update a Role Assignment. Required. + :type create_update_mongo_mi_role_assignment_parameters: + ~azure.mgmt.cosmosdb.models.MongoMIRoleAssignmentResource :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 MongoMIRoleDefinitionResource or the + :return: An instance of LROPoller that returns either MongoMIRoleAssignmentResource or the result of cls(response) :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.MongoMIRoleDefinitionResource] + ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.MongoMIRoleAssignmentResource] :raises ~azure.core.exceptions.HttpResponseError: """ @overload - def begin_create_update_mongo_mi_role_definition( # pylint: disable=name-too-long + def begin_create_update_mongo_mi_role_assignment( # pylint: disable=name-too-long self, resource_group_name: str, account_name: str, - role_definition_id: str, - create_update_mongo_mi_role_definition_parameters: IO[bytes], + role_assignment_id: str, + create_update_mongo_mi_role_assignment_parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> LROPoller[_models.MongoMIRoleDefinitionResource]: - """Creates or updates an Azure Cosmos DB MongoMI Role Definition. + ) -> LROPoller[_models.MongoMIRoleAssignmentResource]: + """Creates or updates an Azure Cosmos DB MongoMI Role Assignment. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param role_definition_id: The GUID for the Role Definition. Required. - :type role_definition_id: str - :param create_update_mongo_mi_role_definition_parameters: The properties required to create or - update a Role Definition. Required. - :type create_update_mongo_mi_role_definition_parameters: IO[bytes] + :param role_assignment_id: The GUID for the Role Assignment. Required. + :type role_assignment_id: str + :param create_update_mongo_mi_role_assignment_parameters: The properties required to create or + update a Role Assignment. Required. + :type create_update_mongo_mi_role_assignment_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 MongoMIRoleDefinitionResource or the + :return: An instance of LROPoller that returns either MongoMIRoleAssignmentResource or the result of cls(response) :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.MongoMIRoleDefinitionResource] + ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.MongoMIRoleAssignmentResource] :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace - def begin_create_update_mongo_mi_role_definition( # pylint: disable=name-too-long + def begin_create_update_mongo_mi_role_assignment( # pylint: disable=name-too-long self, resource_group_name: str, account_name: str, - role_definition_id: str, - create_update_mongo_mi_role_definition_parameters: Union[_models.MongoMIRoleDefinitionResource, IO[bytes]], + role_assignment_id: str, + create_update_mongo_mi_role_assignment_parameters: Union[_models.MongoMIRoleAssignmentResource, IO[bytes]], **kwargs: Any - ) -> LROPoller[_models.MongoMIRoleDefinitionResource]: - """Creates or updates an Azure Cosmos DB MongoMI Role Definition. + ) -> LROPoller[_models.MongoMIRoleAssignmentResource]: + """Creates or updates an Azure Cosmos DB MongoMI Role Assignment. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param role_definition_id: The GUID for the Role Definition. Required. - :type role_definition_id: str - :param create_update_mongo_mi_role_definition_parameters: The properties required to create or - update a Role Definition. Is either a MongoMIRoleDefinitionResource type or a IO[bytes] type. + :param role_assignment_id: The GUID for the Role Assignment. Required. + :type role_assignment_id: str + :param create_update_mongo_mi_role_assignment_parameters: The properties required to create or + update a Role Assignment. Is either a MongoMIRoleAssignmentResource type or a IO[bytes] type. Required. - :type create_update_mongo_mi_role_definition_parameters: - ~azure.mgmt.cosmosdb.models.MongoMIRoleDefinitionResource or IO[bytes] - :return: An instance of LROPoller that returns either MongoMIRoleDefinitionResource or the + :type create_update_mongo_mi_role_assignment_parameters: + ~azure.mgmt.cosmosdb.models.MongoMIRoleAssignmentResource or IO[bytes] + :return: An instance of LROPoller that returns either MongoMIRoleAssignmentResource or the result of cls(response) :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.MongoMIRoleDefinitionResource] + ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.MongoMIRoleAssignmentResource] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -601,16 +690,16 @@ def begin_create_update_mongo_mi_role_definition( # pylint: disable=name-too-lo 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.MongoMIRoleDefinitionResource] = kwargs.pop("cls", None) + cls: ClsType[_models.MongoMIRoleAssignmentResource] = 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_update_mongo_mi_role_definition_initial( + raw_result = self._create_update_mongo_mi_role_assignment_initial( resource_group_name=resource_group_name, account_name=account_name, - role_definition_id=role_definition_id, - create_update_mongo_mi_role_definition_parameters=create_update_mongo_mi_role_definition_parameters, + role_assignment_id=role_assignment_id, + create_update_mongo_mi_role_assignment_parameters=create_update_mongo_mi_role_assignment_parameters, api_version=api_version, content_type=content_type, cls=lambda x, y, z: x, @@ -622,30 +711,32 @@ def begin_create_update_mongo_mi_role_definition( # pylint: disable=name-too-lo kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("MongoMIRoleDefinitionResource", pipeline_response.http_response) + deserialized = self._deserialize("MongoMIRoleAssignmentResource", 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, **kwargs)) + 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.MongoMIRoleDefinitionResource].from_continuation_token( + return LROPoller[_models.MongoMIRoleAssignmentResource].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller[_models.MongoMIRoleDefinitionResource]( + return LROPoller[_models.MongoMIRoleAssignmentResource]( self._client, raw_result, get_long_running_output, polling_method # type: ignore ) - def _delete_mongo_mi_role_definition_initial( - self, resource_group_name: str, account_name: str, role_definition_id: str, **kwargs: Any + def _delete_mongo_mi_role_assignment_initial( + self, resource_group_name: str, account_name: str, role_assignment_id: str, **kwargs: Any ) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -661,10 +752,10 @@ def _delete_mongo_mi_role_definition_initial( 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_mongo_mi_role_definition_request( + _request = build_delete_mongo_mi_role_assignment_request( resource_group_name=resource_group_name, account_name=account_name, - role_definition_id=role_definition_id, + role_assignment_id=role_assignment_id, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, @@ -694,10 +785,10 @@ def _delete_mongo_mi_role_definition_initial( response_headers = {} if response.status_code == 202: - response_headers["azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("azure-AsyncOperation") + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") ) - response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) @@ -707,18 +798,18 @@ def _delete_mongo_mi_role_definition_initial( return deserialized # type: ignore @distributed_trace - def begin_delete_mongo_mi_role_definition( - self, resource_group_name: str, account_name: str, role_definition_id: str, **kwargs: Any + def begin_delete_mongo_mi_role_assignment( + self, resource_group_name: str, account_name: str, role_assignment_id: str, **kwargs: Any ) -> LROPoller[None]: - """Deletes an existing Azure Cosmos DB MongoMI Role Definition. + """Deletes an existing Azure Cosmos DB MongoMI Role Assignment. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param role_definition_id: The GUID for the Role Definition. Required. - :type role_definition_id: str + :param role_assignment_id: The GUID for the Role Assignment. Required. + :type role_assignment_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: @@ -732,10 +823,10 @@ def begin_delete_mongo_mi_role_definition( 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_mongo_mi_role_definition_initial( + raw_result = self._delete_mongo_mi_role_assignment_initial( resource_group_name=resource_group_name, account_name=account_name, - role_definition_id=role_definition_id, + role_assignment_id=role_assignment_id, api_version=api_version, cls=lambda x, y, z: x, headers=_headers, @@ -750,7 +841,9 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- return cls(pipeline_response, None, {}) # type: ignore if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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: @@ -829,7 +922,7 @@ def extract_data(pipeline_response): list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore - return None, iter(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): _request = prepare_request(next_link) @@ -853,10 +946,10 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) @distributed_trace - def get_mongo_mi_role_assignment( - self, resource_group_name: str, account_name: str, role_assignment_id: str, **kwargs: Any - ) -> _models.MongoMIRoleAssignmentResource: - """Retrieves the properties of an existing Azure Cosmos DB MongoMI Role Assignment with the given + def get_mongo_mi_role_definition( + self, resource_group_name: str, account_name: str, role_definition_id: str, **kwargs: Any + ) -> _models.MongoMIRoleDefinitionResource: + """Retrieves the properties of an existing Azure Cosmos DB MongoMI Role Definition with the given Id. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -864,10 +957,10 @@ def get_mongo_mi_role_assignment( :type resource_group_name: str :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param role_assignment_id: The GUID for the Role Assignment. Required. - :type role_assignment_id: str - :return: MongoMIRoleAssignmentResource or the result of cls(response) - :rtype: ~azure.mgmt.cosmosdb.models.MongoMIRoleAssignmentResource + :param role_definition_id: The GUID for the Role Definition. Required. + :type role_definition_id: str + :return: MongoMIRoleDefinitionResource or the result of cls(response) + :rtype: ~azure.mgmt.cosmosdb.models.MongoMIRoleDefinitionResource :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -882,12 +975,12 @@ def get_mongo_mi_role_assignment( _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.MongoMIRoleAssignmentResource] = kwargs.pop("cls", None) + cls: ClsType[_models.MongoMIRoleDefinitionResource] = kwargs.pop("cls", None) - _request = build_get_mongo_mi_role_assignment_request( + _request = build_get_mongo_mi_role_definition_request( resource_group_name=resource_group_name, account_name=account_name, - role_assignment_id=role_assignment_id, + role_definition_id=role_definition_id, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, @@ -910,19 +1003,19 @@ def get_mongo_mi_role_assignment( ) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("MongoMIRoleAssignmentResource", pipeline_response.http_response) + deserialized = self._deserialize("MongoMIRoleDefinitionResource", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - def _create_update_mongo_mi_role_assignment_initial( # pylint: disable=name-too-long + def _create_update_mongo_mi_role_definition_initial( # pylint: disable=name-too-long self, resource_group_name: str, account_name: str, - role_assignment_id: str, - create_update_mongo_mi_role_assignment_parameters: Union[_models.MongoMIRoleAssignmentResource, IO[bytes]], + role_definition_id: str, + create_update_mongo_mi_role_definition_parameters: Union[_models.MongoMIRoleDefinitionResource, IO[bytes]], **kwargs: Any ) -> Iterator[bytes]: error_map: MutableMapping = { @@ -943,17 +1036,17 @@ def _create_update_mongo_mi_role_assignment_initial( # pylint: disable=name-too content_type = content_type or "application/json" _json = None _content = None - if isinstance(create_update_mongo_mi_role_assignment_parameters, (IOBase, bytes)): - _content = create_update_mongo_mi_role_assignment_parameters + if isinstance(create_update_mongo_mi_role_definition_parameters, (IOBase, bytes)): + _content = create_update_mongo_mi_role_definition_parameters else: _json = self._serialize.body( - create_update_mongo_mi_role_assignment_parameters, "MongoMIRoleAssignmentResource" + create_update_mongo_mi_role_definition_parameters, "MongoMIRoleDefinitionResource" ) - _request = build_create_update_mongo_mi_role_assignment_request( + _request = build_create_update_mongo_mi_role_definition_request( resource_group_name=resource_group_name, account_name=account_name, - role_assignment_id=role_assignment_id, + role_definition_id=role_definition_id, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, @@ -986,10 +1079,11 @@ def _create_update_mongo_mi_role_assignment_initial( # pylint: disable=name-too response_headers = {} if response.status_code == 202: - response_headers["azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("azure-AsyncOperation") + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") ) - response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) @@ -999,99 +1093,99 @@ def _create_update_mongo_mi_role_assignment_initial( # pylint: disable=name-too return deserialized # type: ignore @overload - def begin_create_update_mongo_mi_role_assignment( # pylint: disable=name-too-long + def begin_create_update_mongo_mi_role_definition( # pylint: disable=name-too-long self, resource_group_name: str, account_name: str, - role_assignment_id: str, - create_update_mongo_mi_role_assignment_parameters: _models.MongoMIRoleAssignmentResource, + role_definition_id: str, + create_update_mongo_mi_role_definition_parameters: _models.MongoMIRoleDefinitionResource, *, content_type: str = "application/json", **kwargs: Any - ) -> LROPoller[_models.MongoMIRoleAssignmentResource]: - """Creates or updates an Azure Cosmos DB MongoMI Role Assignment. + ) -> LROPoller[_models.MongoMIRoleDefinitionResource]: + """Creates or updates an Azure Cosmos DB MongoMI Role Definition. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param role_assignment_id: The GUID for the Role Assignment. Required. - :type role_assignment_id: str - :param create_update_mongo_mi_role_assignment_parameters: The properties required to create or - update a Role Assignment. Required. - :type create_update_mongo_mi_role_assignment_parameters: - ~azure.mgmt.cosmosdb.models.MongoMIRoleAssignmentResource + :param role_definition_id: The GUID for the Role Definition. Required. + :type role_definition_id: str + :param create_update_mongo_mi_role_definition_parameters: The properties required to create or + update a Role Definition. Required. + :type create_update_mongo_mi_role_definition_parameters: + ~azure.mgmt.cosmosdb.models.MongoMIRoleDefinitionResource :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 MongoMIRoleAssignmentResource or the + :return: An instance of LROPoller that returns either MongoMIRoleDefinitionResource or the result of cls(response) :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.MongoMIRoleAssignmentResource] + ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.MongoMIRoleDefinitionResource] :raises ~azure.core.exceptions.HttpResponseError: """ @overload - def begin_create_update_mongo_mi_role_assignment( # pylint: disable=name-too-long + def begin_create_update_mongo_mi_role_definition( # pylint: disable=name-too-long self, resource_group_name: str, account_name: str, - role_assignment_id: str, - create_update_mongo_mi_role_assignment_parameters: IO[bytes], + role_definition_id: str, + create_update_mongo_mi_role_definition_parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> LROPoller[_models.MongoMIRoleAssignmentResource]: - """Creates or updates an Azure Cosmos DB MongoMI Role Assignment. + ) -> LROPoller[_models.MongoMIRoleDefinitionResource]: + """Creates or updates an Azure Cosmos DB MongoMI Role Definition. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param role_assignment_id: The GUID for the Role Assignment. Required. - :type role_assignment_id: str - :param create_update_mongo_mi_role_assignment_parameters: The properties required to create or - update a Role Assignment. Required. - :type create_update_mongo_mi_role_assignment_parameters: IO[bytes] + :param role_definition_id: The GUID for the Role Definition. Required. + :type role_definition_id: str + :param create_update_mongo_mi_role_definition_parameters: The properties required to create or + update a Role Definition. Required. + :type create_update_mongo_mi_role_definition_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 MongoMIRoleAssignmentResource or the + :return: An instance of LROPoller that returns either MongoMIRoleDefinitionResource or the result of cls(response) :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.MongoMIRoleAssignmentResource] + ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.MongoMIRoleDefinitionResource] :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace - def begin_create_update_mongo_mi_role_assignment( # pylint: disable=name-too-long + def begin_create_update_mongo_mi_role_definition( # pylint: disable=name-too-long self, resource_group_name: str, account_name: str, - role_assignment_id: str, - create_update_mongo_mi_role_assignment_parameters: Union[_models.MongoMIRoleAssignmentResource, IO[bytes]], + role_definition_id: str, + create_update_mongo_mi_role_definition_parameters: Union[_models.MongoMIRoleDefinitionResource, IO[bytes]], **kwargs: Any - ) -> LROPoller[_models.MongoMIRoleAssignmentResource]: - """Creates or updates an Azure Cosmos DB MongoMI Role Assignment. + ) -> LROPoller[_models.MongoMIRoleDefinitionResource]: + """Creates or updates an Azure Cosmos DB MongoMI Role Definition. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param role_assignment_id: The GUID for the Role Assignment. Required. - :type role_assignment_id: str - :param create_update_mongo_mi_role_assignment_parameters: The properties required to create or - update a Role Assignment. Is either a MongoMIRoleAssignmentResource type or a IO[bytes] type. + :param role_definition_id: The GUID for the Role Definition. Required. + :type role_definition_id: str + :param create_update_mongo_mi_role_definition_parameters: The properties required to create or + update a Role Definition. Is either a MongoMIRoleDefinitionResource type or a IO[bytes] type. Required. - :type create_update_mongo_mi_role_assignment_parameters: - ~azure.mgmt.cosmosdb.models.MongoMIRoleAssignmentResource or IO[bytes] - :return: An instance of LROPoller that returns either MongoMIRoleAssignmentResource or the + :type create_update_mongo_mi_role_definition_parameters: + ~azure.mgmt.cosmosdb.models.MongoMIRoleDefinitionResource or IO[bytes] + :return: An instance of LROPoller that returns either MongoMIRoleDefinitionResource or the result of cls(response) :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.MongoMIRoleAssignmentResource] + ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.MongoMIRoleDefinitionResource] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -1099,16 +1193,16 @@ def begin_create_update_mongo_mi_role_assignment( # pylint: disable=name-too-lo 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.MongoMIRoleAssignmentResource] = kwargs.pop("cls", None) + cls: ClsType[_models.MongoMIRoleDefinitionResource] = 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_update_mongo_mi_role_assignment_initial( + raw_result = self._create_update_mongo_mi_role_definition_initial( resource_group_name=resource_group_name, account_name=account_name, - role_assignment_id=role_assignment_id, - create_update_mongo_mi_role_assignment_parameters=create_update_mongo_mi_role_assignment_parameters, + role_definition_id=role_definition_id, + create_update_mongo_mi_role_definition_parameters=create_update_mongo_mi_role_definition_parameters, api_version=api_version, content_type=content_type, cls=lambda x, y, z: x, @@ -1120,30 +1214,32 @@ def begin_create_update_mongo_mi_role_assignment( # pylint: disable=name-too-lo kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("MongoMIRoleAssignmentResource", pipeline_response.http_response) + deserialized = self._deserialize("MongoMIRoleDefinitionResource", 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, **kwargs)) + 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.MongoMIRoleAssignmentResource].from_continuation_token( + return LROPoller[_models.MongoMIRoleDefinitionResource].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller[_models.MongoMIRoleAssignmentResource]( + return LROPoller[_models.MongoMIRoleDefinitionResource]( self._client, raw_result, get_long_running_output, polling_method # type: ignore ) - def _delete_mongo_mi_role_assignment_initial( - self, resource_group_name: str, account_name: str, role_assignment_id: str, **kwargs: Any + def _delete_mongo_mi_role_definition_initial( + self, resource_group_name: str, account_name: str, role_definition_id: str, **kwargs: Any ) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -1159,10 +1255,10 @@ def _delete_mongo_mi_role_assignment_initial( 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_mongo_mi_role_assignment_request( + _request = build_delete_mongo_mi_role_definition_request( resource_group_name=resource_group_name, account_name=account_name, - role_assignment_id=role_assignment_id, + role_definition_id=role_definition_id, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, @@ -1192,10 +1288,10 @@ def _delete_mongo_mi_role_assignment_initial( response_headers = {} if response.status_code == 202: - response_headers["azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("azure-AsyncOperation") + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") ) - response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) @@ -1205,18 +1301,18 @@ def _delete_mongo_mi_role_assignment_initial( return deserialized # type: ignore @distributed_trace - def begin_delete_mongo_mi_role_assignment( - self, resource_group_name: str, account_name: str, role_assignment_id: str, **kwargs: Any + def begin_delete_mongo_mi_role_definition( + self, resource_group_name: str, account_name: str, role_definition_id: str, **kwargs: Any ) -> LROPoller[None]: - """Deletes an existing Azure Cosmos DB MongoMI Role Assignment. + """Deletes an existing Azure Cosmos DB MongoMI Role Definition. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param role_assignment_id: The GUID for the Role Assignment. Required. - :type role_assignment_id: str + :param role_definition_id: The GUID for the Role Definition. Required. + :type role_definition_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: @@ -1230,10 +1326,10 @@ def begin_delete_mongo_mi_role_assignment( 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_mongo_mi_role_assignment_initial( + raw_result = self._delete_mongo_mi_role_definition_initial( resource_group_name=resource_group_name, account_name=account_name, - role_assignment_id=role_assignment_id, + role_definition_id=role_definition_id, api_version=api_version, cls=lambda x, y, z: x, headers=_headers, @@ -1248,7 +1344,9 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- return cls(pipeline_response, None, {}) # type: ignore if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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: @@ -1261,91 +1359,3 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- 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_mongo_mi_role_assignments( - self, resource_group_name: str, account_name: str, **kwargs: Any - ) -> ItemPaged["_models.MongoMIRoleAssignmentResource"]: - """Retrieves the list of all Azure Cosmos DB MongoMI Role Assignments. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param account_name: Cosmos DB database account name. Required. - :type account_name: str - :return: An iterator like instance of either MongoMIRoleAssignmentResource or the result of - cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cosmosdb.models.MongoMIRoleAssignmentResource] - :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.MongoMIRoleAssignmentListResult] = 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_mongo_mi_role_assignments_request( - resource_group_name=resource_group_name, - account_name=account_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("MongoMIRoleAssignmentListResult", 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/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/operations/_network_security_perimeter_configurations_operations.py b/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/operations/_network_security_perimeter_configurations_operations.py index a4758b4b4ff..774abf40311 100644 --- a/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/operations/_network_security_perimeter_configurations_operations.py +++ b/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/operations/_network_security_perimeter_configurations_operations.py @@ -46,7 +46,7 @@ def build_list_request(resource_group_name: str, account_name: str, subscription _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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -85,7 +85,7 @@ def build_get_request( _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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -130,7 +130,7 @@ def build_reconcile_request( _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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -396,6 +396,7 @@ def _reconcile_initial( response_headers = {} response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) diff --git a/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/operations/_notebook_workspaces_operations.py b/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/operations/_notebook_workspaces_operations.py index 138fac74efd..4edebec3d03 100644 --- a/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/operations/_notebook_workspaces_operations.py +++ b/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/operations/_notebook_workspaces_operations.py @@ -49,7 +49,7 @@ def build_list_by_database_account_request( _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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -88,7 +88,7 @@ def build_get_request( _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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -128,7 +128,7 @@ def build_create_or_update_request( _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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -171,7 +171,7 @@ def build_delete_request( _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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -211,7 +211,7 @@ def build_list_connection_info_request( _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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -251,7 +251,7 @@ def build_regenerate_auth_token_request( _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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -291,7 +291,7 @@ def build_start_request( _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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -404,7 +404,7 @@ def extract_data(pipeline_response): list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore - return None, iter(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): _request = prepare_request(next_link) @@ -418,7 +418,7 @@ 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( - _models.ErrorResponseAutoGenerated2, + _models.ErrorResponse, pipeline_response, ) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -484,7 +484,7 @@ def get( 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.ErrorResponseAutoGenerated2, + _models.ErrorResponse, pipeline_response, ) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -556,15 +556,18 @@ def _create_or_update_initial( pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize( - _models.ErrorResponseAutoGenerated2, + _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")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @@ -690,13 +693,19 @@ def begin_create_or_update( kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): + response_headers = {} + response = pipeline_response.http_response + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + deserialized = self._deserialize("NotebookWorkspace", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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: @@ -759,15 +768,20 @@ def _delete_initial( pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize( - _models.ErrorResponseAutoGenerated2, + _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["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @@ -820,7 +834,9 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- return cls(pipeline_response, None, {}) # type: ignore if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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: @@ -891,7 +907,7 @@ def list_connection_info( 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.ErrorResponseAutoGenerated2, + _models.ErrorResponse, pipeline_response, ) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -950,15 +966,20 @@ def _regenerate_auth_token_initial( pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize( - _models.ErrorResponseAutoGenerated2, + _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["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @@ -1011,7 +1032,9 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- return cls(pipeline_response, None, {}) # type: ignore if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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: @@ -1072,15 +1095,20 @@ def _start_initial( pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize( - _models.ErrorResponseAutoGenerated2, + _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["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @@ -1133,7 +1161,9 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- return cls(pipeline_response, None, {}) # type: ignore if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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: diff --git a/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/operations/_operations.py b/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/operations/_operations.py index c4b868e1feb..32258b35c34 100644 --- a/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/operations/_operations.py +++ b/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/operations/_operations.py @@ -41,7 +41,7 @@ def build_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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -142,7 +142,11 @@ 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response diff --git a/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/operations/_partition_key_range_id_operations.py b/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/operations/_partition_key_range_id_operations.py index 5050fbb2dc9..ba8b142900c 100644 --- a/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/operations/_partition_key_range_id_operations.py +++ b/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/operations/_partition_key_range_id_operations.py @@ -52,7 +52,7 @@ def build_list_metrics_request( _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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -189,7 +189,7 @@ def extract_data(pipeline_response): list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore - return None, iter(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): _request = prepare_request(next_link) @@ -202,7 +202,11 @@ 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response diff --git a/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/operations/_partition_key_range_id_region_operations.py b/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/operations/_partition_key_range_id_region_operations.py index cc3151ecddd..99768414fb3 100644 --- a/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/operations/_partition_key_range_id_region_operations.py +++ b/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/operations/_partition_key_range_id_region_operations.py @@ -53,7 +53,7 @@ def build_list_metrics_request( _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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -196,7 +196,7 @@ def extract_data(pipeline_response): list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore - return None, iter(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): _request = prepare_request(next_link) @@ -209,7 +209,11 @@ 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response diff --git a/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/operations/_patch.py b/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/operations/_patch.py index f7dd3251033..87676c65a8f 100644 --- a/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/operations/_patch.py +++ b/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/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/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/operations/_percentile_operations.py b/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/operations/_percentile_operations.py index 0f6c70dbf2b..4b3aaa0b557 100644 --- a/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/operations/_percentile_operations.py +++ b/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/operations/_percentile_operations.py @@ -44,7 +44,7 @@ def build_list_metrics_request( _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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -163,7 +163,7 @@ def extract_data(pipeline_response): list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore - return None, iter(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): _request = prepare_request(next_link) @@ -176,7 +176,11 @@ 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response diff --git a/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/operations/_percentile_source_target_operations.py b/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/operations/_percentile_source_target_operations.py index dab80b177ed..fbf87fc83d8 100644 --- a/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/operations/_percentile_source_target_operations.py +++ b/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/operations/_percentile_source_target_operations.py @@ -51,7 +51,7 @@ def build_list_metrics_request( _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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -186,7 +186,7 @@ def extract_data(pipeline_response): list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore - return None, iter(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): _request = prepare_request(next_link) @@ -199,7 +199,11 @@ 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response diff --git a/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/operations/_percentile_target_operations.py b/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/operations/_percentile_target_operations.py index 2f4c9e7a482..08b8962d17b 100644 --- a/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/operations/_percentile_target_operations.py +++ b/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/operations/_percentile_target_operations.py @@ -44,7 +44,7 @@ def build_list_metrics_request( _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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -168,7 +168,7 @@ def extract_data(pipeline_response): list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore - return None, iter(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): _request = prepare_request(next_link) @@ -181,7 +181,11 @@ 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response diff --git a/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/operations/_private_endpoint_connections_operations.py b/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/operations/_private_endpoint_connections_operations.py index f1fa36bb7a5..f7e3db1139f 100644 --- a/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/operations/_private_endpoint_connections_operations.py +++ b/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/operations/_private_endpoint_connections_operations.py @@ -49,7 +49,7 @@ def build_list_by_database_account_request( _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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -88,7 +88,7 @@ def build_get_request( _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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -130,7 +130,7 @@ def build_create_or_update_request( _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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -175,7 +175,7 @@ def build_delete_request( _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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -291,7 +291,7 @@ def extract_data(pipeline_response): list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore - return None, iter(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): _request = prepare_request(next_link) @@ -304,7 +304,11 @@ 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response @@ -361,7 +365,11 @@ def get( if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + 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) @@ -435,10 +443,15 @@ def _create_or_update_initial( ) 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["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @@ -561,7 +574,9 @@ def get_long_running_output(pipeline_response): return deserialized if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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: @@ -625,10 +640,15 @@ def _delete_initial( ) 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["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @@ -676,7 +696,9 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- return cls(pipeline_response, None, {}) # type: ignore if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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: diff --git a/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/operations/_private_link_resources_operations.py b/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/operations/_private_link_resources_operations.py index e37738b8abf..0df478168f1 100644 --- a/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/operations/_private_link_resources_operations.py +++ b/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/operations/_private_link_resources_operations.py @@ -44,7 +44,7 @@ def build_list_by_database_account_request( _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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -79,7 +79,7 @@ def build_get_request( _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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -192,7 +192,7 @@ def extract_data(pipeline_response): list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore - return None, iter(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): _request = prepare_request(next_link) @@ -205,7 +205,11 @@ 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response @@ -262,7 +266,11 @@ def get( if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + 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) diff --git a/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/operations/_restorable_database_accounts_operations.py b/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/operations/_restorable_database_accounts_operations.py index 235718a0fa9..6a0affde745 100644 --- a/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/operations/_restorable_database_accounts_operations.py +++ b/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/operations/_restorable_database_accounts_operations.py @@ -42,7 +42,7 @@ def build_list_by_location_request(location: str, subscription_id: str, **kwargs _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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -66,19 +66,22 @@ def build_list_by_location_request(location: str, subscription_id: str, **kwargs return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_request(subscription_id: str, **kwargs: Any) -> HttpRequest: +def build_get_by_location_request(location: str, instance_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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( - "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.DocumentDB/restorableDatabaseAccounts" + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.DocumentDB/locations/{location}/restorableDatabaseAccounts/{instanceId}", ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "location": _SERIALIZER.url("location", location, "str"), + "instanceId": _SERIALIZER.url("instance_id", instance_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -92,22 +95,19 @@ def build_list_request(subscription_id: str, **kwargs: Any) -> HttpRequest: return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_get_by_location_request(location: str, instance_id: str, subscription_id: str, **kwargs: Any) -> HttpRequest: +def build_list_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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.DocumentDB/locations/{location}/restorableDatabaseAccounts/{instanceId}", + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.DocumentDB/restorableDatabaseAccounts" ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "location": _SERIALIZER.url("location", location, "str"), - "instanceId": _SERIALIZER.url("instance_id", instance_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -203,7 +203,7 @@ def extract_data(pipeline_response): list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore - return None, iter(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): _request = prepare_request(next_link) @@ -222,6 +222,64 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) + @distributed_trace + def get_by_location( + self, location: str, instance_id: str, **kwargs: Any + ) -> _models.RestorableDatabaseAccountGetResult: + """Retrieves the properties of an existing Azure Cosmos DB restorable database account. This call + requires 'Microsoft.DocumentDB/locations/restorableDatabaseAccounts/read/*' permission. + + :param location: Cosmos DB region, with spaces between words and each word capitalized. + Required. + :type location: str + :param instance_id: The instanceId GUID of a restorable database account. Required. + :type instance_id: str + :return: RestorableDatabaseAccountGetResult or the result of cls(response) + :rtype: ~azure.mgmt.cosmosdb.models.RestorableDatabaseAccountGetResult + :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.RestorableDatabaseAccountGetResult] = kwargs.pop("cls", None) + + _request = build_get_by_location_request( + location=location, + instance_id=instance_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("RestorableDatabaseAccountGetResult", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + @distributed_trace def list(self, **kwargs: Any) -> ItemPaged["_models.RestorableDatabaseAccountGetResult"]: """Lists all the restorable Azure Cosmos DB database accounts available under the subscription. @@ -280,7 +338,7 @@ def extract_data(pipeline_response): list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore - return None, iter(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): _request = prepare_request(next_link) @@ -298,61 +356,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - @distributed_trace - def get_by_location( - self, location: str, instance_id: str, **kwargs: Any - ) -> _models.RestorableDatabaseAccountGetResult: - """Retrieves the properties of an existing Azure Cosmos DB restorable database account. This call - requires 'Microsoft.DocumentDB/locations/restorableDatabaseAccounts/read/*' permission. - - :param location: Cosmos DB region, with spaces between words and each word capitalized. - Required. - :type location: str - :param instance_id: The instanceId GUID of a restorable database account. Required. - :type instance_id: str - :return: RestorableDatabaseAccountGetResult or the result of cls(response) - :rtype: ~azure.mgmt.cosmosdb.models.RestorableDatabaseAccountGetResult - :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.RestorableDatabaseAccountGetResult] = kwargs.pop("cls", None) - - _request = build_get_by_location_request( - location=location, - instance_id=instance_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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("RestorableDatabaseAccountGetResult", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/operations/_restorable_gremlin_databases_operations.py b/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/operations/_restorable_gremlin_databases_operations.py index de38ae7ac72..8a0ffc23b83 100644 --- a/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/operations/_restorable_gremlin_databases_operations.py +++ b/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/operations/_restorable_gremlin_databases_operations.py @@ -42,7 +42,7 @@ def build_list_request(location: str, instance_id: str, subscription_id: str, ** _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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -155,7 +155,7 @@ def extract_data(pipeline_response): list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore - return None, iter(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): _request = prepare_request(next_link) diff --git a/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/operations/_restorable_gremlin_graphs_operations.py b/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/operations/_restorable_gremlin_graphs_operations.py index f563479a398..9c9b1193f85 100644 --- a/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/operations/_restorable_gremlin_graphs_operations.py +++ b/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/operations/_restorable_gremlin_graphs_operations.py @@ -51,7 +51,7 @@ def build_list_request( _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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -187,7 +187,7 @@ def extract_data(pipeline_response): list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore - return None, iter(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): _request = prepare_request(next_link) diff --git a/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/operations/_restorable_gremlin_resources_operations.py b/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/operations/_restorable_gremlin_resources_operations.py index af133c95934..6c3b08705e6 100644 --- a/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/operations/_restorable_gremlin_resources_operations.py +++ b/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/operations/_restorable_gremlin_resources_operations.py @@ -50,7 +50,7 @@ def build_list_request( _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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -182,7 +182,7 @@ def extract_data(pipeline_response): list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore - return None, iter(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): _request = prepare_request(next_link) diff --git a/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/operations/_restorable_mongodb_collections_operations.py b/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/operations/_restorable_mongodb_collections_operations.py index aacf55fc1ad..a9a0f340580 100644 --- a/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/operations/_restorable_mongodb_collections_operations.py +++ b/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/operations/_restorable_mongodb_collections_operations.py @@ -51,7 +51,7 @@ def build_list_request( _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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -187,7 +187,7 @@ def extract_data(pipeline_response): list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore - return None, iter(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): _request = prepare_request(next_link) diff --git a/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/operations/_restorable_mongodb_databases_operations.py b/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/operations/_restorable_mongodb_databases_operations.py index f4bd52858a3..1197975e997 100644 --- a/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/operations/_restorable_mongodb_databases_operations.py +++ b/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/operations/_restorable_mongodb_databases_operations.py @@ -42,7 +42,7 @@ def build_list_request(location: str, instance_id: str, subscription_id: str, ** _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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -155,7 +155,7 @@ def extract_data(pipeline_response): list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore - return None, iter(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): _request = prepare_request(next_link) diff --git a/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/operations/_restorable_mongodb_resources_operations.py b/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/operations/_restorable_mongodb_resources_operations.py index 6286fd34011..5668ea69650 100644 --- a/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/operations/_restorable_mongodb_resources_operations.py +++ b/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/operations/_restorable_mongodb_resources_operations.py @@ -50,7 +50,7 @@ def build_list_request( _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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -182,7 +182,7 @@ def extract_data(pipeline_response): list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore - return None, iter(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): _request = prepare_request(next_link) diff --git a/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/operations/_restorable_sql_containers_operations.py b/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/operations/_restorable_sql_containers_operations.py index 72799d55c07..ac50717b501 100644 --- a/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/operations/_restorable_sql_containers_operations.py +++ b/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/operations/_restorable_sql_containers_operations.py @@ -51,7 +51,7 @@ def build_list_request( _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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -186,7 +186,7 @@ def extract_data(pipeline_response): list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore - return None, iter(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): _request = prepare_request(next_link) diff --git a/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/operations/_restorable_sql_databases_operations.py b/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/operations/_restorable_sql_databases_operations.py index eca1461f707..2ae22228b26 100644 --- a/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/operations/_restorable_sql_databases_operations.py +++ b/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/operations/_restorable_sql_databases_operations.py @@ -42,7 +42,7 @@ def build_list_request(location: str, instance_id: str, subscription_id: str, ** _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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -155,7 +155,7 @@ def extract_data(pipeline_response): list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore - return None, iter(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): _request = prepare_request(next_link) diff --git a/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/operations/_restorable_sql_resources_operations.py b/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/operations/_restorable_sql_resources_operations.py index d1388c56a97..bb1cb0232d8 100644 --- a/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/operations/_restorable_sql_resources_operations.py +++ b/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/operations/_restorable_sql_resources_operations.py @@ -50,7 +50,7 @@ def build_list_request( _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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -182,7 +182,7 @@ def extract_data(pipeline_response): list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore - return None, iter(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): _request = prepare_request(next_link) diff --git a/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/operations/_restorable_table_resources_operations.py b/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/operations/_restorable_table_resources_operations.py index bc1512de288..a7af4e50d4a 100644 --- a/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/operations/_restorable_table_resources_operations.py +++ b/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/operations/_restorable_table_resources_operations.py @@ -50,7 +50,7 @@ def build_list_request( _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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -181,7 +181,7 @@ def extract_data(pipeline_response): list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore - return None, iter(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): _request = prepare_request(next_link) diff --git a/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/operations/_restorable_tables_operations.py b/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/operations/_restorable_tables_operations.py index 517619d45e9..e40f9f186ee 100644 --- a/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/operations/_restorable_tables_operations.py +++ b/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/operations/_restorable_tables_operations.py @@ -50,7 +50,7 @@ def build_list_request( _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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -176,7 +176,7 @@ def extract_data(pipeline_response): list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore - return None, iter(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): _request = prepare_request(next_link) diff --git a/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/operations/_service_operations.py b/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/operations/_service_operations.py index 5e9908b5f2b..317c414804b 100644 --- a/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/operations/_service_operations.py +++ b/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/operations/_service_operations.py @@ -47,7 +47,7 @@ def build_list_request(resource_group_name: str, account_name: str, subscription _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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -76,14 +76,13 @@ def build_list_request(resource_group_name: str, account_name: str, subscription return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_request( +def build_get_request( resource_group_name: str, account_name: str, service_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-11-01-preview")) - 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-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -108,20 +107,19 @@ def build_create_request( _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) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_get_request( +def build_create_request( resource_group_name: str, account_name: str, service_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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -146,9 +144,11 @@ def build_get_request( _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="GET", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_request( @@ -157,7 +157,7 @@ def build_delete_request( _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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -268,7 +268,7 @@ def extract_data(pipeline_response): list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore - return None, iter(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): _request = prepare_request(next_link) @@ -287,6 +287,66 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) + @distributed_trace + def get( + self, resource_group_name: str, account_name: str, service_name: str, **kwargs: Any + ) -> _models.ServiceResource: + """Gets the status of service. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param service_name: Cosmos DB service name. Required. + :type service_name: str + :return: ServiceResource or the result of cls(response) + :rtype: ~azure.mgmt.cosmosdb.models.ServiceResource + :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.ServiceResource] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + account_name=account_name, + service_name=service_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ServiceResource", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + def _create_initial( self, resource_group_name: str, @@ -348,10 +408,15 @@ def _create_initial( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @@ -477,7 +542,9 @@ def get_long_running_output(pipeline_response): return deserialized if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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: @@ -493,66 +560,6 @@ def get_long_running_output(pipeline_response): self._client, raw_result, get_long_running_output, polling_method # type: ignore ) - @distributed_trace - def get( - self, resource_group_name: str, account_name: str, service_name: str, **kwargs: Any - ) -> _models.ServiceResource: - """Gets the status of service. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param account_name: Cosmos DB database account name. Required. - :type account_name: str - :param service_name: Cosmos DB service name. Required. - :type service_name: str - :return: ServiceResource or the result of cls(response) - :rtype: ~azure.mgmt.cosmosdb.models.ServiceResource - :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.ServiceResource] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - account_name=account_name, - service_name=service_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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("ServiceResource", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - def _delete_initial( self, resource_group_name: str, account_name: str, service_name: str, **kwargs: Any ) -> Iterator[bytes]: @@ -599,10 +606,10 @@ def _delete_initial( response_headers = {} if response.status_code == 202: - response_headers["azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("azure-AsyncOperation") + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") ) - response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) @@ -655,7 +662,9 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- return cls(pipeline_response, None, {}) # type: ignore if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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: diff --git a/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/operations/_soft_deleted_database_accounts_operations.py b/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/operations/_soft_deleted_database_accounts_operations.py new file mode 100644 index 00000000000..2ec5abd030f --- /dev/null +++ b/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/operations/_soft_deleted_database_accounts_operations.py @@ -0,0 +1,761 @@ +# 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 CosmosDBManagementClientConfiguration +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_location_request(location: 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-04-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.DocumentDB/locations/{location}/softDeletedDatabaseAccounts", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "location": _SERIALIZER.url("location", location, "str", 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_resource_group_and_location_request( # pylint: disable=name-too-long + resource_group_name: str, location: 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-04-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/locations/{location}/softDeletedDatabaseAccounts", + ) + 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 + ), + "location": _SERIALIZER.url("location", location, "str", 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_get_request( + resource_group_name: str, location: str, account_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-04-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/locations/{location}/softDeletedDatabaseAccounts/{accountName}", + ) + 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 + ), + "location": _SERIALIZER.url("location", location, "str", min_length=1), + "accountName": _SERIALIZER.url( + "account_name", account_name, "str", max_length=50, min_length=3, pattern=r"^[a-z0-9]+(-[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_purge_request( + resource_group_name: str, + location: str, + account_name: str, + subscription_id: str, + *, + soft_delete_action_kind: Optional[Union[str, _models.SoftDeleteActionKind]] = 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-04-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/locations/{location}/softDeletedDatabaseAccounts/{accountName}", + ) + 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 + ), + "location": _SERIALIZER.url("location", location, "str", min_length=1), + "accountName": _SERIALIZER.url( + "account_name", account_name, "str", max_length=50, min_length=3, pattern=r"^[a-z0-9]+(-[a-z0-9]+)*" + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if soft_delete_action_kind is not None: + _params["softDeleteActionKind"] = _SERIALIZER.query("soft_delete_action_kind", soft_delete_action_kind, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_restore_request( + resource_group_name: str, + location: str, + account_name: str, + subscription_id: str, + *, + soft_delete_action_kind: Optional[Union[str, _models.SoftDeleteActionKind]] = 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-04-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/locations/{location}/softDeletedDatabaseAccounts/{accountName}", + ) + 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 + ), + "location": _SERIALIZER.url("location", location, "str", min_length=1), + "accountName": _SERIALIZER.url( + "account_name", account_name, "str", max_length=50, min_length=3, pattern=r"^[a-z0-9]+(-[a-z0-9]+)*" + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if soft_delete_action_kind is not None: + _params["softDeleteActionKind"] = _SERIALIZER.query("soft_delete_action_kind", soft_delete_action_kind, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +class SoftDeletedDatabaseAccountsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.cosmosdb.CosmosDBManagementClient`'s + :attr:`soft_deleted_database_accounts` 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: CosmosDBManagementClientConfiguration = 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_location( + self, location: str, **kwargs: Any + ) -> ItemPaged["_models.SoftDeletedDatabaseAccountGetResult"]: + """Lists all the soft-deleted Azure Cosmos DB database accounts available under the subscription + and in a region. This call requires + 'Microsoft.DocumentDB/locations/softDeletedDatabaseAccounts/read' permission. + + :param location: The name of the Azure region. Required. + :type location: str + :return: An iterator like instance of either SoftDeletedDatabaseAccountGetResult or the result + of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.cosmosdb.models.SoftDeletedDatabaseAccountGetResult] + :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.SoftDeletedDatabaseAccountsListResult] = 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_location_request( + location=location, + 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("SoftDeletedDatabaseAccountsListResult", 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_resource_group_and_location( + self, resource_group_name: str, location: str, **kwargs: Any + ) -> ItemPaged["_models.SoftDeletedDatabaseAccountGetResult"]: + """Lists all the soft-deleted Azure Cosmos DB database accounts available under the given resource + group and in a region. This call requires + 'Microsoft.DocumentDB/locations/softDeletedDatabaseAccounts/read' permission. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param location: The name of the Azure region. Required. + :type location: str + :return: An iterator like instance of either SoftDeletedDatabaseAccountGetResult or the result + of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.cosmosdb.models.SoftDeletedDatabaseAccountGetResult] + :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.SoftDeletedDatabaseAccountsListResult] = 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_and_location_request( + resource_group_name=resource_group_name, + location=location, + 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("SoftDeletedDatabaseAccountsListResult", 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, location: str, account_name: str, **kwargs: Any + ) -> _models.SoftDeletedDatabaseAccountGetResult: + """Retrieves the properties of a soft-deleted Azure Cosmos DB database account by location and + accountName. This call requires + 'Microsoft.DocumentDB/locations/softDeletedDatabaseAccounts/read' permission. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param location: The name of the Azure region. Required. + :type location: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :return: SoftDeletedDatabaseAccountGetResult or the result of cls(response) + :rtype: ~azure.mgmt.cosmosdb.models.SoftDeletedDatabaseAccountGetResult + :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.SoftDeletedDatabaseAccountGetResult] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + location=location, + account_name=account_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("SoftDeletedDatabaseAccountGetResult", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + def _purge_initial( + self, + resource_group_name: str, + location: str, + account_name: str, + soft_delete_action_kind: Optional[Union[str, _models.SoftDeleteActionKind]] = 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 = 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_purge_request( + resource_group_name=resource_group_name, + location=location, + account_name=account_name, + subscription_id=self._config.subscription_id, + soft_delete_action_kind=soft_delete_action_kind, + 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["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + 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_purge( + self, + resource_group_name: str, + location: str, + account_name: str, + soft_delete_action_kind: Optional[Union[str, _models.SoftDeleteActionKind]] = None, + **kwargs: Any + ) -> LROPoller[None]: + """Permanently deletes (purges) a soft-deleted Azure Cosmos DB database account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param location: The name of the Azure region. Required. + :type location: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param soft_delete_action_kind: The kind of soft delete action to perform. Known values are: + "RestoreSoftDeletedResource" and "PermanentDeleteResource". Default value is None. + :type soft_delete_action_kind: str or ~azure.mgmt.cosmosdb.models.SoftDeleteActionKind + :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._purge_initial( + resource_group_name=resource_group_name, + location=location, + account_name=account_name, + soft_delete_action_kind=soft_delete_action_kind, + 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 _restore_initial( + self, + resource_group_name: str, + location: str, + account_name: str, + soft_delete_action_kind: Optional[Union[str, _models.SoftDeleteActionKind]] = 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 = 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_restore_request( + resource_group_name=resource_group_name, + location=location, + account_name=account_name, + subscription_id=self._config.subscription_id, + soft_delete_action_kind=soft_delete_action_kind, + 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["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + 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_restore( + self, + resource_group_name: str, + location: str, + account_name: str, + soft_delete_action_kind: Optional[Union[str, _models.SoftDeleteActionKind]] = None, + **kwargs: Any + ) -> LROPoller[None]: + """Restores a soft-deleted Azure Cosmos DB database account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param location: The name of the Azure region. Required. + :type location: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param soft_delete_action_kind: The kind of soft delete action to perform. Known values are: + "RestoreSoftDeletedResource" and "PermanentDeleteResource". Default value is None. + :type soft_delete_action_kind: str or ~azure.mgmt.cosmosdb.models.SoftDeleteActionKind + :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._restore_initial( + resource_group_name=resource_group_name, + location=location, + account_name=account_name, + soft_delete_action_kind=soft_delete_action_kind, + 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/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/operations/_soft_deleted_sql_containers_operations.py b/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/operations/_soft_deleted_sql_containers_operations.py new file mode 100644 index 00000000000..4a83a800504 --- /dev/null +++ b/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/operations/_soft_deleted_sql_containers_operations.py @@ -0,0 +1,709 @@ +# 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 CosmosDBManagementClientConfiguration +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, location: str, account_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-04-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/locations/{location}/softDeletedDatabaseAccounts/{accountName}/softDeletedSqlDatabases/{databaseName}/softDeletedSqlContainers", + ) + 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 + ), + "location": _SERIALIZER.url("location", location, "str", min_length=1), + "accountName": _SERIALIZER.url( + "account_name", account_name, "str", max_length=50, min_length=3, pattern=r"^[a-z0-9]+(-[a-z0-9]+)*" + ), + "databaseName": _SERIALIZER.url("database_name", database_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) + + +def build_get_request( + resource_group_name: str, + location: str, + account_name: str, + database_name: str, + container_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-04-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/locations/{location}/softDeletedDatabaseAccounts/{accountName}/softDeletedSqlDatabases/{databaseName}/softDeletedSqlContainers/{containerName}", + ) + 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 + ), + "location": _SERIALIZER.url("location", location, "str", min_length=1), + "accountName": _SERIALIZER.url( + "account_name", account_name, "str", max_length=50, min_length=3, pattern=r"^[a-z0-9]+(-[a-z0-9]+)*" + ), + "databaseName": _SERIALIZER.url("database_name", database_name, "str", pattern=r"^[^/\\#?]+$"), + "containerName": _SERIALIZER.url("container_name", container_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) + + +def build_purge_request( + resource_group_name: str, + location: str, + account_name: str, + database_name: str, + container_name: str, + subscription_id: str, + *, + soft_delete_action_kind: Optional[Union[str, _models.SoftDeleteActionKind]] = 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-04-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/locations/{location}/softDeletedDatabaseAccounts/{accountName}/softDeletedSqlDatabases/{databaseName}/softDeletedSqlContainers/{containerName}", + ) + 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 + ), + "location": _SERIALIZER.url("location", location, "str", min_length=1), + "accountName": _SERIALIZER.url( + "account_name", account_name, "str", max_length=50, min_length=3, pattern=r"^[a-z0-9]+(-[a-z0-9]+)*" + ), + "databaseName": _SERIALIZER.url("database_name", database_name, "str", pattern=r"^[^/\\#?]+$"), + "containerName": _SERIALIZER.url("container_name", container_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") + if soft_delete_action_kind is not None: + _params["softDeleteActionKind"] = _SERIALIZER.query("soft_delete_action_kind", soft_delete_action_kind, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_restore_request( + resource_group_name: str, + location: str, + account_name: str, + database_name: str, + container_name: str, + subscription_id: str, + *, + soft_delete_action_kind: Optional[Union[str, _models.SoftDeleteActionKind]] = 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-04-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/locations/{location}/softDeletedDatabaseAccounts/{accountName}/softDeletedSqlDatabases/{databaseName}/softDeletedSqlContainers/{containerName}", + ) + 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 + ), + "location": _SERIALIZER.url("location", location, "str", min_length=1), + "accountName": _SERIALIZER.url( + "account_name", account_name, "str", max_length=50, min_length=3, pattern=r"^[a-z0-9]+(-[a-z0-9]+)*" + ), + "databaseName": _SERIALIZER.url("database_name", database_name, "str", pattern=r"^[^/\\#?]+$"), + "containerName": _SERIALIZER.url("container_name", container_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") + if soft_delete_action_kind is not None: + _params["softDeleteActionKind"] = _SERIALIZER.query("soft_delete_action_kind", soft_delete_action_kind, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +class SoftDeletedSqlContainersOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.cosmosdb.CosmosDBManagementClient`'s + :attr:`soft_deleted_sql_containers` 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: CosmosDBManagementClientConfiguration = 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, location: str, account_name: str, database_name: str, **kwargs: Any + ) -> ItemPaged["_models.SoftDeletedSqlContainerGetResult"]: + """Lists all the soft-deleted Azure Cosmos DB SQL containers under a soft-deleted SQL database. + This call requires + 'Microsoft.DocumentDB/locations/softDeletedDatabaseAccounts/softDeletedSqlDatabases/softDeletedSqlContainers/read' + permission. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param location: The name of the Azure region. Required. + :type location: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param database_name: Cosmos DB SQL database name. Required. + :type database_name: str + :return: An iterator like instance of either SoftDeletedSqlContainerGetResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.cosmosdb.models.SoftDeletedSqlContainerGetResult] + :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.SoftDeletedSqlContainersListResult] = 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, + location=location, + account_name=account_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) + + 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("SoftDeletedSqlContainersListResult", 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, + location: str, + account_name: str, + database_name: str, + container_name: str, + **kwargs: Any + ) -> _models.SoftDeletedSqlContainerGetResult: + """Retrieves the properties of a soft-deleted Azure Cosmos DB SQL container. This call requires + 'Microsoft.DocumentDB/locations/softDeletedDatabaseAccounts/softDeletedSqlDatabases/softDeletedSqlContainers/read' + permission. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param location: The name of the Azure region. Required. + :type location: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param database_name: Cosmos DB SQL database name. Required. + :type database_name: str + :param container_name: Cosmos DB SQL container name. Required. + :type container_name: str + :return: SoftDeletedSqlContainerGetResult or the result of cls(response) + :rtype: ~azure.mgmt.cosmosdb.models.SoftDeletedSqlContainerGetResult + :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.SoftDeletedSqlContainerGetResult] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + location=location, + account_name=account_name, + database_name=database_name, + container_name=container_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("SoftDeletedSqlContainerGetResult", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + def _purge_initial( + self, + resource_group_name: str, + location: str, + account_name: str, + database_name: str, + container_name: str, + soft_delete_action_kind: Optional[Union[str, _models.SoftDeleteActionKind]] = 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 = 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_purge_request( + resource_group_name=resource_group_name, + location=location, + account_name=account_name, + database_name=database_name, + container_name=container_name, + subscription_id=self._config.subscription_id, + soft_delete_action_kind=soft_delete_action_kind, + 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["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + 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_purge( + self, + resource_group_name: str, + location: str, + account_name: str, + database_name: str, + container_name: str, + soft_delete_action_kind: Optional[Union[str, _models.SoftDeleteActionKind]] = None, + **kwargs: Any + ) -> LROPoller[None]: + """Permanently deletes a soft-deleted Azure Cosmos DB SQL container. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param location: The name of the Azure region. Required. + :type location: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param database_name: Cosmos DB SQL database name. Required. + :type database_name: str + :param container_name: Cosmos DB SQL container name. Required. + :type container_name: str + :param soft_delete_action_kind: The kind of soft delete action to perform. Known values are: + "RestoreSoftDeletedResource" and "PermanentDeleteResource". Default value is None. + :type soft_delete_action_kind: str or ~azure.mgmt.cosmosdb.models.SoftDeleteActionKind + :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._purge_initial( + resource_group_name=resource_group_name, + location=location, + account_name=account_name, + database_name=database_name, + container_name=container_name, + soft_delete_action_kind=soft_delete_action_kind, + 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 _restore_initial( + self, + resource_group_name: str, + location: str, + account_name: str, + database_name: str, + container_name: str, + soft_delete_action_kind: Optional[Union[str, _models.SoftDeleteActionKind]] = 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 = 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_restore_request( + resource_group_name=resource_group_name, + location=location, + account_name=account_name, + database_name=database_name, + container_name=container_name, + subscription_id=self._config.subscription_id, + soft_delete_action_kind=soft_delete_action_kind, + 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["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + 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_restore( + self, + resource_group_name: str, + location: str, + account_name: str, + database_name: str, + container_name: str, + soft_delete_action_kind: Optional[Union[str, _models.SoftDeleteActionKind]] = None, + **kwargs: Any + ) -> LROPoller[None]: + """Restores a soft-deleted Azure Cosmos DB SQL container to active state. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param location: The name of the Azure region. Required. + :type location: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param database_name: Cosmos DB SQL database name. Required. + :type database_name: str + :param container_name: Cosmos DB SQL container name. Required. + :type container_name: str + :param soft_delete_action_kind: The kind of soft delete action to perform. Known values are: + "RestoreSoftDeletedResource" and "PermanentDeleteResource". Default value is None. + :type soft_delete_action_kind: str or ~azure.mgmt.cosmosdb.models.SoftDeleteActionKind + :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._restore_initial( + resource_group_name=resource_group_name, + location=location, + account_name=account_name, + database_name=database_name, + container_name=container_name, + soft_delete_action_kind=soft_delete_action_kind, + 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/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/operations/_soft_deleted_sql_databases_operations.py b/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/operations/_soft_deleted_sql_databases_operations.py new file mode 100644 index 00000000000..ade1a287f98 --- /dev/null +++ b/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/operations/_soft_deleted_sql_databases_operations.py @@ -0,0 +1,673 @@ +# 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 CosmosDBManagementClientConfiguration +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, location: str, account_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-04-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/locations/{location}/softDeletedDatabaseAccounts/{accountName}/softDeletedSqlDatabases", + ) + 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 + ), + "location": _SERIALIZER.url("location", location, "str", min_length=1), + "accountName": _SERIALIZER.url( + "account_name", account_name, "str", max_length=50, min_length=3, pattern=r"^[a-z0-9]+(-[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_get_request( + resource_group_name: str, location: str, account_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-04-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/locations/{location}/softDeletedDatabaseAccounts/{accountName}/softDeletedSqlDatabases/{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 + ), + "location": _SERIALIZER.url("location", location, "str", min_length=1), + "accountName": _SERIALIZER.url( + "account_name", account_name, "str", max_length=50, min_length=3, pattern=r"^[a-z0-9]+(-[a-z0-9]+)*" + ), + "databaseName": _SERIALIZER.url("database_name", database_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) + + +def build_purge_request( + resource_group_name: str, + location: str, + account_name: str, + database_name: str, + subscription_id: str, + *, + soft_delete_action_kind: Optional[Union[str, _models.SoftDeleteActionKind]] = 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-04-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/locations/{location}/softDeletedDatabaseAccounts/{accountName}/softDeletedSqlDatabases/{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 + ), + "location": _SERIALIZER.url("location", location, "str", min_length=1), + "accountName": _SERIALIZER.url( + "account_name", account_name, "str", max_length=50, min_length=3, pattern=r"^[a-z0-9]+(-[a-z0-9]+)*" + ), + "databaseName": _SERIALIZER.url("database_name", database_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") + if soft_delete_action_kind is not None: + _params["softDeleteActionKind"] = _SERIALIZER.query("soft_delete_action_kind", soft_delete_action_kind, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_restore_request( + resource_group_name: str, + location: str, + account_name: str, + database_name: str, + subscription_id: str, + *, + soft_delete_action_kind: Optional[Union[str, _models.SoftDeleteActionKind]] = 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-04-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/locations/{location}/softDeletedDatabaseAccounts/{accountName}/softDeletedSqlDatabases/{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 + ), + "location": _SERIALIZER.url("location", location, "str", min_length=1), + "accountName": _SERIALIZER.url( + "account_name", account_name, "str", max_length=50, min_length=3, pattern=r"^[a-z0-9]+(-[a-z0-9]+)*" + ), + "databaseName": _SERIALIZER.url("database_name", database_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") + if soft_delete_action_kind is not None: + _params["softDeleteActionKind"] = _SERIALIZER.query("soft_delete_action_kind", soft_delete_action_kind, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +class SoftDeletedSqlDatabasesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.cosmosdb.CosmosDBManagementClient`'s + :attr:`soft_deleted_sql_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: CosmosDBManagementClientConfiguration = 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, location: str, account_name: str, **kwargs: Any + ) -> ItemPaged["_models.SoftDeletedSqlDatabaseGetResult"]: + """Lists all the soft-deleted Azure Cosmos DB SQL databases under a soft-deleted database account. + This call requires + 'Microsoft.DocumentDB/locations/softDeletedDatabaseAccounts/softDeletedSqlDatabases/read' + permission. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param location: The name of the Azure region. Required. + :type location: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :return: An iterator like instance of either SoftDeletedSqlDatabaseGetResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.cosmosdb.models.SoftDeletedSqlDatabaseGetResult] + :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.SoftDeletedSqlDatabasesListResult] = 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, + location=location, + account_name=account_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("SoftDeletedSqlDatabasesListResult", 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, location: str, account_name: str, database_name: str, **kwargs: Any + ) -> _models.SoftDeletedSqlDatabaseGetResult: + """Retrieves the properties of a soft-deleted Azure Cosmos DB SQL database. This call requires + 'Microsoft.DocumentDB/locations/softDeletedDatabaseAccounts/softDeletedSqlDatabases/read' + permission. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param location: The name of the Azure region. Required. + :type location: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param database_name: Cosmos DB SQL database name. Required. + :type database_name: str + :return: SoftDeletedSqlDatabaseGetResult or the result of cls(response) + :rtype: ~azure.mgmt.cosmosdb.models.SoftDeletedSqlDatabaseGetResult + :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.SoftDeletedSqlDatabaseGetResult] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + location=location, + account_name=account_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("SoftDeletedSqlDatabaseGetResult", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + def _purge_initial( + self, + resource_group_name: str, + location: str, + account_name: str, + database_name: str, + soft_delete_action_kind: Optional[Union[str, _models.SoftDeleteActionKind]] = 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 = 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_purge_request( + resource_group_name=resource_group_name, + location=location, + account_name=account_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + soft_delete_action_kind=soft_delete_action_kind, + 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["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + 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_purge( + self, + resource_group_name: str, + location: str, + account_name: str, + database_name: str, + soft_delete_action_kind: Optional[Union[str, _models.SoftDeleteActionKind]] = None, + **kwargs: Any + ) -> LROPoller[None]: + """Permanently deletes a soft-deleted Azure Cosmos DB SQL database. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param location: The name of the Azure region. Required. + :type location: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param database_name: Cosmos DB SQL database name. Required. + :type database_name: str + :param soft_delete_action_kind: The kind of soft delete action to perform. Known values are: + "RestoreSoftDeletedResource" and "PermanentDeleteResource". Default value is None. + :type soft_delete_action_kind: str or ~azure.mgmt.cosmosdb.models.SoftDeleteActionKind + :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._purge_initial( + resource_group_name=resource_group_name, + location=location, + account_name=account_name, + database_name=database_name, + soft_delete_action_kind=soft_delete_action_kind, + 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 _restore_initial( + self, + resource_group_name: str, + location: str, + account_name: str, + database_name: str, + soft_delete_action_kind: Optional[Union[str, _models.SoftDeleteActionKind]] = 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 = 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_restore_request( + resource_group_name=resource_group_name, + location=location, + account_name=account_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + soft_delete_action_kind=soft_delete_action_kind, + 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["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + 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_restore( + self, + resource_group_name: str, + location: str, + account_name: str, + database_name: str, + soft_delete_action_kind: Optional[Union[str, _models.SoftDeleteActionKind]] = None, + **kwargs: Any + ) -> LROPoller[None]: + """Restores a soft-deleted Azure Cosmos DB SQL database. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param location: The name of the Azure region. Required. + :type location: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param database_name: Cosmos DB SQL database name. Required. + :type database_name: str + :param soft_delete_action_kind: The kind of soft delete action to perform. Known values are: + "RestoreSoftDeletedResource" and "PermanentDeleteResource". Default value is None. + :type soft_delete_action_kind: str or ~azure.mgmt.cosmosdb.models.SoftDeleteActionKind + :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._restore_initial( + resource_group_name=resource_group_name, + location=location, + account_name=account_name, + database_name=database_name, + soft_delete_action_kind=soft_delete_action_kind, + 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/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/operations/_sql_resources_operations.py b/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/operations/_sql_resources_operations.py index f809a45056b..ffb0dcf3fb9 100644 --- a/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/operations/_sql_resources_operations.py +++ b/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/operations/_sql_resources_operations.py @@ -49,7 +49,7 @@ def build_list_sql_databases_request( _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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -84,7 +84,7 @@ def build_get_sql_database_request( _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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -120,7 +120,7 @@ def build_create_update_sql_database_request( _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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -156,9 +156,12 @@ def build_create_update_sql_database_request( def build_delete_sql_database_request( resource_group_name: str, account_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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop( "template_url", @@ -180,22 +183,25 @@ def build_delete_sql_database_request( # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) -def build_get_sql_database_throughput_request( # pylint: disable=name-too-long +def build_list_client_encryption_keys_request( # pylint: disable=name-too-long resource_group_name: str, account_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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/throughputSettings/default", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/clientEncryptionKeys", ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), @@ -219,20 +225,24 @@ def build_get_sql_database_throughput_request( # pylint: disable=name-too-long return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_update_sql_database_throughput_request( # pylint: disable=name-too-long - resource_group_name: str, account_name: str, database_name: str, subscription_id: str, **kwargs: Any +def build_get_client_encryption_key_request( + resource_group_name: str, + account_name: str, + database_name: str, + client_encryption_key_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-11-01-preview")) - 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-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/throughputSettings/default", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/clientEncryptionKeys/{clientEncryptionKeyName}", ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), @@ -243,6 +253,7 @@ def build_update_sql_database_throughput_request( # pylint: disable=name-too-lo "account_name", account_name, "str", max_length=50, min_length=3, pattern=r"^[a-z0-9]+(-[a-z0-9]+)*" ), "databaseName": _SERIALIZER.url("database_name", database_name, "str"), + "clientEncryptionKeyName": _SERIALIZER.url("client_encryption_key_name", client_encryption_key_name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -251,26 +262,30 @@ def build_update_sql_database_throughput_request( # pylint: disable=name-too-lo _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) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_migrate_sql_database_to_autoscale_request( # pylint: disable=name-too-long - resource_group_name: str, account_name: str, database_name: str, subscription_id: str, **kwargs: Any +def build_create_update_client_encryption_key_request( # pylint: disable=name-too-long + resource_group_name: str, + account_name: str, + database_name: str, + client_encryption_key_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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) + 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.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/throughputSettings/default/migrateToAutoscale", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/clientEncryptionKeys/{clientEncryptionKeyName}", ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), @@ -281,6 +296,7 @@ def build_migrate_sql_database_to_autoscale_request( # pylint: disable=name-too "account_name", account_name, "str", max_length=50, min_length=3, pattern=r"^[a-z0-9]+(-[a-z0-9]+)*" ), "databaseName": _SERIALIZER.url("database_name", database_name, "str"), + "clientEncryptionKeyName": _SERIALIZER.url("client_encryption_key_name", client_encryption_key_name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -289,24 +305,26 @@ def build_migrate_sql_database_to_autoscale_request( # pylint: disable=name-too _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) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_migrate_sql_database_to_manual_throughput_request( # pylint: disable=name-too-long +def build_list_sql_containers_request( resource_group_name: str, account_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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/throughputSettings/default/migrateToManualThroughput", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers", ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), @@ -327,22 +345,27 @@ def build_migrate_sql_database_to_manual_throughput_request( # pylint: disable= # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_client_encryption_keys_request( # pylint: disable=name-too-long - resource_group_name: str, account_name: str, database_name: str, subscription_id: str, **kwargs: Any +def build_get_sql_container_request( + resource_group_name: str, + account_name: str, + database_name: str, + container_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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/clientEncryptionKeys", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}", ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), @@ -353,6 +376,7 @@ def build_list_client_encryption_keys_request( # pylint: disable=name-too-long "account_name", account_name, "str", max_length=50, min_length=3, pattern=r"^[a-z0-9]+(-[a-z0-9]+)*" ), "databaseName": _SERIALIZER.url("database_name", database_name, "str"), + "containerName": _SERIALIZER.url("container_name", container_name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -366,24 +390,25 @@ def build_list_client_encryption_keys_request( # pylint: disable=name-too-long return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_get_client_encryption_key_request( +def build_create_update_sql_container_request( # pylint: disable=name-too-long resource_group_name: str, account_name: str, database_name: str, - client_encryption_key_name: str, + container_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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) + 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.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/clientEncryptionKeys/{clientEncryptionKeyName}", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}", ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), @@ -394,7 +419,7 @@ def build_get_client_encryption_key_request( "account_name", account_name, "str", max_length=50, min_length=3, pattern=r"^[a-z0-9]+(-[a-z0-9]+)*" ), "databaseName": _SERIALIZER.url("database_name", database_name, "str"), - "clientEncryptionKeyName": _SERIALIZER.url("client_encryption_key_name", client_encryption_key_name, "str"), + "containerName": _SERIALIZER.url("container_name", container_name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -403,30 +428,31 @@ def build_get_client_encryption_key_request( _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="GET", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_update_client_encryption_key_request( # pylint: disable=name-too-long +def build_delete_sql_container_request( resource_group_name: str, account_name: str, database_name: str, - client_encryption_key_name: str, + container_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-11-01-preview")) - 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-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/clientEncryptionKeys/{clientEncryptionKeyName}", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}", ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), @@ -437,7 +463,7 @@ def build_create_update_client_encryption_key_request( # pylint: disable=name-t "account_name", account_name, "str", max_length=50, min_length=3, pattern=r"^[a-z0-9]+(-[a-z0-9]+)*" ), "databaseName": _SERIALIZER.url("database_name", database_name, "str"), - "clientEncryptionKeyName": _SERIALIZER.url("client_encryption_key_name", client_encryption_key_name, "str"), + "containerName": _SERIALIZER.url("container_name", container_name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -446,26 +472,30 @@ def build_create_update_client_encryption_key_request( # pylint: disable=name-t _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) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_sql_containers_request( - resource_group_name: str, account_name: str, database_name: str, subscription_id: str, **kwargs: Any +def build_list_sql_container_partition_merge_request( # pylint: disable=name-too-long + resource_group_name: str, + account_name: str, + database_name: str, + container_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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) + 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.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}/partitionMerge", ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), @@ -476,6 +506,7 @@ def build_list_sql_containers_request( "account_name", account_name, "str", max_length=50, min_length=3, pattern=r"^[a-z0-9]+(-[a-z0-9]+)*" ), "databaseName": _SERIALIZER.url("database_name", database_name, "str"), + "containerName": _SERIALIZER.url("container_name", container_name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -484,12 +515,14 @@ def build_list_sql_containers_request( _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="GET", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_get_sql_container_request( +def build_retrieve_continuous_backup_information_request( # pylint: disable=name-too-long resource_group_name: str, account_name: str, database_name: str, @@ -500,13 +533,14 @@ def build_get_sql_container_request( _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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) + 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.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}/retrieveContinuousBackupInformation", ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), @@ -526,12 +560,14 @@ def build_get_sql_container_request( _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="GET", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_update_sql_container_request( # pylint: disable=name-too-long +def build_list_sql_stored_procedures_request( resource_group_name: str, account_name: str, database_name: str, @@ -542,14 +578,13 @@ def build_create_update_sql_container_request( # 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", "2025-11-01-preview")) - 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-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}/storedProcedures", ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), @@ -569,28 +604,30 @@ def build_create_update_sql_container_request( # pylint: disable=name-too-long _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) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_delete_sql_container_request( +def build_get_sql_stored_procedure_request( resource_group_name: str, account_name: str, database_name: str, container_name: str, + stored_procedure_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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}/storedProcedures/{storedProcedureName}", ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), @@ -602,6 +639,7 @@ def build_delete_sql_container_request( ), "databaseName": _SERIALIZER.url("database_name", database_name, "str"), "containerName": _SERIALIZER.url("container_name", container_name, "str"), + "storedProcedureName": _SERIALIZER.url("stored_procedure_name", stored_procedure_name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -609,23 +647,32 @@ def build_delete_sql_container_request( # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_sql_database_partition_merge_request( # pylint: disable=name-too-long - resource_group_name: str, account_name: str, database_name: str, subscription_id: str, **kwargs: Any +def build_create_update_sql_stored_procedure_request( # pylint: disable=name-too-long + resource_group_name: str, + account_name: str, + database_name: str, + container_name: str, + stored_procedure_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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) 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.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/partitionMerge", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}/storedProcedures/{storedProcedureName}", ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), @@ -636,6 +683,8 @@ def build_sql_database_partition_merge_request( # pylint: disable=name-too-long "account_name", account_name, "str", max_length=50, min_length=3, pattern=r"^[a-z0-9]+(-[a-z0-9]+)*" ), "databaseName": _SERIALIZER.url("database_name", database_name, "str"), + "containerName": _SERIALIZER.url("container_name", container_name, "str"), + "storedProcedureName": _SERIALIZER.url("stored_procedure_name", stored_procedure_name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -648,28 +697,28 @@ def build_sql_database_partition_merge_request( # pylint: disable=name-too-long _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) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_sql_container_partition_merge_request( # pylint: disable=name-too-long +def build_delete_sql_stored_procedure_request( # pylint: disable=name-too-long resource_group_name: str, account_name: str, database_name: str, container_name: str, + stored_procedure_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-11-01-preview")) - 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-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}/partitionMerge", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}/storedProcedures/{storedProcedureName}", ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), @@ -681,6 +730,7 @@ def build_list_sql_container_partition_merge_request( # pylint: disable=name-to ), "databaseName": _SERIALIZER.url("database_name", database_name, "str"), "containerName": _SERIALIZER.url("container_name", container_name, "str"), + "storedProcedureName": _SERIALIZER.url("stored_procedure_name", stored_procedure_name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -689,11 +739,9 @@ def build_list_sql_container_partition_merge_request( # pylint: disable=name-to _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) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_get_sql_container_throughput_request( # pylint: disable=name-too-long @@ -707,7 +755,7 @@ def build_get_sql_container_throughput_request( # 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", "2025-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -749,7 +797,7 @@ def build_update_sql_container_throughput_request( # pylint: disable=name-too-l _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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -794,7 +842,7 @@ def build_migrate_sql_container_to_autoscale_request( # pylint: disable=name-to _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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -836,7 +884,7 @@ def build_migrate_sql_container_to_manual_throughput_request( # pylint: disable _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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -867,20 +915,25 @@ def build_migrate_sql_container_to_manual_throughput_request( # pylint: disable return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_sql_database_retrieve_throughput_distribution_request( # pylint: disable=name-too-long - resource_group_name: str, account_name: str, database_name: str, subscription_id: str, **kwargs: Any +def build_sql_container_redistribute_throughput_request( # pylint: disable=name-too-long + resource_group_name: str, + account_name: str, + database_name: str, + container_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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) 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.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/throughputSettings/default/retrieveThroughputDistribution", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}/throughputSettings/default/redistributeThroughput", ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), @@ -891,6 +944,7 @@ def build_sql_database_retrieve_throughput_distribution_request( # pylint: disa "account_name", account_name, "str", max_length=50, min_length=3, pattern=r"^[a-z0-9]+(-[a-z0-9]+)*" ), "databaseName": _SERIALIZER.url("database_name", database_name, "str"), + "containerName": _SERIALIZER.url("container_name", container_name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -906,20 +960,25 @@ def build_sql_database_retrieve_throughput_distribution_request( # pylint: disa return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_sql_database_redistribute_throughput_request( # pylint: disable=name-too-long - resource_group_name: str, account_name: str, database_name: str, subscription_id: str, **kwargs: Any +def build_sql_container_retrieve_throughput_distribution_request( # pylint: disable=name-too-long + resource_group_name: str, + account_name: str, + database_name: str, + container_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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) 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.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/throughputSettings/default/redistributeThroughput", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}/throughputSettings/default/retrieveThroughputDistribution", ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), @@ -930,6 +989,7 @@ def build_sql_database_redistribute_throughput_request( # pylint: disable=name- "account_name", account_name, "str", max_length=50, min_length=3, pattern=r"^[a-z0-9]+(-[a-z0-9]+)*" ), "databaseName": _SERIALIZER.url("database_name", database_name, "str"), + "containerName": _SERIALIZER.url("container_name", container_name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -945,7 +1005,7 @@ def build_sql_database_redistribute_throughput_request( # pylint: disable=name- return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_sql_container_retrieve_throughput_distribution_request( # pylint: disable=name-too-long +def build_list_sql_triggers_request( resource_group_name: str, account_name: str, database_name: str, @@ -956,14 +1016,13 @@ def build_sql_container_retrieve_throughput_distribution_request( # pylint: dis _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-11-01-preview")) - 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-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}/throughputSettings/default/retrieveThroughputDistribution", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}/triggers", ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), @@ -983,32 +1042,30 @@ def build_sql_container_retrieve_throughput_distribution_request( # pylint: dis _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) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_sql_container_redistribute_throughput_request( # pylint: disable=name-too-long +def build_get_sql_trigger_request( resource_group_name: str, account_name: str, database_name: str, container_name: str, + trigger_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-11-01-preview")) - 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-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}/throughputSettings/default/redistributeThroughput", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}/triggers/{triggerName}", ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), @@ -1020,6 +1077,7 @@ def build_sql_container_redistribute_throughput_request( # pylint: disable=name ), "databaseName": _SERIALIZER.url("database_name", database_name, "str"), "containerName": _SERIALIZER.url("container_name", container_name, "str"), + "triggerName": _SERIALIZER.url("trigger_name", trigger_name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -1028,31 +1086,31 @@ def build_sql_container_redistribute_throughput_request( # pylint: disable=name _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) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_sql_stored_procedures_request( +def build_create_update_sql_trigger_request( resource_group_name: str, account_name: str, database_name: str, container_name: str, + trigger_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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) + 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.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}/storedProcedures", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}/triggers/{triggerName}", ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), @@ -1064,6 +1122,7 @@ def build_list_sql_stored_procedures_request( ), "databaseName": _SERIALIZER.url("database_name", database_name, "str"), "containerName": _SERIALIZER.url("container_name", container_name, "str"), + "triggerName": _SERIALIZER.url("trigger_name", trigger_name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -1072,30 +1131,32 @@ def build_list_sql_stored_procedures_request( _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="GET", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_get_sql_stored_procedure_request( +def build_delete_sql_trigger_request( resource_group_name: str, account_name: str, database_name: str, container_name: str, - stored_procedure_name: str, + trigger_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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}/storedProcedures/{storedProcedureName}", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}/triggers/{triggerName}", ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), @@ -1107,7 +1168,7 @@ def build_get_sql_stored_procedure_request( ), "databaseName": _SERIALIZER.url("database_name", database_name, "str"), "containerName": _SERIALIZER.url("container_name", container_name, "str"), - "storedProcedureName": _SERIALIZER.url("stored_procedure_name", stored_procedure_name, "str"), + "triggerName": _SERIALIZER.url("trigger_name", trigger_name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -1118,29 +1179,27 @@ def build_get_sql_stored_procedure_request( # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_update_sql_stored_procedure_request( # pylint: disable=name-too-long +def build_list_sql_user_defined_functions_request( # pylint: disable=name-too-long resource_group_name: str, account_name: str, database_name: str, container_name: str, - stored_procedure_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-11-01-preview")) - 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-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}/storedProcedures/{storedProcedureName}", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}/userDefinedFunctions", ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), @@ -1152,7 +1211,6 @@ def build_create_update_sql_stored_procedure_request( # pylint: disable=name-to ), "databaseName": _SERIALIZER.url("database_name", database_name, "str"), "containerName": _SERIALIZER.url("container_name", container_name, "str"), - "storedProcedureName": _SERIALIZER.url("stored_procedure_name", stored_procedure_name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -1161,29 +1219,30 @@ def build_create_update_sql_stored_procedure_request( # pylint: disable=name-to _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) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_delete_sql_stored_procedure_request( # pylint: disable=name-too-long +def build_get_sql_user_defined_function_request( # pylint: disable=name-too-long resource_group_name: str, account_name: str, database_name: str, container_name: str, - stored_procedure_name: str, + user_defined_function_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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}/storedProcedures/{storedProcedureName}", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}/userDefinedFunctions/{userDefinedFunctionName}", ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), @@ -1195,7 +1254,7 @@ def build_delete_sql_stored_procedure_request( # pylint: disable=name-too-long ), "databaseName": _SERIALIZER.url("database_name", database_name, "str"), "containerName": _SERIALIZER.url("container_name", container_name, "str"), - "storedProcedureName": _SERIALIZER.url("stored_procedure_name", stored_procedure_name, "str"), + "userDefinedFunctionName": _SERIALIZER.url("user_defined_function_name", user_defined_function_name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -1203,27 +1262,32 @@ def build_delete_sql_stored_procedure_request( # pylint: disable=name-too-long # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_sql_user_defined_functions_request( # pylint: disable=name-too-long - resource_group_name: str, + +def build_create_update_sql_user_defined_function_request( # pylint: disable=name-too-long + resource_group_name: str, account_name: str, database_name: str, container_name: str, + user_defined_function_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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) + 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.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}/userDefinedFunctions", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}/userDefinedFunctions/{userDefinedFunctionName}", ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), @@ -1235,6 +1299,7 @@ def build_list_sql_user_defined_functions_request( # pylint: disable=name-too-l ), "databaseName": _SERIALIZER.url("database_name", database_name, "str"), "containerName": _SERIALIZER.url("container_name", container_name, "str"), + "userDefinedFunctionName": _SERIALIZER.url("user_defined_function_name", user_defined_function_name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -1243,12 +1308,14 @@ def build_list_sql_user_defined_functions_request( # pylint: disable=name-too-l _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="GET", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_get_sql_user_defined_function_request( # pylint: disable=name-too-long +def build_delete_sql_user_defined_function_request( # pylint: disable=name-too-long resource_group_name: str, account_name: str, database_name: str, @@ -1260,7 +1327,7 @@ def build_get_sql_user_defined_function_request( # pylint: disable=name-too-lon _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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -1289,29 +1356,23 @@ def build_get_sql_user_defined_function_request( # pylint: disable=name-too-lon # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_update_sql_user_defined_function_request( # pylint: disable=name-too-long - resource_group_name: str, - account_name: str, - database_name: str, - container_name: str, - user_defined_function_name: str, - subscription_id: str, - **kwargs: Any +def build_sql_database_partition_merge_request( # pylint: disable=name-too-long + resource_group_name: str, account_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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) 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.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}/userDefinedFunctions/{userDefinedFunctionName}", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/partitionMerge", ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), @@ -1322,8 +1383,6 @@ def build_create_update_sql_user_defined_function_request( # pylint: disable=na "account_name", account_name, "str", max_length=50, min_length=3, pattern=r"^[a-z0-9]+(-[a-z0-9]+)*" ), "databaseName": _SERIALIZER.url("database_name", database_name, "str"), - "containerName": _SERIALIZER.url("container_name", container_name, "str"), - "userDefinedFunctionName": _SERIALIZER.url("user_defined_function_name", user_defined_function_name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -1336,25 +1395,22 @@ def build_create_update_sql_user_defined_function_request( # pylint: disable=na _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) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_delete_sql_user_defined_function_request( # pylint: disable=name-too-long - resource_group_name: str, - account_name: str, - database_name: str, - container_name: str, - user_defined_function_name: str, - subscription_id: str, - **kwargs: Any +def build_get_sql_database_throughput_request( # pylint: disable=name-too-long + resource_group_name: str, account_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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}/userDefinedFunctions/{userDefinedFunctionName}", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/throughputSettings/default", ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), @@ -1365,8 +1421,6 @@ def build_delete_sql_user_defined_function_request( # pylint: disable=name-too- "account_name", account_name, "str", max_length=50, min_length=3, pattern=r"^[a-z0-9]+(-[a-z0-9]+)*" ), "databaseName": _SERIALIZER.url("database_name", database_name, "str"), - "containerName": _SERIALIZER.url("container_name", container_name, "str"), - "userDefinedFunctionName": _SERIALIZER.url("user_defined_function_name", user_defined_function_name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -1374,27 +1428,26 @@ def build_delete_sql_user_defined_function_request( # pylint: disable=name-too- # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_sql_triggers_request( - resource_group_name: str, - account_name: str, - database_name: str, - container_name: str, - subscription_id: str, - **kwargs: Any + +def build_update_sql_database_throughput_request( # pylint: disable=name-too-long + resource_group_name: str, account_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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) + 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.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}/triggers", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/throughputSettings/default", ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), @@ -1405,7 +1458,6 @@ def build_list_sql_triggers_request( "account_name", account_name, "str", max_length=50, min_length=3, pattern=r"^[a-z0-9]+(-[a-z0-9]+)*" ), "databaseName": _SERIALIZER.url("database_name", database_name, "str"), - "containerName": _SERIALIZER.url("container_name", container_name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -1414,30 +1466,26 @@ def build_list_sql_triggers_request( _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="GET", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_get_sql_trigger_request( - resource_group_name: str, - account_name: str, - database_name: str, - container_name: str, - trigger_name: str, - subscription_id: str, - **kwargs: Any +def build_migrate_sql_database_to_autoscale_request( # pylint: disable=name-too-long + resource_group_name: str, account_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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}/triggers/{triggerName}", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/throughputSettings/default/migrateToAutoscale", ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), @@ -1448,8 +1496,6 @@ def build_get_sql_trigger_request( "account_name", account_name, "str", max_length=50, min_length=3, pattern=r"^[a-z0-9]+(-[a-z0-9]+)*" ), "databaseName": _SERIALIZER.url("database_name", database_name, "str"), - "containerName": _SERIALIZER.url("container_name", container_name, "str"), - "triggerName": _SERIALIZER.url("trigger_name", trigger_name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -1460,29 +1506,22 @@ def build_get_sql_trigger_request( # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_update_sql_trigger_request( - resource_group_name: str, - account_name: str, - database_name: str, - container_name: str, - trigger_name: str, - subscription_id: str, - **kwargs: Any +def build_migrate_sql_database_to_manual_throughput_request( # pylint: disable=name-too-long + resource_group_name: str, account_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-11-01-preview")) - 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-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}/triggers/{triggerName}", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/throughputSettings/default/migrateToManualThroughput", ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), @@ -1493,8 +1532,6 @@ def build_create_update_sql_trigger_request( "account_name", account_name, "str", max_length=50, min_length=3, pattern=r"^[a-z0-9]+(-[a-z0-9]+)*" ), "databaseName": _SERIALIZER.url("database_name", database_name, "str"), - "containerName": _SERIALIZER.url("container_name", container_name, "str"), - "triggerName": _SERIALIZER.url("trigger_name", trigger_name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -1503,29 +1540,25 @@ def build_create_update_sql_trigger_request( _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) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_delete_sql_trigger_request( - resource_group_name: str, - account_name: str, - database_name: str, - container_name: str, - trigger_name: str, - subscription_id: str, - **kwargs: Any +def build_sql_database_redistribute_throughput_request( # pylint: disable=name-too-long + resource_group_name: str, account_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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) + 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.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}/triggers/{triggerName}", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/throughputSettings/default/redistributeThroughput", ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), @@ -1536,8 +1569,6 @@ def build_delete_sql_trigger_request( "account_name", account_name, "str", max_length=50, min_length=3, pattern=r"^[a-z0-9]+(-[a-z0-9]+)*" ), "databaseName": _SERIALIZER.url("database_name", database_name, "str"), - "containerName": _SERIALIZER.url("container_name", container_name, "str"), - "triggerName": _SERIALIZER.url("trigger_name", trigger_name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -1545,25 +1576,30 @@ def build_delete_sql_trigger_request( # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) + # 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_sql_role_definition_request( - role_definition_id: str, resource_group_name: str, account_name: str, subscription_id: str, **kwargs: Any +def build_sql_database_retrieve_throughput_distribution_request( # pylint: disable=name-too-long + resource_group_name: str, account_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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) + 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.DocumentDB/databaseAccounts/{accountName}/sqlRoleDefinitions/{roleDefinitionId}", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/throughputSettings/default/retrieveThroughputDistribution", ) path_format_arguments = { - "roleDefinitionId": _SERIALIZER.url("role_definition_id", role_definition_id, "str"), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "resourceGroupName": _SERIALIZER.url( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 @@ -1571,6 +1607,7 @@ def build_get_sql_role_definition_request( "accountName": _SERIALIZER.url( "account_name", account_name, "str", max_length=50, min_length=3, pattern=r"^[a-z0-9]+(-[a-z0-9]+)*" ), + "databaseName": _SERIALIZER.url("database_name", database_name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -1579,28 +1616,28 @@ def build_get_sql_role_definition_request( _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="GET", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_update_sql_role_definition_request( # pylint: disable=name-too-long - role_definition_id: str, resource_group_name: str, account_name: str, subscription_id: str, **kwargs: Any +def build_list_sql_role_assignments_request( + resource_group_name: str, account_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-11-01-preview")) - 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-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlRoleDefinitions/{roleDefinitionId}", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlRoleAssignments", ) path_format_arguments = { - "roleDefinitionId": _SERIALIZER.url("role_definition_id", role_definition_id, "str"), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "resourceGroupName": _SERIALIZER.url( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 @@ -1616,29 +1653,26 @@ def build_create_update_sql_role_definition_request( # pylint: disable=name-too _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) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_delete_sql_role_definition_request( - role_definition_id: str, resource_group_name: str, account_name: str, subscription_id: str, **kwargs: Any +def build_get_sql_role_assignment_request( + resource_group_name: str, account_name: str, role_assignment_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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlRoleDefinitions/{roleDefinitionId}", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlRoleAssignments/{roleAssignmentId}", ) path_format_arguments = { - "roleDefinitionId": _SERIALIZER.url("role_definition_id", role_definition_id, "str"), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "resourceGroupName": _SERIALIZER.url( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 @@ -1646,6 +1680,7 @@ def build_delete_sql_role_definition_request( "accountName": _SERIALIZER.url( "account_name", account_name, "str", max_length=50, min_length=3, pattern=r"^[a-z0-9]+(-[a-z0-9]+)*" ), + "roleAssignmentId": _SERIALIZER.url("role_assignment_id", role_assignment_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -1656,22 +1691,23 @@ def build_delete_sql_role_definition_request( # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_sql_role_definitions_request( - resource_group_name: str, account_name: str, subscription_id: str, **kwargs: Any +def build_create_update_sql_role_assignment_request( # pylint: disable=name-too-long + resource_group_name: str, account_name: str, role_assignment_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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) + 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.DocumentDB/databaseAccounts/{accountName}/sqlRoleDefinitions", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlRoleAssignments/{roleAssignmentId}", ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), @@ -1681,6 +1717,7 @@ def build_list_sql_role_definitions_request( "accountName": _SERIALIZER.url( "account_name", account_name, "str", max_length=50, min_length=3, pattern=r"^[a-z0-9]+(-[a-z0-9]+)*" ), + "roleAssignmentId": _SERIALIZER.url("role_assignment_id", role_assignment_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -1689,18 +1726,20 @@ def build_list_sql_role_definitions_request( _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="GET", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_get_sql_role_assignment_request( - role_assignment_id: str, resource_group_name: str, account_name: str, subscription_id: str, **kwargs: Any +def build_delete_sql_role_assignment_request( + resource_group_name: str, account_name: str, role_assignment_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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -1709,7 +1748,6 @@ def build_get_sql_role_assignment_request( "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlRoleAssignments/{roleAssignmentId}", ) path_format_arguments = { - "roleAssignmentId": _SERIALIZER.url("role_assignment_id", role_assignment_id, "str"), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "resourceGroupName": _SERIALIZER.url( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 @@ -1717,6 +1755,7 @@ def build_get_sql_role_assignment_request( "accountName": _SERIALIZER.url( "account_name", account_name, "str", max_length=50, min_length=3, pattern=r"^[a-z0-9]+(-[a-z0-9]+)*" ), + "roleAssignmentId": _SERIALIZER.url("role_assignment_id", role_assignment_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -1727,26 +1766,24 @@ def build_get_sql_role_assignment_request( # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_update_sql_role_assignment_request( # pylint: disable=name-too-long - role_assignment_id: str, resource_group_name: str, account_name: str, subscription_id: str, **kwargs: Any +def build_list_sql_role_definitions_request( + resource_group_name: str, account_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-11-01-preview")) - 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-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlRoleAssignments/{roleAssignmentId}", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlRoleDefinitions", ) path_format_arguments = { - "roleAssignmentId": _SERIALIZER.url("role_assignment_id", role_assignment_id, "str"), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "resourceGroupName": _SERIALIZER.url( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 @@ -1762,29 +1799,26 @@ def build_create_update_sql_role_assignment_request( # pylint: disable=name-too _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) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_delete_sql_role_assignment_request( - role_assignment_id: str, resource_group_name: str, account_name: str, subscription_id: str, **kwargs: Any +def build_get_sql_role_definition_request( + resource_group_name: str, account_name: str, role_definition_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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlRoleAssignments/{roleAssignmentId}", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlRoleDefinitions/{roleDefinitionId}", ) path_format_arguments = { - "roleAssignmentId": _SERIALIZER.url("role_assignment_id", role_assignment_id, "str"), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "resourceGroupName": _SERIALIZER.url( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 @@ -1792,6 +1826,7 @@ def build_delete_sql_role_assignment_request( "accountName": _SERIALIZER.url( "account_name", account_name, "str", max_length=50, min_length=3, pattern=r"^[a-z0-9]+(-[a-z0-9]+)*" ), + "roleDefinitionId": _SERIALIZER.url("role_definition_id", role_definition_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -1802,22 +1837,23 @@ def build_delete_sql_role_assignment_request( # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_sql_role_assignments_request( - resource_group_name: str, account_name: str, subscription_id: str, **kwargs: Any +def build_create_update_sql_role_definition_request( # pylint: disable=name-too-long + resource_group_name: str, account_name: str, role_definition_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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) + 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.DocumentDB/databaseAccounts/{accountName}/sqlRoleAssignments", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlRoleDefinitions/{roleDefinitionId}", ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), @@ -1827,6 +1863,7 @@ def build_list_sql_role_assignments_request( "accountName": _SERIALIZER.url( "account_name", account_name, "str", max_length=50, min_length=3, pattern=r"^[a-z0-9]+(-[a-z0-9]+)*" ), + "roleDefinitionId": _SERIALIZER.url("role_definition_id", role_definition_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -1835,30 +1872,26 @@ def build_list_sql_role_assignments_request( _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="GET", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_retrieve_continuous_backup_information_request( # pylint: disable=name-too-long - resource_group_name: str, - account_name: str, - database_name: str, - container_name: str, - subscription_id: str, - **kwargs: Any +def build_delete_sql_role_definition_request( + resource_group_name: str, account_name: str, role_definition_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-11-01-preview")) - 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-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}/retrieveContinuousBackupInformation", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlRoleDefinitions/{roleDefinitionId}", ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), @@ -1868,8 +1901,7 @@ def build_retrieve_continuous_backup_information_request( # pylint: disable=nam "accountName": _SERIALIZER.url( "account_name", account_name, "str", max_length=50, min_length=3, pattern=r"^[a-z0-9]+(-[a-z0-9]+)*" ), - "databaseName": _SERIALIZER.url("database_name", database_name, "str"), - "containerName": _SERIALIZER.url("container_name", container_name, "str"), + "roleDefinitionId": _SERIALIZER.url("role_definition_id", role_definition_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -1878,11 +1910,9 @@ def build_retrieve_continuous_backup_information_request( # pylint: disable=nam _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) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) class SqlResourcesOperations: # pylint: disable=too-many-public-methods @@ -1969,7 +1999,7 @@ def extract_data(pipeline_response): list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore - return None, iter(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): _request = prepare_request(next_link) @@ -1982,7 +2012,11 @@ 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response @@ -2040,7 +2074,11 @@ def get_sql_database( if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("SqlDatabaseGetResults", pipeline_response.http_response) @@ -2108,14 +2146,19 @@ def _create_update_sql_database_initial( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + 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["azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("azure-AsyncOperation") + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") ) - response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) @@ -2248,7 +2291,9 @@ def get_long_running_output(pipeline_response): return deserialized if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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: @@ -2306,14 +2351,18 @@ def _delete_sql_database_initial( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + 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["azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("azure-AsyncOperation") + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") ) - response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) @@ -2366,7 +2415,9 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- return cls(pipeline_response, None, {}) # type: ignore if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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: @@ -2381,11 +2432,10 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore @distributed_trace - def get_sql_database_throughput( + def list_client_encryption_keys( self, resource_group_name: str, account_name: str, database_name: str, **kwargs: Any - ) -> _models.ThroughputSettingsGetResults: - """Gets the RUs per second of the SQL database under an existing Azure Cosmos DB database account - with the provided name. + ) -> ItemPaged["_models.ClientEncryptionKeyGetResults"]: + """Lists the ClientEncryptionKeys under an existing Azure Cosmos DB SQL database. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -2394,15 +2444,113 @@ def get_sql_database_throughput( :type account_name: str :param database_name: Cosmos DB database name. Required. :type database_name: str - :return: ThroughputSettingsGetResults or the result of cls(response) - :rtype: ~azure.mgmt.cosmosdb.models.ThroughputSettingsGetResults + :return: An iterator like instance of either ClientEncryptionKeyGetResults or the result of + cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cosmosdb.models.ClientEncryptionKeyGetResults] :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, + _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.ClientEncryptionKeysListResult] = 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_client_encryption_keys_request( + resource_group_name=resource_group_name, + account_name=account_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) + + 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("ClientEncryptionKeysListResult", 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_client_encryption_key( + self, + resource_group_name: str, + account_name: str, + database_name: str, + client_encryption_key_name: str, + **kwargs: Any + ) -> _models.ClientEncryptionKeyGetResults: + """Gets the ClientEncryptionKey under an existing Azure Cosmos DB SQL database. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param database_name: Cosmos DB database name. Required. + :type database_name: str + :param client_encryption_key_name: Cosmos DB ClientEncryptionKey name. Required. + :type client_encryption_key_name: str + :return: ClientEncryptionKeyGetResults or the result of cls(response) + :rtype: ~azure.mgmt.cosmosdb.models.ClientEncryptionKeyGetResults + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) @@ -2410,12 +2558,13 @@ def get_sql_database_throughput( _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.ThroughputSettingsGetResults] = kwargs.pop("cls", None) + cls: ClsType[_models.ClientEncryptionKeyGetResults] = kwargs.pop("cls", None) - _request = build_get_sql_database_throughput_request( + _request = build_get_client_encryption_key_request( resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, + client_encryption_key_name=client_encryption_key_name, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, @@ -2432,21 +2581,28 @@ def get_sql_database_throughput( if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("ThroughputSettingsGetResults", pipeline_response.http_response) + deserialized = self._deserialize("ClientEncryptionKeyGetResults", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - def _update_sql_database_throughput_initial( + def _create_update_client_encryption_key_initial( # pylint: disable=name-too-long self, resource_group_name: str, account_name: str, database_name: str, - update_throughput_parameters: Union[_models.ThroughputSettingsUpdateParameters, IO[bytes]], + client_encryption_key_name: str, + create_update_client_encryption_key_parameters: Union[ + _models.ClientEncryptionKeyCreateUpdateParameters, IO[bytes] + ], **kwargs: Any ) -> Iterator[bytes]: error_map: MutableMapping = { @@ -2467,15 +2623,18 @@ def _update_sql_database_throughput_initial( content_type = content_type or "application/json" _json = None _content = None - if isinstance(update_throughput_parameters, (IOBase, bytes)): - _content = update_throughput_parameters + if isinstance(create_update_client_encryption_key_parameters, (IOBase, bytes)): + _content = create_update_client_encryption_key_parameters else: - _json = self._serialize.body(update_throughput_parameters, "ThroughputSettingsUpdateParameters") + _json = self._serialize.body( + create_update_client_encryption_key_parameters, "ClientEncryptionKeyCreateUpdateParameters" + ) - _request = build_update_sql_database_throughput_request( + _request = build_create_update_client_encryption_key_request( resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, + client_encryption_key_name=client_encryption_key_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, @@ -2500,14 +2659,19 @@ def _update_sql_database_throughput_initial( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + 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["azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("azure-AsyncOperation") + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") ) - response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) @@ -2517,17 +2681,19 @@ def _update_sql_database_throughput_initial( return deserialized # type: ignore @overload - def begin_update_sql_database_throughput( + def begin_create_update_client_encryption_key( # pylint: disable=name-too-long self, resource_group_name: str, account_name: str, database_name: str, - update_throughput_parameters: _models.ThroughputSettingsUpdateParameters, + client_encryption_key_name: str, + create_update_client_encryption_key_parameters: _models.ClientEncryptionKeyCreateUpdateParameters, *, content_type: str = "application/json", **kwargs: Any - ) -> LROPoller[_models.ThroughputSettingsGetResults]: - """Update RUs per second of an Azure Cosmos DB SQL database. + ) -> LROPoller[_models.ClientEncryptionKeyGetResults]: + """Create or update a ClientEncryptionKey. This API is meant to be invoked via tools such as the + Azure Powershell (instead of directly). :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -2536,31 +2702,36 @@ def begin_update_sql_database_throughput( :type account_name: str :param database_name: Cosmos DB database name. Required. :type database_name: str - :param update_throughput_parameters: The parameters to provide for the RUs per second of the - current SQL database. Required. - :type update_throughput_parameters: - ~azure.mgmt.cosmosdb.models.ThroughputSettingsUpdateParameters + :param client_encryption_key_name: Cosmos DB ClientEncryptionKey name. Required. + :type client_encryption_key_name: str + :param create_update_client_encryption_key_parameters: The parameters to provide for the client + encryption key. Required. + :type create_update_client_encryption_key_parameters: + ~azure.mgmt.cosmosdb.models.ClientEncryptionKeyCreateUpdateParameters :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 ThroughputSettingsGetResults or the + :return: An instance of LROPoller that returns either ClientEncryptionKeyGetResults or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.ThroughputSettingsGetResults] + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.ClientEncryptionKeyGetResults] :raises ~azure.core.exceptions.HttpResponseError: """ @overload - def begin_update_sql_database_throughput( + def begin_create_update_client_encryption_key( # pylint: disable=name-too-long self, resource_group_name: str, account_name: str, database_name: str, - update_throughput_parameters: IO[bytes], + client_encryption_key_name: str, + create_update_client_encryption_key_parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> LROPoller[_models.ThroughputSettingsGetResults]: - """Update RUs per second of an Azure Cosmos DB SQL database. + ) -> LROPoller[_models.ClientEncryptionKeyGetResults]: + """Create or update a ClientEncryptionKey. This API is meant to be invoked via tools such as the + Azure Powershell (instead of directly). :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -2569,28 +2740,35 @@ def begin_update_sql_database_throughput( :type account_name: str :param database_name: Cosmos DB database name. Required. :type database_name: str - :param update_throughput_parameters: The parameters to provide for the RUs per second of the - current SQL database. Required. - :type update_throughput_parameters: IO[bytes] + :param client_encryption_key_name: Cosmos DB ClientEncryptionKey name. Required. + :type client_encryption_key_name: str + :param create_update_client_encryption_key_parameters: The parameters to provide for the client + encryption key. Required. + :type create_update_client_encryption_key_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 ThroughputSettingsGetResults or the + :return: An instance of LROPoller that returns either ClientEncryptionKeyGetResults or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.ThroughputSettingsGetResults] + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.ClientEncryptionKeyGetResults] :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace - def begin_update_sql_database_throughput( + def begin_create_update_client_encryption_key( # pylint: disable=name-too-long self, resource_group_name: str, account_name: str, database_name: str, - update_throughput_parameters: Union[_models.ThroughputSettingsUpdateParameters, IO[bytes]], + client_encryption_key_name: str, + create_update_client_encryption_key_parameters: Union[ + _models.ClientEncryptionKeyCreateUpdateParameters, IO[bytes] + ], **kwargs: Any - ) -> LROPoller[_models.ThroughputSettingsGetResults]: - """Update RUs per second of an Azure Cosmos DB SQL database. + ) -> LROPoller[_models.ClientEncryptionKeyGetResults]: + """Create or update a ClientEncryptionKey. This API is meant to be invoked via tools such as the + Azure Powershell (instead of directly). :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -2599,14 +2777,17 @@ def begin_update_sql_database_throughput( :type account_name: str :param database_name: Cosmos DB database name. Required. :type database_name: str - :param update_throughput_parameters: The parameters to provide for the RUs per second of the - current SQL database. Is either a ThroughputSettingsUpdateParameters type or a IO[bytes] type. + :param client_encryption_key_name: Cosmos DB ClientEncryptionKey name. Required. + :type client_encryption_key_name: str + :param create_update_client_encryption_key_parameters: The parameters to provide for the client + encryption key. Is either a ClientEncryptionKeyCreateUpdateParameters type or a IO[bytes] type. Required. - :type update_throughput_parameters: - ~azure.mgmt.cosmosdb.models.ThroughputSettingsUpdateParameters or IO[bytes] - :return: An instance of LROPoller that returns either ThroughputSettingsGetResults or the + :type create_update_client_encryption_key_parameters: + ~azure.mgmt.cosmosdb.models.ClientEncryptionKeyCreateUpdateParameters or IO[bytes] + :return: An instance of LROPoller that returns either ClientEncryptionKeyGetResults or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.ThroughputSettingsGetResults] + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.ClientEncryptionKeyGetResults] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -2614,16 +2795,17 @@ def begin_update_sql_database_throughput( 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.ThroughputSettingsGetResults] = kwargs.pop("cls", None) + cls: ClsType[_models.ClientEncryptionKeyGetResults] = 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_sql_database_throughput_initial( + raw_result = self._create_update_client_encryption_key_initial( resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, - update_throughput_parameters=update_throughput_parameters, + client_encryption_key_name=client_encryption_key_name, + create_update_client_encryption_key_parameters=create_update_client_encryption_key_parameters, api_version=api_version, content_type=content_type, cls=lambda x, y, z: x, @@ -2635,31 +2817,54 @@ def begin_update_sql_database_throughput( kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ThroughputSettingsGetResults", pipeline_response.http_response) + deserialized = self._deserialize("ClientEncryptionKeyGetResults", 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, **kwargs)) + 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.ThroughputSettingsGetResults].from_continuation_token( + return LROPoller[_models.ClientEncryptionKeyGetResults].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller[_models.ThroughputSettingsGetResults]( + return LROPoller[_models.ClientEncryptionKeyGetResults]( self._client, raw_result, get_long_running_output, polling_method # type: ignore ) - def _migrate_sql_database_to_autoscale_initial( # pylint: disable=name-too-long + @distributed_trace + def list_sql_containers( self, resource_group_name: str, account_name: str, database_name: str, **kwargs: Any - ) -> Iterator[bytes]: + ) -> ItemPaged["_models.SqlContainerGetResults"]: + """Lists the SQL container under an existing Azure Cosmos DB database account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param database_name: Cosmos DB database name. Required. + :type database_name: str + :return: An iterator like instance of either SqlContainerGetResults or the result of + cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cosmosdb.models.SqlContainerGetResults] + :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.SqlContainerListResult] = kwargs.pop("cls", None) + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -2668,666 +2873,8 @@ def _migrate_sql_database_to_autoscale_initial( # pylint: disable=name-too-long } 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_migrate_sql_database_to_autoscale_request( - resource_group_name=resource_group_name, - account_name=account_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 [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) - raise HttpResponseError(response=response, 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")) - - 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_migrate_sql_database_to_autoscale( - self, resource_group_name: str, account_name: str, database_name: str, **kwargs: Any - ) -> LROPoller[_models.ThroughputSettingsGetResults]: - """Migrate an Azure Cosmos DB SQL database from manual throughput to autoscale. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param account_name: Cosmos DB database account name. Required. - :type account_name: str - :param database_name: Cosmos DB database name. Required. - :type database_name: str - :return: An instance of LROPoller that returns either ThroughputSettingsGetResults or the - result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.ThroughputSettingsGetResults] - :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.ThroughputSettingsGetResults] = 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_sql_database_to_autoscale_initial( - resource_group_name=resource_group_name, - account_name=account_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): - deserialized = self._deserialize("ThroughputSettingsGetResults", 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, **kwargs)) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[_models.ThroughputSettingsGetResults].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.ThroughputSettingsGetResults]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _migrate_sql_database_to_manual_throughput_initial( # pylint: disable=name-too-long - self, resource_group_name: str, account_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_migrate_sql_database_to_manual_throughput_request( - resource_group_name=resource_group_name, - account_name=account_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 [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) - raise HttpResponseError(response=response, 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")) - - 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_migrate_sql_database_to_manual_throughput( # pylint: disable=name-too-long - self, resource_group_name: str, account_name: str, database_name: str, **kwargs: Any - ) -> LROPoller[_models.ThroughputSettingsGetResults]: - """Migrate an Azure Cosmos DB SQL database from autoscale to manual throughput. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param account_name: Cosmos DB database account name. Required. - :type account_name: str - :param database_name: Cosmos DB database name. Required. - :type database_name: str - :return: An instance of LROPoller that returns either ThroughputSettingsGetResults or the - result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.ThroughputSettingsGetResults] - :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.ThroughputSettingsGetResults] = 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_sql_database_to_manual_throughput_initial( - resource_group_name=resource_group_name, - account_name=account_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): - deserialized = self._deserialize("ThroughputSettingsGetResults", 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, **kwargs)) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[_models.ThroughputSettingsGetResults].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.ThroughputSettingsGetResults]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - @distributed_trace - def list_client_encryption_keys( - self, resource_group_name: str, account_name: str, database_name: str, **kwargs: Any - ) -> ItemPaged["_models.ClientEncryptionKeyGetResults"]: - """Lists the ClientEncryptionKeys under an existing Azure Cosmos DB SQL database. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param account_name: Cosmos DB database account name. Required. - :type account_name: str - :param database_name: Cosmos DB database name. Required. - :type database_name: str - :return: An iterator like instance of either ClientEncryptionKeyGetResults or the result of - cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cosmosdb.models.ClientEncryptionKeyGetResults] - :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.ClientEncryptionKeysListResult] = 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_client_encryption_keys_request( - resource_group_name=resource_group_name, - account_name=account_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) - - 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("ClientEncryptionKeysListResult", 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def get_client_encryption_key( - self, - resource_group_name: str, - account_name: str, - database_name: str, - client_encryption_key_name: str, - **kwargs: Any - ) -> _models.ClientEncryptionKeyGetResults: - """Gets the ClientEncryptionKey under an existing Azure Cosmos DB SQL database. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param account_name: Cosmos DB database account name. Required. - :type account_name: str - :param database_name: Cosmos DB database name. Required. - :type database_name: str - :param client_encryption_key_name: Cosmos DB ClientEncryptionKey name. Required. - :type client_encryption_key_name: str - :return: ClientEncryptionKeyGetResults or the result of cls(response) - :rtype: ~azure.mgmt.cosmosdb.models.ClientEncryptionKeyGetResults - :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.ClientEncryptionKeyGetResults] = kwargs.pop("cls", None) - - _request = build_get_client_encryption_key_request( - resource_group_name=resource_group_name, - account_name=account_name, - database_name=database_name, - client_encryption_key_name=client_encryption_key_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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("ClientEncryptionKeyGetResults", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - def _create_update_client_encryption_key_initial( # pylint: disable=name-too-long - self, - resource_group_name: str, - account_name: str, - database_name: str, - client_encryption_key_name: str, - create_update_client_encryption_key_parameters: Union[ - _models.ClientEncryptionKeyCreateUpdateParameters, 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(create_update_client_encryption_key_parameters, (IOBase, bytes)): - _content = create_update_client_encryption_key_parameters - else: - _json = self._serialize.body( - create_update_client_encryption_key_parameters, "ClientEncryptionKeyCreateUpdateParameters" - ) - - _request = build_create_update_client_encryption_key_request( - resource_group_name=resource_group_name, - account_name=account_name, - database_name=database_name, - client_encryption_key_name=client_encryption_key_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) - raise HttpResponseError(response=response, 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")) - - 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_update_client_encryption_key( # pylint: disable=name-too-long - self, - resource_group_name: str, - account_name: str, - database_name: str, - client_encryption_key_name: str, - create_update_client_encryption_key_parameters: _models.ClientEncryptionKeyCreateUpdateParameters, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.ClientEncryptionKeyGetResults]: - """Create or update a ClientEncryptionKey. This API is meant to be invoked via tools such as the - Azure Powershell (instead of directly). - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param account_name: Cosmos DB database account name. Required. - :type account_name: str - :param database_name: Cosmos DB database name. Required. - :type database_name: str - :param client_encryption_key_name: Cosmos DB ClientEncryptionKey name. Required. - :type client_encryption_key_name: str - :param create_update_client_encryption_key_parameters: The parameters to provide for the client - encryption key. Required. - :type create_update_client_encryption_key_parameters: - ~azure.mgmt.cosmosdb.models.ClientEncryptionKeyCreateUpdateParameters - :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 ClientEncryptionKeyGetResults or the - result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.ClientEncryptionKeyGetResults] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_create_update_client_encryption_key( # pylint: disable=name-too-long - self, - resource_group_name: str, - account_name: str, - database_name: str, - client_encryption_key_name: str, - create_update_client_encryption_key_parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.ClientEncryptionKeyGetResults]: - """Create or update a ClientEncryptionKey. This API is meant to be invoked via tools such as the - Azure Powershell (instead of directly). - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param account_name: Cosmos DB database account name. Required. - :type account_name: str - :param database_name: Cosmos DB database name. Required. - :type database_name: str - :param client_encryption_key_name: Cosmos DB ClientEncryptionKey name. Required. - :type client_encryption_key_name: str - :param create_update_client_encryption_key_parameters: The parameters to provide for the client - encryption key. Required. - :type create_update_client_encryption_key_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 ClientEncryptionKeyGetResults or the - result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.ClientEncryptionKeyGetResults] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_create_update_client_encryption_key( # pylint: disable=name-too-long - self, - resource_group_name: str, - account_name: str, - database_name: str, - client_encryption_key_name: str, - create_update_client_encryption_key_parameters: Union[ - _models.ClientEncryptionKeyCreateUpdateParameters, IO[bytes] - ], - **kwargs: Any - ) -> LROPoller[_models.ClientEncryptionKeyGetResults]: - """Create or update a ClientEncryptionKey. This API is meant to be invoked via tools such as the - Azure Powershell (instead of directly). - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param account_name: Cosmos DB database account name. Required. - :type account_name: str - :param database_name: Cosmos DB database name. Required. - :type database_name: str - :param client_encryption_key_name: Cosmos DB ClientEncryptionKey name. Required. - :type client_encryption_key_name: str - :param create_update_client_encryption_key_parameters: The parameters to provide for the client - encryption key. Is either a ClientEncryptionKeyCreateUpdateParameters type or a IO[bytes] type. - Required. - :type create_update_client_encryption_key_parameters: - ~azure.mgmt.cosmosdb.models.ClientEncryptionKeyCreateUpdateParameters or IO[bytes] - :return: An instance of LROPoller that returns either ClientEncryptionKeyGetResults or the - result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.ClientEncryptionKeyGetResults] - :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.ClientEncryptionKeyGetResults] = 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_update_client_encryption_key_initial( - resource_group_name=resource_group_name, - account_name=account_name, - database_name=database_name, - client_encryption_key_name=client_encryption_key_name, - create_update_client_encryption_key_parameters=create_update_client_encryption_key_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("ClientEncryptionKeyGetResults", 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, **kwargs)) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[_models.ClientEncryptionKeyGetResults].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.ClientEncryptionKeyGetResults]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - @distributed_trace - def list_sql_containers( - self, resource_group_name: str, account_name: str, database_name: str, **kwargs: Any - ) -> ItemPaged["_models.SqlContainerGetResults"]: - """Lists the SQL container under an existing Azure Cosmos DB database account. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param account_name: Cosmos DB database account name. Required. - :type account_name: str - :param database_name: Cosmos DB database name. Required. - :type database_name: str - :return: An iterator like instance of either SqlContainerGetResults or the result of - cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cosmosdb.models.SqlContainerGetResults] - :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.SqlContainerListResult] = 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: + def prepare_request(next_link=None): + if not next_link: _request = build_list_sql_containers_request( resource_group_name=resource_group_name, @@ -3362,7 +2909,7 @@ def extract_data(pipeline_response): list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore - return None, iter(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): _request = prepare_request(next_link) @@ -3375,7 +2922,11 @@ 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response @@ -3435,7 +2986,11 @@ def get_sql_container( if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("SqlContainerGetResults", pipeline_response.http_response) @@ -3505,14 +3060,19 @@ def _create_update_sql_container_initial( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + 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["azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("azure-AsyncOperation") + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") ) - response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) @@ -3655,7 +3215,9 @@ def get_long_running_output(pipeline_response): return deserialized if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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: @@ -3714,14 +3276,18 @@ def _delete_sql_container_initial( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + 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["azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("azure-AsyncOperation") + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") ) - response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) @@ -3777,7 +3343,9 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- return cls(pipeline_response, None, {}) # type: ignore if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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: @@ -3791,11 +3359,12 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- ) return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - def _sql_database_partition_merge_initial( + def _list_sql_container_partition_merge_initial( # pylint: disable=name-too-long self, resource_group_name: str, account_name: str, database_name: str, + container_name: str, merge_parameters: Union[_models.MergeParameters, IO[bytes]], **kwargs: Any ) -> Iterator[bytes]: @@ -3822,10 +3391,11 @@ def _sql_database_partition_merge_initial( else: _json = self._serialize.body(merge_parameters, "MergeParameters") - _request = build_sql_database_partition_merge_request( + _request = build_list_sql_container_partition_merge_request( resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, + container_name=container_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, @@ -3854,10 +3424,10 @@ def _sql_database_partition_merge_initial( response_headers = {} if response.status_code == 202: - response_headers["azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("azure-AsyncOperation") + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") ) - response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) @@ -3867,17 +3437,18 @@ def _sql_database_partition_merge_initial( return deserialized # type: ignore @overload - def begin_sql_database_partition_merge( + def begin_list_sql_container_partition_merge( self, resource_group_name: str, account_name: str, database_name: str, + container_name: str, merge_parameters: _models.MergeParameters, *, content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.PhysicalPartitionStorageInfoCollection]: - """Merges the partitions of a SQL database. + """Merges the partitions of a SQL Container. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -3886,6 +3457,8 @@ def begin_sql_database_partition_merge( :type account_name: str :param database_name: Cosmos DB database name. Required. :type database_name: str + :param container_name: Cosmos DB container name. Required. + :type container_name: str :param merge_parameters: The parameters for the merge operation. Required. :type merge_parameters: ~azure.mgmt.cosmosdb.models.MergeParameters :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. @@ -3899,17 +3472,18 @@ def begin_sql_database_partition_merge( """ @overload - def begin_sql_database_partition_merge( + def begin_list_sql_container_partition_merge( self, resource_group_name: str, account_name: str, database_name: str, + container_name: str, merge_parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.PhysicalPartitionStorageInfoCollection]: - """Merges the partitions of a SQL database. + """Merges the partitions of a SQL Container. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -3918,6 +3492,8 @@ def begin_sql_database_partition_merge( :type account_name: str :param database_name: Cosmos DB database name. Required. :type database_name: str + :param container_name: Cosmos DB container name. Required. + :type container_name: str :param merge_parameters: The parameters for the merge operation. Required. :type merge_parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. @@ -3931,15 +3507,16 @@ def begin_sql_database_partition_merge( """ @distributed_trace - def begin_sql_database_partition_merge( + def begin_list_sql_container_partition_merge( self, resource_group_name: str, account_name: str, database_name: str, + container_name: str, merge_parameters: Union[_models.MergeParameters, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.PhysicalPartitionStorageInfoCollection]: - """Merges the partitions of a SQL database. + """Merges the partitions of a SQL Container. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -3948,6 +3525,8 @@ def begin_sql_database_partition_merge( :type account_name: str :param database_name: Cosmos DB database name. Required. :type database_name: str + :param container_name: Cosmos DB container name. Required. + :type container_name: str :param merge_parameters: The parameters for the merge operation. Is either a MergeParameters type or a IO[bytes] type. Required. :type merge_parameters: ~azure.mgmt.cosmosdb.models.MergeParameters or IO[bytes] @@ -3967,10 +3546,11 @@ def begin_sql_database_partition_merge( 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._sql_database_partition_merge_initial( + raw_result = self._list_sql_container_partition_merge_initial( resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, + container_name=container_name, merge_parameters=merge_parameters, api_version=api_version, content_type=content_type, @@ -4007,13 +3587,13 @@ def get_long_running_output(pipeline_response): self._client, raw_result, get_long_running_output, polling_method # type: ignore ) - def _list_sql_container_partition_merge_initial( # pylint: disable=name-too-long + def _retrieve_continuous_backup_information_initial( # pylint: disable=name-too-long self, resource_group_name: str, account_name: str, database_name: str, container_name: str, - merge_parameters: Union[_models.MergeParameters, IO[bytes]], + location: Union[_models.ContinuousBackupRestoreLocation, IO[bytes]], **kwargs: Any ) -> Iterator[bytes]: error_map: MutableMapping = { @@ -4034,12 +3614,12 @@ def _list_sql_container_partition_merge_initial( # pylint: disable=name-too-lon content_type = content_type or "application/json" _json = None _content = None - if isinstance(merge_parameters, (IOBase, bytes)): - _content = merge_parameters + if isinstance(location, (IOBase, bytes)): + _content = location else: - _json = self._serialize.body(merge_parameters, "MergeParameters") + _json = self._serialize.body(location, "ContinuousBackupRestoreLocation") - _request = build_list_sql_container_partition_merge_request( + _request = build_retrieve_continuous_backup_information_request( resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, @@ -4072,10 +3652,8 @@ def _list_sql_container_partition_merge_initial( # pylint: disable=name-too-lon 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["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) @@ -4085,18 +3663,18 @@ def _list_sql_container_partition_merge_initial( # pylint: disable=name-too-lon return deserialized # type: ignore @overload - def begin_list_sql_container_partition_merge( + def begin_retrieve_continuous_backup_information( # pylint: disable=name-too-long self, resource_group_name: str, account_name: str, database_name: str, container_name: str, - merge_parameters: _models.MergeParameters, + location: _models.ContinuousBackupRestoreLocation, *, content_type: str = "application/json", **kwargs: Any - ) -> LROPoller[_models.PhysicalPartitionStorageInfoCollection]: - """Merges the partitions of a SQL Container. + ) -> LROPoller[_models.BackupInformation]: + """Retrieves continuous backup information for a container resource. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -4107,31 +3685,30 @@ def begin_list_sql_container_partition_merge( :type database_name: str :param container_name: Cosmos DB container name. Required. :type container_name: str - :param merge_parameters: The parameters for the merge operation. Required. - :type merge_parameters: ~azure.mgmt.cosmosdb.models.MergeParameters + :param location: The name of the continuous backup restore location. Required. + :type location: ~azure.mgmt.cosmosdb.models.ContinuousBackupRestoreLocation :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 PhysicalPartitionStorageInfoCollection or - the result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.PhysicalPartitionStorageInfoCollection] + :return: An instance of LROPoller that returns either BackupInformation or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.BackupInformation] :raises ~azure.core.exceptions.HttpResponseError: """ @overload - def begin_list_sql_container_partition_merge( + def begin_retrieve_continuous_backup_information( # pylint: disable=name-too-long self, resource_group_name: str, account_name: str, database_name: str, container_name: str, - merge_parameters: IO[bytes], + location: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> LROPoller[_models.PhysicalPartitionStorageInfoCollection]: - """Merges the partitions of a SQL Container. + ) -> LROPoller[_models.BackupInformation]: + """Retrieves continuous backup information for a container resource. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -4142,29 +3719,28 @@ def begin_list_sql_container_partition_merge( :type database_name: str :param container_name: Cosmos DB container name. Required. :type container_name: str - :param merge_parameters: The parameters for the merge operation. Required. - :type merge_parameters: IO[bytes] + :param location: The name of the continuous backup restore location. Required. + :type location: 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 PhysicalPartitionStorageInfoCollection or - the result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.PhysicalPartitionStorageInfoCollection] + :return: An instance of LROPoller that returns either BackupInformation or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.BackupInformation] :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace - def begin_list_sql_container_partition_merge( + def begin_retrieve_continuous_backup_information( # pylint: disable=name-too-long self, resource_group_name: str, account_name: str, database_name: str, container_name: str, - merge_parameters: Union[_models.MergeParameters, IO[bytes]], + location: Union[_models.ContinuousBackupRestoreLocation, IO[bytes]], **kwargs: Any - ) -> LROPoller[_models.PhysicalPartitionStorageInfoCollection]: - """Merges the partitions of a SQL Container. + ) -> LROPoller[_models.BackupInformation]: + """Retrieves continuous backup information for a container resource. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -4175,13 +3751,12 @@ def begin_list_sql_container_partition_merge( :type database_name: str :param container_name: Cosmos DB container name. Required. :type container_name: str - :param merge_parameters: The parameters for the merge operation. Is either a MergeParameters - type or a IO[bytes] type. Required. - :type merge_parameters: ~azure.mgmt.cosmosdb.models.MergeParameters or IO[bytes] - :return: An instance of LROPoller that returns either PhysicalPartitionStorageInfoCollection or - the result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.PhysicalPartitionStorageInfoCollection] + :param location: The name of the continuous backup restore location. Is either a + ContinuousBackupRestoreLocation type or a IO[bytes] type. Required. + :type location: ~azure.mgmt.cosmosdb.models.ContinuousBackupRestoreLocation or IO[bytes] + :return: An instance of LROPoller that returns either BackupInformation or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.BackupInformation] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -4189,17 +3764,17 @@ def begin_list_sql_container_partition_merge( 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.PhysicalPartitionStorageInfoCollection] = kwargs.pop("cls", None) + cls: ClsType[_models.BackupInformation] = 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._list_sql_container_partition_merge_initial( + raw_result = self._retrieve_continuous_backup_information_initial( resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, container_name=container_name, - merge_parameters=merge_parameters, + location=location, api_version=api_version, content_type=content_type, cls=lambda x, y, z: x, @@ -4211,7 +3786,7 @@ def begin_list_sql_container_partition_merge( kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("PhysicalPartitionStorageInfoCollection", pipeline_response.http_response) + deserialized = self._deserialize("BackupInformation", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized @@ -4225,22 +3800,21 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller[_models.PhysicalPartitionStorageInfoCollection].from_continuation_token( + return LROPoller[_models.BackupInformation].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller[_models.PhysicalPartitionStorageInfoCollection]( + return LROPoller[_models.BackupInformation]( self._client, raw_result, get_long_running_output, polling_method # type: ignore ) @distributed_trace - def get_sql_container_throughput( + def list_sql_stored_procedures( self, resource_group_name: str, account_name: str, database_name: str, container_name: str, **kwargs: Any - ) -> _models.ThroughputSettingsGetResults: - """Gets the RUs per second of the SQL container under an existing Azure Cosmos DB database - account. + ) -> ItemPaged["_models.SqlStoredProcedureGetResults"]: + """Lists the SQL storedProcedure under an existing Azure Cosmos DB database account. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -4251,8 +3825,106 @@ def get_sql_container_throughput( :type database_name: str :param container_name: Cosmos DB container name. Required. :type container_name: str - :return: ThroughputSettingsGetResults or the result of cls(response) - :rtype: ~azure.mgmt.cosmosdb.models.ThroughputSettingsGetResults + :return: An iterator like instance of either SqlStoredProcedureGetResults or the result of + cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cosmosdb.models.SqlStoredProcedureGetResults] + :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.SqlStoredProcedureListResult] = 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_sql_stored_procedures_request( + resource_group_name=resource_group_name, + account_name=account_name, + database_name=database_name, + container_name=container_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("SqlStoredProcedureListResult", 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def get_sql_stored_procedure( + self, + resource_group_name: str, + account_name: str, + database_name: str, + container_name: str, + stored_procedure_name: str, + **kwargs: Any + ) -> _models.SqlStoredProcedureGetResults: + """Gets the SQL storedProcedure under an existing Azure Cosmos DB database account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param database_name: Cosmos DB database name. Required. + :type database_name: str + :param container_name: Cosmos DB container name. Required. + :type container_name: str + :param stored_procedure_name: Cosmos DB storedProcedure name. Required. + :type stored_procedure_name: str + :return: SqlStoredProcedureGetResults or the result of cls(response) + :rtype: ~azure.mgmt.cosmosdb.models.SqlStoredProcedureGetResults :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -4267,13 +3939,14 @@ def get_sql_container_throughput( _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.ThroughputSettingsGetResults] = kwargs.pop("cls", None) + cls: ClsType[_models.SqlStoredProcedureGetResults] = kwargs.pop("cls", None) - _request = build_get_sql_container_throughput_request( + _request = build_get_sql_stored_procedure_request( resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, container_name=container_name, + stored_procedure_name=stored_procedure_name, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, @@ -4290,22 +3963,29 @@ def get_sql_container_throughput( if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("ThroughputSettingsGetResults", pipeline_response.http_response) + deserialized = self._deserialize("SqlStoredProcedureGetResults", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - def _update_sql_container_throughput_initial( + def _create_update_sql_stored_procedure_initial( # pylint: disable=name-too-long self, resource_group_name: str, account_name: str, database_name: str, container_name: str, - update_throughput_parameters: Union[_models.ThroughputSettingsUpdateParameters, IO[bytes]], + stored_procedure_name: str, + create_update_sql_stored_procedure_parameters: Union[ + _models.SqlStoredProcedureCreateUpdateParameters, IO[bytes] + ], **kwargs: Any ) -> Iterator[bytes]: error_map: MutableMapping = { @@ -4326,16 +4006,19 @@ def _update_sql_container_throughput_initial( content_type = content_type or "application/json" _json = None _content = None - if isinstance(update_throughput_parameters, (IOBase, bytes)): - _content = update_throughput_parameters + if isinstance(create_update_sql_stored_procedure_parameters, (IOBase, bytes)): + _content = create_update_sql_stored_procedure_parameters else: - _json = self._serialize.body(update_throughput_parameters, "ThroughputSettingsUpdateParameters") + _json = self._serialize.body( + create_update_sql_stored_procedure_parameters, "SqlStoredProcedureCreateUpdateParameters" + ) - _request = build_update_sql_container_throughput_request( + _request = build_create_update_sql_stored_procedure_request( resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, container_name=container_name, + stored_procedure_name=stored_procedure_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, @@ -4360,14 +4043,19 @@ def _update_sql_container_throughput_initial( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + 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["azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("azure-AsyncOperation") + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") ) - response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) @@ -4377,18 +4065,19 @@ def _update_sql_container_throughput_initial( return deserialized # type: ignore @overload - def begin_update_sql_container_throughput( + def begin_create_update_sql_stored_procedure( self, resource_group_name: str, account_name: str, database_name: str, container_name: str, - update_throughput_parameters: _models.ThroughputSettingsUpdateParameters, + stored_procedure_name: str, + create_update_sql_stored_procedure_parameters: _models.SqlStoredProcedureCreateUpdateParameters, *, content_type: str = "application/json", **kwargs: Any - ) -> LROPoller[_models.ThroughputSettingsGetResults]: - """Update RUs per second of an Azure Cosmos DB SQL container. + ) -> LROPoller[_models.SqlStoredProcedureGetResults]: + """Create or update an Azure Cosmos DB SQL storedProcedure. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -4399,32 +4088,35 @@ def begin_update_sql_container_throughput( :type database_name: str :param container_name: Cosmos DB container name. Required. :type container_name: str - :param update_throughput_parameters: The parameters to provide for the RUs per second of the - current SQL container. Required. - :type update_throughput_parameters: - ~azure.mgmt.cosmosdb.models.ThroughputSettingsUpdateParameters + :param stored_procedure_name: Cosmos DB storedProcedure name. Required. + :type stored_procedure_name: str + :param create_update_sql_stored_procedure_parameters: The parameters to provide for the current + SQL storedProcedure. Required. + :type create_update_sql_stored_procedure_parameters: + ~azure.mgmt.cosmosdb.models.SqlStoredProcedureCreateUpdateParameters :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 ThroughputSettingsGetResults or the + :return: An instance of LROPoller that returns either SqlStoredProcedureGetResults or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.ThroughputSettingsGetResults] + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.SqlStoredProcedureGetResults] :raises ~azure.core.exceptions.HttpResponseError: """ @overload - def begin_update_sql_container_throughput( + def begin_create_update_sql_stored_procedure( self, resource_group_name: str, account_name: str, database_name: str, container_name: str, - update_throughput_parameters: IO[bytes], + stored_procedure_name: str, + create_update_sql_stored_procedure_parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> LROPoller[_models.ThroughputSettingsGetResults]: - """Update RUs per second of an Azure Cosmos DB SQL container. + ) -> LROPoller[_models.SqlStoredProcedureGetResults]: + """Create or update an Azure Cosmos DB SQL storedProcedure. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -4435,29 +4127,34 @@ def begin_update_sql_container_throughput( :type database_name: str :param container_name: Cosmos DB container name. Required. :type container_name: str - :param update_throughput_parameters: The parameters to provide for the RUs per second of the - current SQL container. Required. - :type update_throughput_parameters: IO[bytes] + :param stored_procedure_name: Cosmos DB storedProcedure name. Required. + :type stored_procedure_name: str + :param create_update_sql_stored_procedure_parameters: The parameters to provide for the current + SQL storedProcedure. Required. + :type create_update_sql_stored_procedure_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 ThroughputSettingsGetResults or the + :return: An instance of LROPoller that returns either SqlStoredProcedureGetResults or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.ThroughputSettingsGetResults] + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.SqlStoredProcedureGetResults] :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace - def begin_update_sql_container_throughput( + def begin_create_update_sql_stored_procedure( self, resource_group_name: str, account_name: str, database_name: str, container_name: str, - update_throughput_parameters: Union[_models.ThroughputSettingsUpdateParameters, IO[bytes]], + stored_procedure_name: str, + create_update_sql_stored_procedure_parameters: Union[ + _models.SqlStoredProcedureCreateUpdateParameters, IO[bytes] + ], **kwargs: Any - ) -> LROPoller[_models.ThroughputSettingsGetResults]: - """Update RUs per second of an Azure Cosmos DB SQL container. + ) -> LROPoller[_models.SqlStoredProcedureGetResults]: + """Create or update an Azure Cosmos DB SQL storedProcedure. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -4468,14 +4165,16 @@ def begin_update_sql_container_throughput( :type database_name: str :param container_name: Cosmos DB container name. Required. :type container_name: str - :param update_throughput_parameters: The parameters to provide for the RUs per second of the - current SQL container. Is either a ThroughputSettingsUpdateParameters type or a IO[bytes] type. - Required. - :type update_throughput_parameters: - ~azure.mgmt.cosmosdb.models.ThroughputSettingsUpdateParameters or IO[bytes] - :return: An instance of LROPoller that returns either ThroughputSettingsGetResults or the + :param stored_procedure_name: Cosmos DB storedProcedure name. Required. + :type stored_procedure_name: str + :param create_update_sql_stored_procedure_parameters: The parameters to provide for the current + SQL storedProcedure. Is either a SqlStoredProcedureCreateUpdateParameters type or a IO[bytes] + type. Required. + :type create_update_sql_stored_procedure_parameters: + ~azure.mgmt.cosmosdb.models.SqlStoredProcedureCreateUpdateParameters or IO[bytes] + :return: An instance of LROPoller that returns either SqlStoredProcedureGetResults or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.ThroughputSettingsGetResults] + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.SqlStoredProcedureGetResults] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -4483,17 +4182,18 @@ def begin_update_sql_container_throughput( 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.ThroughputSettingsGetResults] = kwargs.pop("cls", None) + cls: ClsType[_models.SqlStoredProcedureGetResults] = 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_sql_container_throughput_initial( + raw_result = self._create_update_sql_stored_procedure_initial( resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, container_name=container_name, - update_throughput_parameters=update_throughput_parameters, + stored_procedure_name=stored_procedure_name, + create_update_sql_stored_procedure_parameters=create_update_sql_stored_procedure_parameters, api_version=api_version, content_type=content_type, cls=lambda x, y, z: x, @@ -4505,30 +4205,38 @@ def begin_update_sql_container_throughput( kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ThroughputSettingsGetResults", pipeline_response.http_response) + deserialized = self._deserialize("SqlStoredProcedureGetResults", 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, **kwargs)) + 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.ThroughputSettingsGetResults].from_continuation_token( + return LROPoller[_models.SqlStoredProcedureGetResults].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller[_models.ThroughputSettingsGetResults]( + return LROPoller[_models.SqlStoredProcedureGetResults]( self._client, raw_result, get_long_running_output, polling_method # type: ignore ) - def _migrate_sql_container_to_autoscale_initial( # pylint: disable=name-too-long - self, resource_group_name: str, account_name: str, database_name: str, container_name: str, **kwargs: Any + def _delete_sql_stored_procedure_initial( + self, + resource_group_name: str, + account_name: str, + database_name: str, + container_name: str, + stored_procedure_name: str, + **kwargs: Any ) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -4544,11 +4252,12 @@ def _migrate_sql_container_to_autoscale_initial( # pylint: disable=name-too-lon 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_migrate_sql_container_to_autoscale_request( + _request = build_delete_sql_stored_procedure_request( resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, container_name=container_name, + stored_procedure_name=stored_procedure_name, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, @@ -4564,20 +4273,24 @@ def _migrate_sql_container_to_autoscale_initial( # pylint: disable=name-too-lon response = pipeline_response.http_response - if response.status_code not in [200, 202]: + 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + 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["azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("azure-AsyncOperation") + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") ) - response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) @@ -4587,10 +4300,16 @@ def _migrate_sql_container_to_autoscale_initial( # pylint: disable=name-too-lon return deserialized # type: ignore @distributed_trace - def begin_migrate_sql_container_to_autoscale( - self, resource_group_name: str, account_name: str, database_name: str, container_name: str, **kwargs: Any - ) -> LROPoller[_models.ThroughputSettingsGetResults]: - """Migrate an Azure Cosmos DB SQL container from manual throughput to autoscale. + def begin_delete_sql_stored_procedure( + self, + resource_group_name: str, + account_name: str, + database_name: str, + container_name: str, + stored_procedure_name: str, + **kwargs: Any + ) -> LROPoller[None]: + """Deletes an existing Azure Cosmos DB SQL storedProcedure. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -4601,25 +4320,27 @@ def begin_migrate_sql_container_to_autoscale( :type database_name: str :param container_name: Cosmos DB container name. Required. :type container_name: str - :return: An instance of LROPoller that returns either ThroughputSettingsGetResults or the - result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.ThroughputSettingsGetResults] + :param stored_procedure_name: Cosmos DB storedProcedure name. Required. + :type stored_procedure_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[_models.ThroughputSettingsGetResults] = kwargs.pop("cls", 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._migrate_sql_container_to_autoscale_initial( + raw_result = self._delete_sql_stored_procedure_initial( resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, container_name=container_name, + stored_procedure_name=stored_procedure_name, api_version=api_version, cls=lambda x, y, z: x, headers=_headers, @@ -4629,32 +4350,47 @@ def begin_migrate_sql_container_to_autoscale( raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ThroughputSettingsGetResults", pipeline_response.http_response) + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return cls(pipeline_response, None, {}) # type: ignore if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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.ThroughputSettingsGetResults].from_continuation_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[_models.ThroughputSettingsGetResults]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - def _migrate_sql_container_to_manual_throughput_initial( # pylint: disable=name-too-long + @distributed_trace + def get_sql_container_throughput( self, resource_group_name: str, account_name: str, database_name: str, container_name: str, **kwargs: Any - ) -> Iterator[bytes]: + ) -> _models.ThroughputSettingsGetResults: + """Gets the RUs per second of the SQL container under an existing Azure Cosmos DB database + account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param database_name: Cosmos DB database name. Required. + :type database_name: str + :param container_name: Cosmos DB container name. Required. + :type container_name: str + :return: ThroughputSettingsGetResults or the result of cls(response) + :rtype: ~azure.mgmt.cosmosdb.models.ThroughputSettingsGetResults + :raises ~azure.core.exceptions.HttpResponseError: + """ error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -4667,15 +4403,84 @@ def _migrate_sql_container_to_manual_throughput_initial( # pylint: disable=name _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.ThroughputSettingsGetResults] = kwargs.pop("cls", None) + + _request = build_get_sql_container_throughput_request( + resource_group_name=resource_group_name, + account_name=account_name, + database_name=database_name, + container_name=container_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("ThroughputSettingsGetResults", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + def _update_sql_container_throughput_initial( + self, + resource_group_name: str, + account_name: str, + database_name: str, + container_name: str, + update_throughput_parameters: Union[_models.ThroughputSettingsUpdateParameters, 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) - _request = build_migrate_sql_container_to_manual_throughput_request( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(update_throughput_parameters, (IOBase, bytes)): + _content = update_throughput_parameters + else: + _json = self._serialize.body(update_throughput_parameters, "ThroughputSettingsUpdateParameters") + + _request = build_update_sql_container_throughput_request( resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, container_name=container_name, subscription_id=self._config.subscription_id, api_version=api_version, + content_type=content_type, + json=_json, + content=_content, headers=_headers, params=_params, ) @@ -4695,14 +4500,19 @@ def _migrate_sql_container_to_manual_throughput_initial( # pylint: disable=name except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + 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["azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("azure-AsyncOperation") + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") ) - response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) @@ -4711,11 +4521,88 @@ def _migrate_sql_container_to_manual_throughput_initial( # pylint: disable=name return deserialized # type: ignore + @overload + def begin_update_sql_container_throughput( + self, + resource_group_name: str, + account_name: str, + database_name: str, + container_name: str, + update_throughput_parameters: _models.ThroughputSettingsUpdateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ThroughputSettingsGetResults]: + """Update RUs per second of an Azure Cosmos DB SQL container. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param database_name: Cosmos DB database name. Required. + :type database_name: str + :param container_name: Cosmos DB container name. Required. + :type container_name: str + :param update_throughput_parameters: The parameters to provide for the RUs per second of the + current SQL container. Required. + :type update_throughput_parameters: + ~azure.mgmt.cosmosdb.models.ThroughputSettingsUpdateParameters + :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 ThroughputSettingsGetResults or the + result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.ThroughputSettingsGetResults] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update_sql_container_throughput( + self, + resource_group_name: str, + account_name: str, + database_name: str, + container_name: str, + update_throughput_parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ThroughputSettingsGetResults]: + """Update RUs per second of an Azure Cosmos DB SQL container. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param database_name: Cosmos DB database name. Required. + :type database_name: str + :param container_name: Cosmos DB container name. Required. + :type container_name: str + :param update_throughput_parameters: The parameters to provide for the RUs per second of the + current SQL container. Required. + :type update_throughput_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 ThroughputSettingsGetResults or the + result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.ThroughputSettingsGetResults] + :raises ~azure.core.exceptions.HttpResponseError: + """ + @distributed_trace - def begin_migrate_sql_container_to_manual_throughput( # pylint: disable=name-too-long - self, resource_group_name: str, account_name: str, database_name: str, container_name: str, **kwargs: Any + def begin_update_sql_container_throughput( + self, + resource_group_name: str, + account_name: str, + database_name: str, + container_name: str, + update_throughput_parameters: Union[_models.ThroughputSettingsUpdateParameters, IO[bytes]], + **kwargs: Any ) -> LROPoller[_models.ThroughputSettingsGetResults]: - """Migrate an Azure Cosmos DB SQL container from autoscale to manual throughput. + """Update RUs per second of an Azure Cosmos DB SQL container. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -4726,26 +4613,34 @@ def begin_migrate_sql_container_to_manual_throughput( # pylint: disable=name-to :type database_name: str :param container_name: Cosmos DB container name. Required. :type container_name: str + :param update_throughput_parameters: The parameters to provide for the RUs per second of the + current SQL container. Is either a ThroughputSettingsUpdateParameters type or a IO[bytes] type. + Required. + :type update_throughput_parameters: + ~azure.mgmt.cosmosdb.models.ThroughputSettingsUpdateParameters or IO[bytes] :return: An instance of LROPoller that returns either ThroughputSettingsGetResults or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.ThroughputSettingsGetResults] :raises ~azure.core.exceptions.HttpResponseError: """ - _headers = kwargs.pop("headers", {}) 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.ThroughputSettingsGetResults] = 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_sql_container_to_manual_throughput_initial( + raw_result = self._update_sql_container_throughput_initial( resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, container_name=container_name, + update_throughput_parameters=update_throughput_parameters, api_version=api_version, + content_type=content_type, cls=lambda x, y, z: x, headers=_headers, params=_params, @@ -4761,7 +4656,9 @@ def get_long_running_output(pipeline_response): return deserialized if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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: @@ -4777,13 +4674,8 @@ def get_long_running_output(pipeline_response): self._client, raw_result, get_long_running_output, polling_method # type: ignore ) - def _sql_database_retrieve_throughput_distribution_initial( # pylint: disable=name-too-long - self, - resource_group_name: str, - account_name: str, - database_name: str, - retrieve_throughput_parameters: Union[_models.RetrieveThroughputParameters, IO[bytes]], - **kwargs: Any + def _migrate_sql_container_to_autoscale_initial( # pylint: disable=name-too-long + self, resource_group_name: str, account_name: str, database_name: str, container_name: str, **kwargs: Any ) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -4793,30 +4685,19 @@ def _sql_database_retrieve_throughput_distribution_initial( # pylint: disable=n } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = case_insensitive_dict(kwargs.pop("headers", {}) 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)) - 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(retrieve_throughput_parameters, (IOBase, bytes)): - _content = retrieve_throughput_parameters - else: - _json = self._serialize.body(retrieve_throughput_parameters, "RetrieveThroughputParameters") - - _request = build_sql_database_retrieve_throughput_distribution_request( + _request = build_migrate_sql_container_to_autoscale_request( resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, + container_name=container_name, subscription_id=self._config.subscription_id, api_version=api_version, - content_type=content_type, - json=_json, - content=_content, headers=_headers, params=_params, ) @@ -4840,10 +4721,10 @@ def _sql_database_retrieve_throughput_distribution_initial( # pylint: disable=n response_headers = {} if response.status_code == 202: - response_headers["azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("azure-AsyncOperation") + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") ) - response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) @@ -4852,82 +4733,11 @@ def _sql_database_retrieve_throughput_distribution_initial( # pylint: disable=n return deserialized # type: ignore - @overload - def begin_sql_database_retrieve_throughput_distribution( # pylint: disable=name-too-long - self, - resource_group_name: str, - account_name: str, - database_name: str, - retrieve_throughput_parameters: _models.RetrieveThroughputParameters, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.PhysicalPartitionThroughputInfoResult]: - """Retrieve throughput distribution for an Azure Cosmos DB SQL database. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param account_name: Cosmos DB database account name. Required. - :type account_name: str - :param database_name: Cosmos DB database name. Required. - :type database_name: str - :param retrieve_throughput_parameters: The parameters to provide for retrieving throughput - distribution for the current SQL database. Required. - :type retrieve_throughput_parameters: ~azure.mgmt.cosmosdb.models.RetrieveThroughputParameters - :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 PhysicalPartitionThroughputInfoResult or - the result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.PhysicalPartitionThroughputInfoResult] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_sql_database_retrieve_throughput_distribution( # pylint: disable=name-too-long - self, - resource_group_name: str, - account_name: str, - database_name: str, - retrieve_throughput_parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.PhysicalPartitionThroughputInfoResult]: - """Retrieve throughput distribution for an Azure Cosmos DB SQL database. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param account_name: Cosmos DB database account name. Required. - :type account_name: str - :param database_name: Cosmos DB database name. Required. - :type database_name: str - :param retrieve_throughput_parameters: The parameters to provide for retrieving throughput - distribution for the current SQL database. Required. - :type retrieve_throughput_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 PhysicalPartitionThroughputInfoResult or - the result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.PhysicalPartitionThroughputInfoResult] - :raises ~azure.core.exceptions.HttpResponseError: - """ - @distributed_trace - def begin_sql_database_retrieve_throughput_distribution( # pylint: disable=name-too-long - self, - resource_group_name: str, - account_name: str, - database_name: str, - retrieve_throughput_parameters: Union[_models.RetrieveThroughputParameters, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.PhysicalPartitionThroughputInfoResult]: - """Retrieve throughput distribution for an Azure Cosmos DB SQL database. + def begin_migrate_sql_container_to_autoscale( + self, resource_group_name: str, account_name: str, database_name: str, container_name: str, **kwargs: Any + ) -> LROPoller[_models.ThroughputSettingsGetResults]: + """Migrate an Azure Cosmos DB SQL container from manual throughput to autoscale. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -4936,34 +4746,28 @@ def begin_sql_database_retrieve_throughput_distribution( # pylint: disable=name :type account_name: str :param database_name: Cosmos DB database name. Required. :type database_name: str - :param retrieve_throughput_parameters: The parameters to provide for retrieving throughput - distribution for the current SQL database. Is either a RetrieveThroughputParameters type or a - IO[bytes] type. Required. - :type retrieve_throughput_parameters: ~azure.mgmt.cosmosdb.models.RetrieveThroughputParameters - or IO[bytes] - :return: An instance of LROPoller that returns either PhysicalPartitionThroughputInfoResult or - the result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.PhysicalPartitionThroughputInfoResult] + :param container_name: Cosmos DB container name. Required. + :type container_name: str + :return: An instance of LROPoller that returns either ThroughputSettingsGetResults or the + result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.ThroughputSettingsGetResults] :raises ~azure.core.exceptions.HttpResponseError: """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) 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)) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.PhysicalPartitionThroughputInfoResult] = kwargs.pop("cls", None) + cls: ClsType[_models.ThroughputSettingsGetResults] = 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._sql_database_retrieve_throughput_distribution_initial( + raw_result = self._migrate_sql_container_to_autoscale_initial( resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, - retrieve_throughput_parameters=retrieve_throughput_parameters, + container_name=container_name, api_version=api_version, - content_type=content_type, cls=lambda x, y, z: x, headers=_headers, params=_params, @@ -4973,7 +4777,7 @@ def begin_sql_database_retrieve_throughput_distribution( # pylint: disable=name kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("PhysicalPartitionThroughputInfoResult", pipeline_response.http_response) + deserialized = self._deserialize("ThroughputSettingsGetResults", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized @@ -4987,23 +4791,18 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller[_models.PhysicalPartitionThroughputInfoResult].from_continuation_token( + return LROPoller[_models.ThroughputSettingsGetResults].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller[_models.PhysicalPartitionThroughputInfoResult]( + return LROPoller[_models.ThroughputSettingsGetResults]( self._client, raw_result, get_long_running_output, polling_method # type: ignore ) - def _sql_database_redistribute_throughput_initial( # pylint: disable=name-too-long - self, - resource_group_name: str, - account_name: str, - database_name: str, - redistribute_throughput_parameters: Union[_models.RedistributeThroughputParameters, IO[bytes]], - **kwargs: Any + def _migrate_sql_container_to_manual_throughput_initial( # pylint: disable=name-too-long + self, resource_group_name: str, account_name: str, database_name: str, container_name: str, **kwargs: Any ) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -5013,30 +4812,19 @@ def _sql_database_redistribute_throughput_initial( # pylint: disable=name-too-l } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = case_insensitive_dict(kwargs.pop("headers", {}) 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)) - 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(redistribute_throughput_parameters, (IOBase, bytes)): - _content = redistribute_throughput_parameters - else: - _json = self._serialize.body(redistribute_throughput_parameters, "RedistributeThroughputParameters") - - _request = build_sql_database_redistribute_throughput_request( + _request = build_migrate_sql_container_to_manual_throughput_request( resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, + container_name=container_name, subscription_id=self._config.subscription_id, api_version=api_version, - content_type=content_type, - json=_json, - content=_content, headers=_headers, params=_params, ) @@ -5060,95 +4848,23 @@ def _sql_database_redistribute_throughput_initial( # pylint: disable=name-too-l response_headers = {} if response.status_code == 202: - response_headers["azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("azure-AsyncOperation") + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") ) - response_headers["location"] = self._deserialize("str", response.headers.get("location")) - - 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_sql_database_redistribute_throughput( # pylint: disable=name-too-long - self, - resource_group_name: str, - account_name: str, - database_name: str, - redistribute_throughput_parameters: _models.RedistributeThroughputParameters, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.PhysicalPartitionThroughputInfoResult]: - """Redistribute throughput for an Azure Cosmos DB SQL database. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param account_name: Cosmos DB database account name. Required. - :type account_name: str - :param database_name: Cosmos DB database name. Required. - :type database_name: str - :param redistribute_throughput_parameters: The parameters to provide for redistributing - throughput for the current SQL database. Required. - :type redistribute_throughput_parameters: - ~azure.mgmt.cosmosdb.models.RedistributeThroughputParameters - :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 PhysicalPartitionThroughputInfoResult or - the result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.PhysicalPartitionThroughputInfoResult] - :raises ~azure.core.exceptions.HttpResponseError: - """ + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - @overload - def begin_sql_database_redistribute_throughput( # pylint: disable=name-too-long - self, - resource_group_name: str, - account_name: str, - database_name: str, - redistribute_throughput_parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.PhysicalPartitionThroughputInfoResult]: - """Redistribute throughput for an Azure Cosmos DB SQL database. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param account_name: Cosmos DB database account name. Required. - :type account_name: str - :param database_name: Cosmos DB database name. Required. - :type database_name: str - :param redistribute_throughput_parameters: The parameters to provide for redistributing - throughput for the current SQL database. Required. - :type redistribute_throughput_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 PhysicalPartitionThroughputInfoResult or - the result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.PhysicalPartitionThroughputInfoResult] - :raises ~azure.core.exceptions.HttpResponseError: - """ + 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_sql_database_redistribute_throughput( # pylint: disable=name-too-long - self, - resource_group_name: str, - account_name: str, - database_name: str, - redistribute_throughput_parameters: Union[_models.RedistributeThroughputParameters, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.PhysicalPartitionThroughputInfoResult]: - """Redistribute throughput for an Azure Cosmos DB SQL database. + def begin_migrate_sql_container_to_manual_throughput( # pylint: disable=name-too-long + self, resource_group_name: str, account_name: str, database_name: str, container_name: str, **kwargs: Any + ) -> LROPoller[_models.ThroughputSettingsGetResults]: + """Migrate an Azure Cosmos DB SQL container from autoscale to manual throughput. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -5157,34 +4873,28 @@ def begin_sql_database_redistribute_throughput( # pylint: disable=name-too-long :type account_name: str :param database_name: Cosmos DB database name. Required. :type database_name: str - :param redistribute_throughput_parameters: The parameters to provide for redistributing - throughput for the current SQL database. Is either a RedistributeThroughputParameters type or a - IO[bytes] type. Required. - :type redistribute_throughput_parameters: - ~azure.mgmt.cosmosdb.models.RedistributeThroughputParameters or IO[bytes] - :return: An instance of LROPoller that returns either PhysicalPartitionThroughputInfoResult or - the result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.PhysicalPartitionThroughputInfoResult] + :param container_name: Cosmos DB container name. Required. + :type container_name: str + :return: An instance of LROPoller that returns either ThroughputSettingsGetResults or the + result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.ThroughputSettingsGetResults] :raises ~azure.core.exceptions.HttpResponseError: """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) 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)) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.PhysicalPartitionThroughputInfoResult] = kwargs.pop("cls", None) + cls: ClsType[_models.ThroughputSettingsGetResults] = 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._sql_database_redistribute_throughput_initial( + raw_result = self._migrate_sql_container_to_manual_throughput_initial( resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, - redistribute_throughput_parameters=redistribute_throughput_parameters, + container_name=container_name, api_version=api_version, - content_type=content_type, cls=lambda x, y, z: x, headers=_headers, params=_params, @@ -5194,7 +4904,7 @@ def begin_sql_database_redistribute_throughput( # pylint: disable=name-too-long kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("PhysicalPartitionThroughputInfoResult", pipeline_response.http_response) + deserialized = self._deserialize("ThroughputSettingsGetResults", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized @@ -5208,23 +4918,23 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller[_models.PhysicalPartitionThroughputInfoResult].from_continuation_token( + return LROPoller[_models.ThroughputSettingsGetResults].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller[_models.PhysicalPartitionThroughputInfoResult]( + return LROPoller[_models.ThroughputSettingsGetResults]( self._client, raw_result, get_long_running_output, polling_method # type: ignore ) - def _sql_container_retrieve_throughput_distribution_initial( # pylint: disable=name-too-long + def _sql_container_redistribute_throughput_initial( # pylint: disable=name-too-long self, resource_group_name: str, account_name: str, database_name: str, container_name: str, - retrieve_throughput_parameters: Union[_models.RetrieveThroughputParameters, IO[bytes]], + redistribute_throughput_parameters: Union[_models.RedistributeThroughputParameters, IO[bytes]], **kwargs: Any ) -> Iterator[bytes]: error_map: MutableMapping = { @@ -5245,12 +4955,12 @@ def _sql_container_retrieve_throughput_distribution_initial( # pylint: disable= content_type = content_type or "application/json" _json = None _content = None - if isinstance(retrieve_throughput_parameters, (IOBase, bytes)): - _content = retrieve_throughput_parameters + if isinstance(redistribute_throughput_parameters, (IOBase, bytes)): + _content = redistribute_throughput_parameters else: - _json = self._serialize.body(retrieve_throughput_parameters, "RetrieveThroughputParameters") + _json = self._serialize.body(redistribute_throughput_parameters, "RedistributeThroughputParameters") - _request = build_sql_container_retrieve_throughput_distribution_request( + _request = build_sql_container_redistribute_throughput_request( resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, @@ -5283,10 +4993,10 @@ def _sql_container_retrieve_throughput_distribution_initial( # pylint: disable= response_headers = {} if response.status_code == 202: - response_headers["azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("azure-AsyncOperation") + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") ) - response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) @@ -5296,18 +5006,18 @@ def _sql_container_retrieve_throughput_distribution_initial( # pylint: disable= return deserialized # type: ignore @overload - def begin_sql_container_retrieve_throughput_distribution( # pylint: disable=name-too-long + def begin_sql_container_redistribute_throughput( # pylint: disable=name-too-long self, resource_group_name: str, account_name: str, database_name: str, container_name: str, - retrieve_throughput_parameters: _models.RetrieveThroughputParameters, + redistribute_throughput_parameters: _models.RedistributeThroughputParameters, *, content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.PhysicalPartitionThroughputInfoResult]: - """Retrieve throughput distribution for an Azure Cosmos DB SQL container. + """Redistribute throughput for an Azure Cosmos DB SQL container. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -5318,9 +5028,10 @@ def begin_sql_container_retrieve_throughput_distribution( # pylint: disable=nam :type database_name: str :param container_name: Cosmos DB container name. Required. :type container_name: str - :param retrieve_throughput_parameters: The parameters to provide for retrieving throughput - distribution for the current SQL container. Required. - :type retrieve_throughput_parameters: ~azure.mgmt.cosmosdb.models.RetrieveThroughputParameters + :param redistribute_throughput_parameters: The parameters to provide for redistributing + throughput for the current SQL container. Required. + :type redistribute_throughput_parameters: + ~azure.mgmt.cosmosdb.models.RedistributeThroughputParameters :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str @@ -5332,18 +5043,18 @@ def begin_sql_container_retrieve_throughput_distribution( # pylint: disable=nam """ @overload - def begin_sql_container_retrieve_throughput_distribution( # pylint: disable=name-too-long + def begin_sql_container_redistribute_throughput( # pylint: disable=name-too-long self, resource_group_name: str, account_name: str, database_name: str, container_name: str, - retrieve_throughput_parameters: IO[bytes], + redistribute_throughput_parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.PhysicalPartitionThroughputInfoResult]: - """Retrieve throughput distribution for an Azure Cosmos DB SQL container. + """Redistribute throughput for an Azure Cosmos DB SQL container. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -5354,9 +5065,9 @@ def begin_sql_container_retrieve_throughput_distribution( # pylint: disable=nam :type database_name: str :param container_name: Cosmos DB container name. Required. :type container_name: str - :param retrieve_throughput_parameters: The parameters to provide for retrieving throughput - distribution for the current SQL container. Required. - :type retrieve_throughput_parameters: IO[bytes] + :param redistribute_throughput_parameters: The parameters to provide for redistributing + throughput for the current SQL container. Required. + :type redistribute_throughput_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 @@ -5368,16 +5079,16 @@ def begin_sql_container_retrieve_throughput_distribution( # pylint: disable=nam """ @distributed_trace - def begin_sql_container_retrieve_throughput_distribution( # pylint: disable=name-too-long + def begin_sql_container_redistribute_throughput( # pylint: disable=name-too-long self, resource_group_name: str, account_name: str, database_name: str, container_name: str, - retrieve_throughput_parameters: Union[_models.RetrieveThroughputParameters, IO[bytes]], + redistribute_throughput_parameters: Union[_models.RedistributeThroughputParameters, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.PhysicalPartitionThroughputInfoResult]: - """Retrieve throughput distribution for an Azure Cosmos DB SQL container. + """Redistribute throughput for an Azure Cosmos DB SQL container. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -5388,11 +5099,11 @@ def begin_sql_container_retrieve_throughput_distribution( # pylint: disable=nam :type database_name: str :param container_name: Cosmos DB container name. Required. :type container_name: str - :param retrieve_throughput_parameters: The parameters to provide for retrieving throughput - distribution for the current SQL container. Is either a RetrieveThroughputParameters type or a - IO[bytes] type. Required. - :type retrieve_throughput_parameters: ~azure.mgmt.cosmosdb.models.RetrieveThroughputParameters - or IO[bytes] + :param redistribute_throughput_parameters: The parameters to provide for redistributing + throughput for the current SQL container. Is either a RedistributeThroughputParameters type or + a IO[bytes] type. Required. + :type redistribute_throughput_parameters: + ~azure.mgmt.cosmosdb.models.RedistributeThroughputParameters or IO[bytes] :return: An instance of LROPoller that returns either PhysicalPartitionThroughputInfoResult or the result of cls(response) :rtype: @@ -5409,12 +5120,12 @@ def begin_sql_container_retrieve_throughput_distribution( # pylint: disable=nam 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._sql_container_retrieve_throughput_distribution_initial( + raw_result = self._sql_container_redistribute_throughput_initial( resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, container_name=container_name, - retrieve_throughput_parameters=retrieve_throughput_parameters, + redistribute_throughput_parameters=redistribute_throughput_parameters, api_version=api_version, content_type=content_type, cls=lambda x, y, z: x, @@ -5450,13 +5161,13 @@ def get_long_running_output(pipeline_response): self._client, raw_result, get_long_running_output, polling_method # type: ignore ) - def _sql_container_redistribute_throughput_initial( # pylint: disable=name-too-long + def _sql_container_retrieve_throughput_distribution_initial( # pylint: disable=name-too-long self, resource_group_name: str, account_name: str, database_name: str, container_name: str, - redistribute_throughput_parameters: Union[_models.RedistributeThroughputParameters, IO[bytes]], + retrieve_throughput_parameters: Union[_models.RetrieveThroughputParameters, IO[bytes]], **kwargs: Any ) -> Iterator[bytes]: error_map: MutableMapping = { @@ -5477,12 +5188,12 @@ def _sql_container_redistribute_throughput_initial( # pylint: disable=name-too- content_type = content_type or "application/json" _json = None _content = None - if isinstance(redistribute_throughput_parameters, (IOBase, bytes)): - _content = redistribute_throughput_parameters + if isinstance(retrieve_throughput_parameters, (IOBase, bytes)): + _content = retrieve_throughput_parameters else: - _json = self._serialize.body(redistribute_throughput_parameters, "RedistributeThroughputParameters") + _json = self._serialize.body(retrieve_throughput_parameters, "RetrieveThroughputParameters") - _request = build_sql_container_redistribute_throughput_request( + _request = build_sql_container_retrieve_throughput_distribution_request( resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, @@ -5515,10 +5226,10 @@ def _sql_container_redistribute_throughput_initial( # pylint: disable=name-too- response_headers = {} if response.status_code == 202: - response_headers["azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("azure-AsyncOperation") + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") ) - response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) @@ -5528,18 +5239,18 @@ def _sql_container_redistribute_throughput_initial( # pylint: disable=name-too- return deserialized # type: ignore @overload - def begin_sql_container_redistribute_throughput( # pylint: disable=name-too-long + def begin_sql_container_retrieve_throughput_distribution( # pylint: disable=name-too-long self, resource_group_name: str, account_name: str, database_name: str, container_name: str, - redistribute_throughput_parameters: _models.RedistributeThroughputParameters, + retrieve_throughput_parameters: _models.RetrieveThroughputParameters, *, content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.PhysicalPartitionThroughputInfoResult]: - """Redistribute throughput for an Azure Cosmos DB SQL container. + """Retrieve throughput distribution for an Azure Cosmos DB SQL container. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -5550,10 +5261,9 @@ def begin_sql_container_redistribute_throughput( # pylint: disable=name-too-lon :type database_name: str :param container_name: Cosmos DB container name. Required. :type container_name: str - :param redistribute_throughput_parameters: The parameters to provide for redistributing - throughput for the current SQL container. Required. - :type redistribute_throughput_parameters: - ~azure.mgmt.cosmosdb.models.RedistributeThroughputParameters + :param retrieve_throughput_parameters: The parameters to provide for retrieving throughput + distribution for the current SQL container. Required. + :type retrieve_throughput_parameters: ~azure.mgmt.cosmosdb.models.RetrieveThroughputParameters :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str @@ -5565,18 +5275,18 @@ def begin_sql_container_redistribute_throughput( # pylint: disable=name-too-lon """ @overload - def begin_sql_container_redistribute_throughput( # pylint: disable=name-too-long + def begin_sql_container_retrieve_throughput_distribution( # pylint: disable=name-too-long self, resource_group_name: str, account_name: str, database_name: str, container_name: str, - redistribute_throughput_parameters: IO[bytes], + retrieve_throughput_parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.PhysicalPartitionThroughputInfoResult]: - """Redistribute throughput for an Azure Cosmos DB SQL container. + """Retrieve throughput distribution for an Azure Cosmos DB SQL container. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -5587,9 +5297,9 @@ def begin_sql_container_redistribute_throughput( # pylint: disable=name-too-lon :type database_name: str :param container_name: Cosmos DB container name. Required. :type container_name: str - :param redistribute_throughput_parameters: The parameters to provide for redistributing - throughput for the current SQL container. Required. - :type redistribute_throughput_parameters: IO[bytes] + :param retrieve_throughput_parameters: The parameters to provide for retrieving throughput + distribution for the current SQL container. Required. + :type retrieve_throughput_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 @@ -5601,16 +5311,16 @@ def begin_sql_container_redistribute_throughput( # pylint: disable=name-too-lon """ @distributed_trace - def begin_sql_container_redistribute_throughput( # pylint: disable=name-too-long + def begin_sql_container_retrieve_throughput_distribution( # pylint: disable=name-too-long self, resource_group_name: str, account_name: str, database_name: str, container_name: str, - redistribute_throughput_parameters: Union[_models.RedistributeThroughputParameters, IO[bytes]], + retrieve_throughput_parameters: Union[_models.RetrieveThroughputParameters, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.PhysicalPartitionThroughputInfoResult]: - """Redistribute throughput for an Azure Cosmos DB SQL container. + """Retrieve throughput distribution for an Azure Cosmos DB SQL container. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -5621,11 +5331,11 @@ def begin_sql_container_redistribute_throughput( # pylint: disable=name-too-lon :type database_name: str :param container_name: Cosmos DB container name. Required. :type container_name: str - :param redistribute_throughput_parameters: The parameters to provide for redistributing - throughput for the current SQL container. Is either a RedistributeThroughputParameters type or - a IO[bytes] type. Required. - :type redistribute_throughput_parameters: - ~azure.mgmt.cosmosdb.models.RedistributeThroughputParameters or IO[bytes] + :param retrieve_throughput_parameters: The parameters to provide for retrieving throughput + distribution for the current SQL container. Is either a RetrieveThroughputParameters type or a + IO[bytes] type. Required. + :type retrieve_throughput_parameters: ~azure.mgmt.cosmosdb.models.RetrieveThroughputParameters + or IO[bytes] :return: An instance of LROPoller that returns either PhysicalPartitionThroughputInfoResult or the result of cls(response) :rtype: @@ -5642,12 +5352,12 @@ def begin_sql_container_redistribute_throughput( # pylint: disable=name-too-lon 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._sql_container_redistribute_throughput_initial( + raw_result = self._sql_container_retrieve_throughput_distribution_initial( resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, container_name=container_name, - redistribute_throughput_parameters=redistribute_throughput_parameters, + retrieve_throughput_parameters=retrieve_throughput_parameters, api_version=api_version, content_type=content_type, cls=lambda x, y, z: x, @@ -5684,10 +5394,10 @@ def get_long_running_output(pipeline_response): ) @distributed_trace - def list_sql_stored_procedures( + def list_sql_triggers( self, resource_group_name: str, account_name: str, database_name: str, container_name: str, **kwargs: Any - ) -> ItemPaged["_models.SqlStoredProcedureGetResults"]: - """Lists the SQL storedProcedure under an existing Azure Cosmos DB database account. + ) -> ItemPaged["_models.SqlTriggerGetResults"]: + """Lists the SQL trigger under an existing Azure Cosmos DB database account. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -5698,16 +5408,16 @@ def list_sql_stored_procedures( :type database_name: str :param container_name: Cosmos DB container name. Required. :type container_name: str - :return: An iterator like instance of either SqlStoredProcedureGetResults or the result of + :return: An iterator like instance of either SqlTriggerGetResults or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cosmosdb.models.SqlStoredProcedureGetResults] + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cosmosdb.models.SqlTriggerGetResults] :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.SqlStoredProcedureListResult] = kwargs.pop("cls", None) + cls: ClsType[_models.SqlTriggerListResult] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -5720,7 +5430,7 @@ def list_sql_stored_procedures( def prepare_request(next_link=None): if not next_link: - _request = build_list_sql_stored_procedures_request( + _request = build_list_sql_triggers_request( resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, @@ -5750,11 +5460,11 @@ def prepare_request(next_link=None): return _request def extract_data(pipeline_response): - deserialized = self._deserialize("SqlStoredProcedureListResult", pipeline_response) + deserialized = self._deserialize("SqlTriggerListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore - return None, iter(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): _request = prepare_request(next_link) @@ -5767,23 +5477,27 @@ 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + 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_sql_stored_procedure( + def get_sql_trigger( self, resource_group_name: str, account_name: str, database_name: str, container_name: str, - stored_procedure_name: str, + trigger_name: str, **kwargs: Any - ) -> _models.SqlStoredProcedureGetResults: - """Gets the SQL storedProcedure under an existing Azure Cosmos DB database account. + ) -> _models.SqlTriggerGetResults: + """Gets the SQL trigger under an existing Azure Cosmos DB database account. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -5794,10 +5508,10 @@ def get_sql_stored_procedure( :type database_name: str :param container_name: Cosmos DB container name. Required. :type container_name: str - :param stored_procedure_name: Cosmos DB storedProcedure name. Required. - :type stored_procedure_name: str - :return: SqlStoredProcedureGetResults or the result of cls(response) - :rtype: ~azure.mgmt.cosmosdb.models.SqlStoredProcedureGetResults + :param trigger_name: Cosmos DB trigger name. Required. + :type trigger_name: str + :return: SqlTriggerGetResults or the result of cls(response) + :rtype: ~azure.mgmt.cosmosdb.models.SqlTriggerGetResults :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -5812,14 +5526,14 @@ def get_sql_stored_procedure( _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.SqlStoredProcedureGetResults] = kwargs.pop("cls", None) + cls: ClsType[_models.SqlTriggerGetResults] = kwargs.pop("cls", None) - _request = build_get_sql_stored_procedure_request( + _request = build_get_sql_trigger_request( resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, container_name=container_name, - stored_procedure_name=stored_procedure_name, + trigger_name=trigger_name, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, @@ -5836,25 +5550,27 @@ def get_sql_stored_procedure( if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("SqlStoredProcedureGetResults", pipeline_response.http_response) + deserialized = self._deserialize("SqlTriggerGetResults", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - def _create_update_sql_stored_procedure_initial( # pylint: disable=name-too-long + def _create_update_sql_trigger_initial( self, resource_group_name: str, account_name: str, database_name: str, container_name: str, - stored_procedure_name: str, - create_update_sql_stored_procedure_parameters: Union[ - _models.SqlStoredProcedureCreateUpdateParameters, IO[bytes] - ], + trigger_name: str, + create_update_sql_trigger_parameters: Union[_models.SqlTriggerCreateUpdateParameters, IO[bytes]], **kwargs: Any ) -> Iterator[bytes]: error_map: MutableMapping = { @@ -5875,19 +5591,17 @@ def _create_update_sql_stored_procedure_initial( # pylint: disable=name-too-lon content_type = content_type or "application/json" _json = None _content = None - if isinstance(create_update_sql_stored_procedure_parameters, (IOBase, bytes)): - _content = create_update_sql_stored_procedure_parameters + if isinstance(create_update_sql_trigger_parameters, (IOBase, bytes)): + _content = create_update_sql_trigger_parameters else: - _json = self._serialize.body( - create_update_sql_stored_procedure_parameters, "SqlStoredProcedureCreateUpdateParameters" - ) + _json = self._serialize.body(create_update_sql_trigger_parameters, "SqlTriggerCreateUpdateParameters") - _request = build_create_update_sql_stored_procedure_request( + _request = build_create_update_sql_trigger_request( resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, container_name=container_name, - stored_procedure_name=stored_procedure_name, + trigger_name=trigger_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, @@ -5912,14 +5626,19 @@ def _create_update_sql_stored_procedure_initial( # pylint: disable=name-too-lon except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + 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["azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("azure-AsyncOperation") + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") ) - response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) @@ -5929,19 +5648,19 @@ def _create_update_sql_stored_procedure_initial( # pylint: disable=name-too-lon return deserialized # type: ignore @overload - def begin_create_update_sql_stored_procedure( + def begin_create_update_sql_trigger( self, resource_group_name: str, account_name: str, database_name: str, container_name: str, - stored_procedure_name: str, - create_update_sql_stored_procedure_parameters: _models.SqlStoredProcedureCreateUpdateParameters, + trigger_name: str, + create_update_sql_trigger_parameters: _models.SqlTriggerCreateUpdateParameters, *, content_type: str = "application/json", **kwargs: Any - ) -> LROPoller[_models.SqlStoredProcedureGetResults]: - """Create or update an Azure Cosmos DB SQL storedProcedure. + ) -> LROPoller[_models.SqlTriggerGetResults]: + """Create or update an Azure Cosmos DB SQL trigger. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -5952,35 +5671,35 @@ def begin_create_update_sql_stored_procedure( :type database_name: str :param container_name: Cosmos DB container name. Required. :type container_name: str - :param stored_procedure_name: Cosmos DB storedProcedure name. Required. - :type stored_procedure_name: str - :param create_update_sql_stored_procedure_parameters: The parameters to provide for the current - SQL storedProcedure. Required. - :type create_update_sql_stored_procedure_parameters: - ~azure.mgmt.cosmosdb.models.SqlStoredProcedureCreateUpdateParameters + :param trigger_name: Cosmos DB trigger name. Required. + :type trigger_name: str + :param create_update_sql_trigger_parameters: The parameters to provide for the current SQL + trigger. Required. + :type create_update_sql_trigger_parameters: + ~azure.mgmt.cosmosdb.models.SqlTriggerCreateUpdateParameters :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 SqlStoredProcedureGetResults or the - result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.SqlStoredProcedureGetResults] + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns either SqlTriggerGetResults or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.SqlTriggerGetResults] :raises ~azure.core.exceptions.HttpResponseError: """ @overload - def begin_create_update_sql_stored_procedure( + def begin_create_update_sql_trigger( self, resource_group_name: str, account_name: str, database_name: str, container_name: str, - stored_procedure_name: str, - create_update_sql_stored_procedure_parameters: IO[bytes], + trigger_name: str, + create_update_sql_trigger_parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> LROPoller[_models.SqlStoredProcedureGetResults]: - """Create or update an Azure Cosmos DB SQL storedProcedure. + ) -> LROPoller[_models.SqlTriggerGetResults]: + """Create or update an Azure Cosmos DB SQL trigger. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -5991,34 +5710,32 @@ def begin_create_update_sql_stored_procedure( :type database_name: str :param container_name: Cosmos DB container name. Required. :type container_name: str - :param stored_procedure_name: Cosmos DB storedProcedure name. Required. - :type stored_procedure_name: str - :param create_update_sql_stored_procedure_parameters: The parameters to provide for the current - SQL storedProcedure. Required. - :type create_update_sql_stored_procedure_parameters: IO[bytes] + :param trigger_name: Cosmos DB trigger name. Required. + :type trigger_name: str + :param create_update_sql_trigger_parameters: The parameters to provide for the current SQL + trigger. Required. + :type create_update_sql_trigger_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 SqlStoredProcedureGetResults or the - result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.SqlStoredProcedureGetResults] + :return: An instance of LROPoller that returns either SqlTriggerGetResults or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.SqlTriggerGetResults] :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace - def begin_create_update_sql_stored_procedure( + def begin_create_update_sql_trigger( self, resource_group_name: str, account_name: str, database_name: str, container_name: str, - stored_procedure_name: str, - create_update_sql_stored_procedure_parameters: Union[ - _models.SqlStoredProcedureCreateUpdateParameters, IO[bytes] - ], + trigger_name: str, + create_update_sql_trigger_parameters: Union[_models.SqlTriggerCreateUpdateParameters, IO[bytes]], **kwargs: Any - ) -> LROPoller[_models.SqlStoredProcedureGetResults]: - """Create or update an Azure Cosmos DB SQL storedProcedure. + ) -> LROPoller[_models.SqlTriggerGetResults]: + """Create or update an Azure Cosmos DB SQL trigger. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -6029,16 +5746,15 @@ def begin_create_update_sql_stored_procedure( :type database_name: str :param container_name: Cosmos DB container name. Required. :type container_name: str - :param stored_procedure_name: Cosmos DB storedProcedure name. Required. - :type stored_procedure_name: str - :param create_update_sql_stored_procedure_parameters: The parameters to provide for the current - SQL storedProcedure. Is either a SqlStoredProcedureCreateUpdateParameters type or a IO[bytes] - type. Required. - :type create_update_sql_stored_procedure_parameters: - ~azure.mgmt.cosmosdb.models.SqlStoredProcedureCreateUpdateParameters or IO[bytes] - :return: An instance of LROPoller that returns either SqlStoredProcedureGetResults or the - result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.SqlStoredProcedureGetResults] + :param trigger_name: Cosmos DB trigger name. Required. + :type trigger_name: str + :param create_update_sql_trigger_parameters: The parameters to provide for the current SQL + trigger. Is either a SqlTriggerCreateUpdateParameters type or a IO[bytes] type. Required. + :type create_update_sql_trigger_parameters: + ~azure.mgmt.cosmosdb.models.SqlTriggerCreateUpdateParameters or IO[bytes] + :return: An instance of LROPoller that returns either SqlTriggerGetResults or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.SqlTriggerGetResults] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -6046,18 +5762,18 @@ def begin_create_update_sql_stored_procedure( 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.SqlStoredProcedureGetResults] = kwargs.pop("cls", None) + cls: ClsType[_models.SqlTriggerGetResults] = 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_update_sql_stored_procedure_initial( + raw_result = self._create_update_sql_trigger_initial( resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, container_name=container_name, - stored_procedure_name=stored_procedure_name, - create_update_sql_stored_procedure_parameters=create_update_sql_stored_procedure_parameters, + trigger_name=trigger_name, + create_update_sql_trigger_parameters=create_update_sql_trigger_parameters, api_version=api_version, content_type=content_type, cls=lambda x, y, z: x, @@ -6069,35 +5785,37 @@ def begin_create_update_sql_stored_procedure( kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("SqlStoredProcedureGetResults", pipeline_response.http_response) + deserialized = self._deserialize("SqlTriggerGetResults", 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, **kwargs)) + 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.SqlStoredProcedureGetResults].from_continuation_token( + return LROPoller[_models.SqlTriggerGetResults].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller[_models.SqlStoredProcedureGetResults]( + return LROPoller[_models.SqlTriggerGetResults]( self._client, raw_result, get_long_running_output, polling_method # type: ignore ) - def _delete_sql_stored_procedure_initial( + def _delete_sql_trigger_initial( self, resource_group_name: str, account_name: str, database_name: str, container_name: str, - stored_procedure_name: str, + trigger_name: str, **kwargs: Any ) -> Iterator[bytes]: error_map: MutableMapping = { @@ -6114,12 +5832,12 @@ def _delete_sql_stored_procedure_initial( 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_sql_stored_procedure_request( + _request = build_delete_sql_trigger_request( resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, container_name=container_name, - stored_procedure_name=stored_procedure_name, + trigger_name=trigger_name, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, @@ -6141,14 +5859,18 @@ def _delete_sql_stored_procedure_initial( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + 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["azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("azure-AsyncOperation") + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") ) - response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) @@ -6158,16 +5880,16 @@ def _delete_sql_stored_procedure_initial( return deserialized # type: ignore @distributed_trace - def begin_delete_sql_stored_procedure( + def begin_delete_sql_trigger( self, resource_group_name: str, account_name: str, database_name: str, container_name: str, - stored_procedure_name: str, + trigger_name: str, **kwargs: Any ) -> LROPoller[None]: - """Deletes an existing Azure Cosmos DB SQL storedProcedure. + """Deletes an existing Azure Cosmos DB SQL trigger. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -6178,8 +5900,8 @@ def begin_delete_sql_stored_procedure( :type database_name: str :param container_name: Cosmos DB container name. Required. :type container_name: str - :param stored_procedure_name: Cosmos DB storedProcedure name. Required. - :type stored_procedure_name: str + :param trigger_name: Cosmos DB trigger name. Required. + :type trigger_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: @@ -6193,12 +5915,12 @@ def begin_delete_sql_stored_procedure( 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_sql_stored_procedure_initial( + raw_result = self._delete_sql_trigger_initial( resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, container_name=container_name, - stored_procedure_name=stored_procedure_name, + trigger_name=trigger_name, api_version=api_version, cls=lambda x, y, z: x, headers=_headers, @@ -6213,7 +5935,9 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- return cls(pipeline_response, None, {}) # type: ignore if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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: @@ -6299,7 +6023,7 @@ def extract_data(pipeline_response): list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore - return None, iter(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): _request = prepare_request(next_link) @@ -6312,7 +6036,11 @@ 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response @@ -6381,7 +6109,11 @@ def get_sql_user_defined_function( if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("SqlUserDefinedFunctionGetResults", pipeline_response.http_response) @@ -6457,14 +6189,19 @@ def _create_update_sql_user_defined_function_initial( # pylint: disable=name-to except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + 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["azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("azure-AsyncOperation") + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") ) - response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) @@ -6623,7 +6360,9 @@ def get_long_running_output(pipeline_response): return deserialized if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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: @@ -6662,14 +6401,165 @@ def _delete_sql_user_defined_function_initial( # pylint: disable=name-too-long 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_sql_user_defined_function_request( + _request = build_delete_sql_user_defined_function_request( + resource_group_name=resource_group_name, + account_name=account_name, + database_name=database_name, + container_name=container_name, + user_defined_function_name=user_defined_function_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["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + 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_sql_user_defined_function( + self, + resource_group_name: str, + account_name: str, + database_name: str, + container_name: str, + user_defined_function_name: str, + **kwargs: Any + ) -> LROPoller[None]: + """Deletes an existing Azure Cosmos DB SQL userDefinedFunction. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param database_name: Cosmos DB database name. Required. + :type database_name: str + :param container_name: Cosmos DB container name. Required. + :type container_name: str + :param user_defined_function_name: Cosmos DB userDefinedFunction name. Required. + :type user_defined_function_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_sql_user_defined_function_initial( + resource_group_name=resource_group_name, + account_name=account_name, + database_name=database_name, + container_name=container_name, + user_defined_function_name=user_defined_function_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 _sql_database_partition_merge_initial( + self, + resource_group_name: str, + account_name: str, + database_name: str, + merge_parameters: Union[_models.MergeParameters, 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(merge_parameters, (IOBase, bytes)): + _content = merge_parameters + else: + _json = self._serialize.body(merge_parameters, "MergeParameters") + + _request = build_sql_database_partition_merge_request( resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, - container_name=container_name, - user_defined_function_name=user_defined_function_name, subscription_id=self._config.subscription_id, api_version=api_version, + content_type=content_type, + json=_json, + content=_content, headers=_headers, params=_params, ) @@ -6683,7 +6573,7 @@ def _delete_sql_user_defined_function_initial( # pylint: disable=name-too-long response = pipeline_response.http_response - if response.status_code not in [202, 204]: + if response.status_code not in [200, 202]: try: response.read() # Load the body in memory and close the socket except (StreamConsumedError, StreamClosedError): @@ -6693,10 +6583,11 @@ def _delete_sql_user_defined_function_initial( # pylint: disable=name-too-long response_headers = {} if response.status_code == 202: - response_headers["azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("azure-AsyncOperation") + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") ) - response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) @@ -6705,17 +6596,80 @@ def _delete_sql_user_defined_function_initial( # pylint: disable=name-too-long return deserialized # type: ignore + @overload + def begin_sql_database_partition_merge( + self, + resource_group_name: str, + account_name: str, + database_name: str, + merge_parameters: _models.MergeParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.PhysicalPartitionStorageInfoCollection]: + """Merges the partitions of a SQL database. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param database_name: Cosmos DB database name. Required. + :type database_name: str + :param merge_parameters: The parameters for the merge operation. Required. + :type merge_parameters: ~azure.mgmt.cosmosdb.models.MergeParameters + :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 PhysicalPartitionStorageInfoCollection or + the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.PhysicalPartitionStorageInfoCollection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_sql_database_partition_merge( + self, + resource_group_name: str, + account_name: str, + database_name: str, + merge_parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.PhysicalPartitionStorageInfoCollection]: + """Merges the partitions of a SQL database. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param database_name: Cosmos DB database name. Required. + :type database_name: str + :param merge_parameters: The parameters for the merge operation. Required. + :type merge_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 PhysicalPartitionStorageInfoCollection or + the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.PhysicalPartitionStorageInfoCollection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + @distributed_trace - def begin_delete_sql_user_defined_function( + def begin_sql_database_partition_merge( self, resource_group_name: str, account_name: str, database_name: str, - container_name: str, - user_defined_function_name: str, + merge_parameters: Union[_models.MergeParameters, IO[bytes]], **kwargs: Any - ) -> LROPoller[None]: - """Deletes an existing Azure Cosmos DB SQL userDefinedFunction. + ) -> LROPoller[_models.PhysicalPartitionStorageInfoCollection]: + """Merges the partitions of a SQL database. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -6724,30 +6678,32 @@ def begin_delete_sql_user_defined_function( :type account_name: str :param database_name: Cosmos DB database name. Required. :type database_name: str - :param container_name: Cosmos DB container name. Required. - :type container_name: str - :param user_defined_function_name: Cosmos DB userDefinedFunction name. Required. - :type user_defined_function_name: str - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] + :param merge_parameters: The parameters for the merge operation. Is either a MergeParameters + type or a IO[bytes] type. Required. + :type merge_parameters: ~azure.mgmt.cosmosdb.models.MergeParameters or IO[bytes] + :return: An instance of LROPoller that returns either PhysicalPartitionStorageInfoCollection or + the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.PhysicalPartitionStorageInfoCollection] :raises ~azure.core.exceptions.HttpResponseError: """ - _headers = kwargs.pop("headers", {}) 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)) - cls: ClsType[None] = kwargs.pop("cls", None) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.PhysicalPartitionStorageInfoCollection] = 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_sql_user_defined_function_initial( + raw_result = self._sql_database_partition_merge_initial( resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, - container_name=container_name, - user_defined_function_name=user_defined_function_name, + merge_parameters=merge_parameters, api_version=api_version, + content_type=content_type, cls=lambda x, y, z: x, headers=_headers, params=_params, @@ -6756,126 +6712,37 @@ def begin_delete_sql_user_defined_function( raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("PhysicalPartitionStorageInfoCollection", pipeline_response.http_response) if cls: - return cls(pipeline_response, None, {}) # type: ignore + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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( + return LROPoller[_models.PhysicalPartitionStorageInfoCollection].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_sql_triggers( - self, resource_group_name: str, account_name: str, database_name: str, container_name: str, **kwargs: Any - ) -> ItemPaged["_models.SqlTriggerGetResults"]: - """Lists the SQL trigger under an existing Azure Cosmos DB database account. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param account_name: Cosmos DB database account name. Required. - :type account_name: str - :param database_name: Cosmos DB database name. Required. - :type database_name: str - :param container_name: Cosmos DB container name. Required. - :type container_name: str - :return: An iterator like instance of either SqlTriggerGetResults or the result of - cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cosmosdb.models.SqlTriggerGetResults] - :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.SqlTriggerListResult] = 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_sql_triggers_request( - resource_group_name=resource_group_name, - account_name=account_name, - database_name=database_name, - container_name=container_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("SqlTriggerListResult", 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) + return LROPoller[_models.PhysicalPartitionStorageInfoCollection]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) @distributed_trace - def get_sql_trigger( - self, - resource_group_name: str, - account_name: str, - database_name: str, - container_name: str, - trigger_name: str, - **kwargs: Any - ) -> _models.SqlTriggerGetResults: - """Gets the SQL trigger under an existing Azure Cosmos DB database account. + def get_sql_database_throughput( + self, resource_group_name: str, account_name: str, database_name: str, **kwargs: Any + ) -> _models.ThroughputSettingsGetResults: + """Gets the RUs per second of the SQL database under an existing Azure Cosmos DB database account + with the provided name. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -6884,12 +6751,8 @@ def get_sql_trigger( :type account_name: str :param database_name: Cosmos DB database name. Required. :type database_name: str - :param container_name: Cosmos DB container name. Required. - :type container_name: str - :param trigger_name: Cosmos DB trigger name. Required. - :type trigger_name: str - :return: SqlTriggerGetResults or the result of cls(response) - :rtype: ~azure.mgmt.cosmosdb.models.SqlTriggerGetResults + :return: ThroughputSettingsGetResults or the result of cls(response) + :rtype: ~azure.mgmt.cosmosdb.models.ThroughputSettingsGetResults :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -6904,14 +6767,12 @@ def get_sql_trigger( _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.SqlTriggerGetResults] = kwargs.pop("cls", None) + cls: ClsType[_models.ThroughputSettingsGetResults] = kwargs.pop("cls", None) - _request = build_get_sql_trigger_request( + _request = build_get_sql_database_throughput_request( resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, - container_name=container_name, - trigger_name=trigger_name, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, @@ -6928,23 +6789,25 @@ def get_sql_trigger( if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("SqlTriggerGetResults", pipeline_response.http_response) + deserialized = self._deserialize("ThroughputSettingsGetResults", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - def _create_update_sql_trigger_initial( + def _update_sql_database_throughput_initial( self, resource_group_name: str, account_name: str, database_name: str, - container_name: str, - trigger_name: str, - create_update_sql_trigger_parameters: Union[_models.SqlTriggerCreateUpdateParameters, IO[bytes]], + update_throughput_parameters: Union[_models.ThroughputSettingsUpdateParameters, IO[bytes]], **kwargs: Any ) -> Iterator[bytes]: error_map: MutableMapping = { @@ -6965,17 +6828,15 @@ def _create_update_sql_trigger_initial( content_type = content_type or "application/json" _json = None _content = None - if isinstance(create_update_sql_trigger_parameters, (IOBase, bytes)): - _content = create_update_sql_trigger_parameters + if isinstance(update_throughput_parameters, (IOBase, bytes)): + _content = update_throughput_parameters else: - _json = self._serialize.body(create_update_sql_trigger_parameters, "SqlTriggerCreateUpdateParameters") + _json = self._serialize.body(update_throughput_parameters, "ThroughputSettingsUpdateParameters") - _request = build_create_update_sql_trigger_request( + _request = build_update_sql_database_throughput_request( resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, - container_name=container_name, - trigger_name=trigger_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, @@ -7000,14 +6861,19 @@ def _create_update_sql_trigger_initial( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + 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["azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("azure-AsyncOperation") + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") ) - response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) @@ -7017,19 +6883,17 @@ def _create_update_sql_trigger_initial( return deserialized # type: ignore @overload - def begin_create_update_sql_trigger( + def begin_update_sql_database_throughput( self, resource_group_name: str, account_name: str, database_name: str, - container_name: str, - trigger_name: str, - create_update_sql_trigger_parameters: _models.SqlTriggerCreateUpdateParameters, + update_throughput_parameters: _models.ThroughputSettingsUpdateParameters, *, content_type: str = "application/json", **kwargs: Any - ) -> LROPoller[_models.SqlTriggerGetResults]: - """Create or update an Azure Cosmos DB SQL trigger. + ) -> LROPoller[_models.ThroughputSettingsGetResults]: + """Update RUs per second of an Azure Cosmos DB SQL database. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -7038,37 +6902,31 @@ def begin_create_update_sql_trigger( :type account_name: str :param database_name: Cosmos DB database name. Required. :type database_name: str - :param container_name: Cosmos DB container name. Required. - :type container_name: str - :param trigger_name: Cosmos DB trigger name. Required. - :type trigger_name: str - :param create_update_sql_trigger_parameters: The parameters to provide for the current SQL - trigger. Required. - :type create_update_sql_trigger_parameters: - ~azure.mgmt.cosmosdb.models.SqlTriggerCreateUpdateParameters + :param update_throughput_parameters: The parameters to provide for the RUs per second of the + current SQL database. Required. + :type update_throughput_parameters: + ~azure.mgmt.cosmosdb.models.ThroughputSettingsUpdateParameters :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 SqlTriggerGetResults or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.SqlTriggerGetResults] + :return: An instance of LROPoller that returns either ThroughputSettingsGetResults or the + result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.ThroughputSettingsGetResults] :raises ~azure.core.exceptions.HttpResponseError: """ @overload - def begin_create_update_sql_trigger( + def begin_update_sql_database_throughput( self, resource_group_name: str, account_name: str, database_name: str, - container_name: str, - trigger_name: str, - create_update_sql_trigger_parameters: IO[bytes], + update_throughput_parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> LROPoller[_models.SqlTriggerGetResults]: - """Create or update an Azure Cosmos DB SQL trigger. + ) -> LROPoller[_models.ThroughputSettingsGetResults]: + """Update RUs per second of an Azure Cosmos DB SQL database. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -7077,34 +6935,28 @@ def begin_create_update_sql_trigger( :type account_name: str :param database_name: Cosmos DB database name. Required. :type database_name: str - :param container_name: Cosmos DB container name. Required. - :type container_name: str - :param trigger_name: Cosmos DB trigger name. Required. - :type trigger_name: str - :param create_update_sql_trigger_parameters: The parameters to provide for the current SQL - trigger. Required. - :type create_update_sql_trigger_parameters: IO[bytes] + :param update_throughput_parameters: The parameters to provide for the RUs per second of the + current SQL database. Required. + :type update_throughput_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 SqlTriggerGetResults or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.SqlTriggerGetResults] + :return: An instance of LROPoller that returns either ThroughputSettingsGetResults or the + result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.ThroughputSettingsGetResults] :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace - def begin_create_update_sql_trigger( + def begin_update_sql_database_throughput( self, resource_group_name: str, account_name: str, database_name: str, - container_name: str, - trigger_name: str, - create_update_sql_trigger_parameters: Union[_models.SqlTriggerCreateUpdateParameters, IO[bytes]], + update_throughput_parameters: Union[_models.ThroughputSettingsUpdateParameters, IO[bytes]], **kwargs: Any - ) -> LROPoller[_models.SqlTriggerGetResults]: - """Create or update an Azure Cosmos DB SQL trigger. + ) -> LROPoller[_models.ThroughputSettingsGetResults]: + """Update RUs per second of an Azure Cosmos DB SQL database. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -7113,17 +6965,14 @@ def begin_create_update_sql_trigger( :type account_name: str :param database_name: Cosmos DB database name. Required. :type database_name: str - :param container_name: Cosmos DB container name. Required. - :type container_name: str - :param trigger_name: Cosmos DB trigger name. Required. - :type trigger_name: str - :param create_update_sql_trigger_parameters: The parameters to provide for the current SQL - trigger. Is either a SqlTriggerCreateUpdateParameters type or a IO[bytes] type. Required. - :type create_update_sql_trigger_parameters: - ~azure.mgmt.cosmosdb.models.SqlTriggerCreateUpdateParameters or IO[bytes] - :return: An instance of LROPoller that returns either SqlTriggerGetResults or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.SqlTriggerGetResults] + :param update_throughput_parameters: The parameters to provide for the RUs per second of the + current SQL database. Is either a ThroughputSettingsUpdateParameters type or a IO[bytes] type. + Required. + :type update_throughput_parameters: + ~azure.mgmt.cosmosdb.models.ThroughputSettingsUpdateParameters or IO[bytes] + :return: An instance of LROPoller that returns either ThroughputSettingsGetResults or the + result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.ThroughputSettingsGetResults] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -7131,18 +6980,16 @@ def begin_create_update_sql_trigger( 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.SqlTriggerGetResults] = kwargs.pop("cls", None) + cls: ClsType[_models.ThroughputSettingsGetResults] = 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_update_sql_trigger_initial( + raw_result = self._update_sql_database_throughput_initial( resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, - container_name=container_name, - trigger_name=trigger_name, - create_update_sql_trigger_parameters=create_update_sql_trigger_parameters, + update_throughput_parameters=update_throughput_parameters, api_version=api_version, content_type=content_type, cls=lambda x, y, z: x, @@ -7154,36 +7001,32 @@ def begin_create_update_sql_trigger( kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("SqlTriggerGetResults", pipeline_response.http_response) + deserialized = self._deserialize("ThroughputSettingsGetResults", 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, **kwargs)) + 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.SqlTriggerGetResults].from_continuation_token( + return LROPoller[_models.ThroughputSettingsGetResults].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller[_models.SqlTriggerGetResults]( + return LROPoller[_models.ThroughputSettingsGetResults]( self._client, raw_result, get_long_running_output, polling_method # type: ignore ) - def _delete_sql_trigger_initial( - self, - resource_group_name: str, - account_name: str, - database_name: str, - container_name: str, - trigger_name: str, - **kwargs: Any + def _migrate_sql_database_to_autoscale_initial( # pylint: disable=name-too-long + self, resource_group_name: str, account_name: str, database_name: str, **kwargs: Any ) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -7199,12 +7042,10 @@ def _delete_sql_trigger_initial( 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_sql_trigger_request( + _request = build_migrate_sql_database_to_autoscale_request( resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, - container_name=container_name, - trigger_name=trigger_name, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, @@ -7220,7 +7061,7 @@ def _delete_sql_trigger_initial( response = pipeline_response.http_response - if response.status_code not in [202, 204]: + if response.status_code not in [200, 202]: try: response.read() # Load the body in memory and close the socket except (StreamConsumedError, StreamClosedError): @@ -7230,10 +7071,11 @@ def _delete_sql_trigger_initial( response_headers = {} if response.status_code == 202: - response_headers["azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("azure-AsyncOperation") + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") ) - response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) @@ -7243,16 +7085,134 @@ def _delete_sql_trigger_initial( return deserialized # type: ignore @distributed_trace - def begin_delete_sql_trigger( - self, - resource_group_name: str, - account_name: str, - database_name: str, - container_name: str, - trigger_name: str, - **kwargs: Any - ) -> LROPoller[None]: - """Deletes an existing Azure Cosmos DB SQL trigger. + def begin_migrate_sql_database_to_autoscale( + self, resource_group_name: str, account_name: str, database_name: str, **kwargs: Any + ) -> LROPoller[_models.ThroughputSettingsGetResults]: + """Migrate an Azure Cosmos DB SQL database from manual throughput to autoscale. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param database_name: Cosmos DB database name. Required. + :type database_name: str + :return: An instance of LROPoller that returns either ThroughputSettingsGetResults or the + result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.ThroughputSettingsGetResults] + :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.ThroughputSettingsGetResults] = 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_sql_database_to_autoscale_initial( + resource_group_name=resource_group_name, + account_name=account_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): + deserialized = self._deserialize("ThroughputSettingsGetResults", 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": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.ThroughputSettingsGetResults].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.ThroughputSettingsGetResults]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + def _migrate_sql_database_to_manual_throughput_initial( # pylint: disable=name-too-long + self, resource_group_name: str, account_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_migrate_sql_database_to_manual_throughput_request( + resource_group_name=resource_group_name, + account_name=account_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 [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) + raise HttpResponseError(response=response, 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.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_migrate_sql_database_to_manual_throughput( # pylint: disable=name-too-long + self, resource_group_name: str, account_name: str, database_name: str, **kwargs: Any + ) -> LROPoller[_models.ThroughputSettingsGetResults]: + """Migrate an Azure Cosmos DB SQL database from autoscale to manual throughput. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -7261,29 +7221,24 @@ def begin_delete_sql_trigger( :type account_name: str :param database_name: Cosmos DB database name. Required. :type database_name: str - :param container_name: Cosmos DB container name. Required. - :type container_name: str - :param trigger_name: Cosmos DB trigger name. Required. - :type trigger_name: str - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] + :return: An instance of LROPoller that returns either ThroughputSettingsGetResults or the + result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.ThroughputSettingsGetResults] :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) + cls: ClsType[_models.ThroughputSettingsGetResults] = 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_sql_trigger_initial( + raw_result = self._migrate_sql_database_to_manual_throughput_initial( resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, - container_name=container_name, - trigger_name=trigger_name, api_version=api_version, cls=lambda x, y, z: x, headers=_headers, @@ -7293,91 +7248,37 @@ def begin_delete_sql_trigger( raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("ThroughputSettingsGetResults", pipeline_response.http_response) if cls: - return cls(pipeline_response, None, {}) # type: ignore + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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( + return LROPoller[_models.ThroughputSettingsGetResults].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_sql_role_definition( - self, role_definition_id: str, resource_group_name: str, account_name: str, **kwargs: Any - ) -> _models.SqlRoleDefinitionGetResults: - """Retrieves the properties of an existing Azure Cosmos DB SQL Role Definition with the given Id. - - :param role_definition_id: The GUID for the Role Definition. Required. - :type role_definition_id: str - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param account_name: Cosmos DB database account name. Required. - :type account_name: str - :return: SqlRoleDefinitionGetResults or the result of cls(response) - :rtype: ~azure.mgmt.cosmosdb.models.SqlRoleDefinitionGetResults - :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.SqlRoleDefinitionGetResults] = kwargs.pop("cls", None) - - _request = build_get_sql_role_definition_request( - role_definition_id=role_definition_id, - resource_group_name=resource_group_name, - account_name=account_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 + return LROPoller[_models.ThroughputSettingsGetResults]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore ) - 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("SqlRoleDefinitionGetResults", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - def _create_update_sql_role_definition_initial( # pylint: disable=name-too-long + def _sql_database_redistribute_throughput_initial( # pylint: disable=name-too-long self, - role_definition_id: str, resource_group_name: str, account_name: str, - create_update_sql_role_definition_parameters: Union[_models.SqlRoleDefinitionCreateUpdateParameters, IO[bytes]], + database_name: str, + redistribute_throughput_parameters: Union[_models.RedistributeThroughputParameters, IO[bytes]], **kwargs: Any ) -> Iterator[bytes]: error_map: MutableMapping = { @@ -7398,17 +7299,15 @@ def _create_update_sql_role_definition_initial( # pylint: disable=name-too-long content_type = content_type or "application/json" _json = None _content = None - if isinstance(create_update_sql_role_definition_parameters, (IOBase, bytes)): - _content = create_update_sql_role_definition_parameters + if isinstance(redistribute_throughput_parameters, (IOBase, bytes)): + _content = redistribute_throughput_parameters else: - _json = self._serialize.body( - create_update_sql_role_definition_parameters, "SqlRoleDefinitionCreateUpdateParameters" - ) + _json = self._serialize.body(redistribute_throughput_parameters, "RedistributeThroughputParameters") - _request = build_create_update_sql_role_definition_request( - role_definition_id=role_definition_id, + _request = build_sql_database_redistribute_throughput_request( resource_group_name=resource_group_name, account_name=account_name, + database_name=database_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, @@ -7435,104 +7334,115 @@ def _create_update_sql_role_definition_initial( # pylint: disable=name-too-long map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, 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.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @overload - def begin_create_update_sql_role_definition( + def begin_sql_database_redistribute_throughput( # pylint: disable=name-too-long self, - role_definition_id: str, resource_group_name: str, account_name: str, - create_update_sql_role_definition_parameters: _models.SqlRoleDefinitionCreateUpdateParameters, + database_name: str, + redistribute_throughput_parameters: _models.RedistributeThroughputParameters, *, content_type: str = "application/json", **kwargs: Any - ) -> LROPoller[_models.SqlRoleDefinitionGetResults]: - """Creates or updates an Azure Cosmos DB SQL Role Definition. + ) -> LROPoller[_models.PhysicalPartitionThroughputInfoResult]: + """Redistribute throughput for an Azure Cosmos DB SQL database. - :param role_definition_id: The GUID for the Role Definition. Required. - :type role_definition_id: str :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param create_update_sql_role_definition_parameters: The properties required to create or - update a Role Definition. Required. - :type create_update_sql_role_definition_parameters: - ~azure.mgmt.cosmosdb.models.SqlRoleDefinitionCreateUpdateParameters + :param database_name: Cosmos DB database name. Required. + :type database_name: str + :param redistribute_throughput_parameters: The parameters to provide for redistributing + throughput for the current SQL database. Required. + :type redistribute_throughput_parameters: + ~azure.mgmt.cosmosdb.models.RedistributeThroughputParameters :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 SqlRoleDefinitionGetResults or the result - of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.SqlRoleDefinitionGetResults] + :return: An instance of LROPoller that returns either PhysicalPartitionThroughputInfoResult or + the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.PhysicalPartitionThroughputInfoResult] :raises ~azure.core.exceptions.HttpResponseError: """ @overload - def begin_create_update_sql_role_definition( + def begin_sql_database_redistribute_throughput( # pylint: disable=name-too-long self, - role_definition_id: str, resource_group_name: str, account_name: str, - create_update_sql_role_definition_parameters: IO[bytes], + database_name: str, + redistribute_throughput_parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> LROPoller[_models.SqlRoleDefinitionGetResults]: - """Creates or updates an Azure Cosmos DB SQL Role Definition. + ) -> LROPoller[_models.PhysicalPartitionThroughputInfoResult]: + """Redistribute throughput for an Azure Cosmos DB SQL database. - :param role_definition_id: The GUID for the Role Definition. Required. - :type role_definition_id: str :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param create_update_sql_role_definition_parameters: The properties required to create or - update a Role Definition. Required. - :type create_update_sql_role_definition_parameters: IO[bytes] + :param database_name: Cosmos DB database name. Required. + :type database_name: str + :param redistribute_throughput_parameters: The parameters to provide for redistributing + throughput for the current SQL database. Required. + :type redistribute_throughput_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 SqlRoleDefinitionGetResults or the result - of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.SqlRoleDefinitionGetResults] + :return: An instance of LROPoller that returns either PhysicalPartitionThroughputInfoResult or + the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.PhysicalPartitionThroughputInfoResult] :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace - def begin_create_update_sql_role_definition( + def begin_sql_database_redistribute_throughput( # pylint: disable=name-too-long self, - role_definition_id: str, resource_group_name: str, account_name: str, - create_update_sql_role_definition_parameters: Union[_models.SqlRoleDefinitionCreateUpdateParameters, IO[bytes]], + database_name: str, + redistribute_throughput_parameters: Union[_models.RedistributeThroughputParameters, IO[bytes]], **kwargs: Any - ) -> LROPoller[_models.SqlRoleDefinitionGetResults]: - """Creates or updates an Azure Cosmos DB SQL Role Definition. + ) -> LROPoller[_models.PhysicalPartitionThroughputInfoResult]: + """Redistribute throughput for an Azure Cosmos DB SQL database. - :param role_definition_id: The GUID for the Role Definition. Required. - :type role_definition_id: str :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param create_update_sql_role_definition_parameters: The properties required to create or - update a Role Definition. Is either a SqlRoleDefinitionCreateUpdateParameters type or a + :param database_name: Cosmos DB database name. Required. + :type database_name: str + :param redistribute_throughput_parameters: The parameters to provide for redistributing + throughput for the current SQL database. Is either a RedistributeThroughputParameters type or a IO[bytes] type. Required. - :type create_update_sql_role_definition_parameters: - ~azure.mgmt.cosmosdb.models.SqlRoleDefinitionCreateUpdateParameters or IO[bytes] - :return: An instance of LROPoller that returns either SqlRoleDefinitionGetResults or the result - of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.SqlRoleDefinitionGetResults] + :type redistribute_throughput_parameters: + ~azure.mgmt.cosmosdb.models.RedistributeThroughputParameters or IO[bytes] + :return: An instance of LROPoller that returns either PhysicalPartitionThroughputInfoResult or + the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.PhysicalPartitionThroughputInfoResult] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -7540,16 +7450,16 @@ def begin_create_update_sql_role_definition( 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.SqlRoleDefinitionGetResults] = kwargs.pop("cls", None) + cls: ClsType[_models.PhysicalPartitionThroughputInfoResult] = 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_update_sql_role_definition_initial( - role_definition_id=role_definition_id, + raw_result = self._sql_database_redistribute_throughput_initial( resource_group_name=resource_group_name, account_name=account_name, - create_update_sql_role_definition_parameters=create_update_sql_role_definition_parameters, + database_name=database_name, + redistribute_throughput_parameters=redistribute_throughput_parameters, api_version=api_version, content_type=content_type, cls=lambda x, y, z: x, @@ -7561,30 +7471,37 @@ def begin_create_update_sql_role_definition( kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("SqlRoleDefinitionGetResults", pipeline_response.http_response) + deserialized = self._deserialize("PhysicalPartitionThroughputInfoResult", 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, **kwargs)) + 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.SqlRoleDefinitionGetResults].from_continuation_token( + return LROPoller[_models.PhysicalPartitionThroughputInfoResult].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller[_models.SqlRoleDefinitionGetResults]( + return LROPoller[_models.PhysicalPartitionThroughputInfoResult]( self._client, raw_result, get_long_running_output, polling_method # type: ignore ) - def _delete_sql_role_definition_initial( - self, role_definition_id: str, resource_group_name: str, account_name: str, **kwargs: Any + def _sql_database_retrieve_throughput_distribution_initial( # pylint: disable=name-too-long + self, + resource_group_name: str, + account_name: str, + database_name: str, + retrieve_throughput_parameters: Union[_models.RetrieveThroughputParameters, IO[bytes]], + **kwargs: Any ) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -7594,18 +7511,30 @@ def _delete_sql_role_definition_initial( } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) 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) - _request = build_delete_sql_role_definition_request( - role_definition_id=role_definition_id, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(retrieve_throughput_parameters, (IOBase, bytes)): + _content = retrieve_throughput_parameters + else: + _json = self._serialize.body(retrieve_throughput_parameters, "RetrieveThroughputParameters") + + _request = build_sql_database_retrieve_throughput_distribution_request( resource_group_name=resource_group_name, account_name=account_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, ) @@ -7619,7 +7548,7 @@ def _delete_sql_role_definition_initial( response = pipeline_response.http_response - if response.status_code not in [200, 202, 204]: + if response.status_code not in [200, 202]: try: response.read() # Load the body in memory and close the socket except (StreamConsumedError, StreamClosedError): @@ -7627,44 +7556,133 @@ def _delete_sql_role_definition_initial( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + 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.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_sql_database_retrieve_throughput_distribution( # pylint: disable=name-too-long + self, + resource_group_name: str, + account_name: str, + database_name: str, + retrieve_throughput_parameters: _models.RetrieveThroughputParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.PhysicalPartitionThroughputInfoResult]: + """Retrieve throughput distribution for an Azure Cosmos DB SQL database. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param database_name: Cosmos DB database name. Required. + :type database_name: str + :param retrieve_throughput_parameters: The parameters to provide for retrieving throughput + distribution for the current SQL database. Required. + :type retrieve_throughput_parameters: ~azure.mgmt.cosmosdb.models.RetrieveThroughputParameters + :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 PhysicalPartitionThroughputInfoResult or + the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.PhysicalPartitionThroughputInfoResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + @overload + def begin_sql_database_retrieve_throughput_distribution( # pylint: disable=name-too-long + self, + resource_group_name: str, + account_name: str, + database_name: str, + retrieve_throughput_parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.PhysicalPartitionThroughputInfoResult]: + """Retrieve throughput distribution for an Azure Cosmos DB SQL database. - return deserialized # type: ignore + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param database_name: Cosmos DB database name. Required. + :type database_name: str + :param retrieve_throughput_parameters: The parameters to provide for retrieving throughput + distribution for the current SQL database. Required. + :type retrieve_throughput_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 PhysicalPartitionThroughputInfoResult or + the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.PhysicalPartitionThroughputInfoResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace - def begin_delete_sql_role_definition( - self, role_definition_id: str, resource_group_name: str, account_name: str, **kwargs: Any - ) -> LROPoller[None]: - """Deletes an existing Azure Cosmos DB SQL Role Definition. + def begin_sql_database_retrieve_throughput_distribution( # pylint: disable=name-too-long + self, + resource_group_name: str, + account_name: str, + database_name: str, + retrieve_throughput_parameters: Union[_models.RetrieveThroughputParameters, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.PhysicalPartitionThroughputInfoResult]: + """Retrieve throughput distribution for an Azure Cosmos DB SQL database. - :param role_definition_id: The GUID for the Role Definition. Required. - :type role_definition_id: str :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param account_name: Cosmos DB database account name. Required. :type account_name: str - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] + :param database_name: Cosmos DB database name. Required. + :type database_name: str + :param retrieve_throughput_parameters: The parameters to provide for retrieving throughput + distribution for the current SQL database. Is either a RetrieveThroughputParameters type or a + IO[bytes] type. Required. + :type retrieve_throughput_parameters: ~azure.mgmt.cosmosdb.models.RetrieveThroughputParameters + or IO[bytes] + :return: An instance of LROPoller that returns either PhysicalPartitionThroughputInfoResult or + the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.PhysicalPartitionThroughputInfoResult] :raises ~azure.core.exceptions.HttpResponseError: """ - _headers = kwargs.pop("headers", {}) 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)) - cls: ClsType[None] = kwargs.pop("cls", None) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.PhysicalPartitionThroughputInfoResult] = 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_sql_role_definition_initial( - role_definition_id=role_definition_id, + raw_result = self._sql_database_retrieve_throughput_distribution_initial( resource_group_name=resource_group_name, account_name=account_name, + database_name=database_name, + retrieve_throughput_parameters=retrieve_throughput_parameters, api_version=api_version, + content_type=content_type, cls=lambda x, y, z: x, headers=_headers, params=_params, @@ -7673,46 +7691,52 @@ def begin_delete_sql_role_definition( raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("PhysicalPartitionThroughputInfoResult", pipeline_response.http_response) if cls: - return cls(pipeline_response, None, {}) # type: ignore + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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( + return LROPoller[_models.PhysicalPartitionThroughputInfoResult].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 + return LROPoller[_models.PhysicalPartitionThroughputInfoResult]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) @distributed_trace - def list_sql_role_definitions( + def list_sql_role_assignments( self, resource_group_name: str, account_name: str, **kwargs: Any - ) -> ItemPaged["_models.SqlRoleDefinitionGetResults"]: - """Retrieves the list of all Azure Cosmos DB SQL Role Definitions. + ) -> ItemPaged["_models.SqlRoleAssignmentGetResults"]: + """Retrieves the list of all Azure Cosmos DB SQL Role Assignments. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param account_name: Cosmos DB database account name. Required. :type account_name: str - :return: An iterator like instance of either SqlRoleDefinitionGetResults or the result of + :return: An iterator like instance of either SqlRoleAssignmentGetResults or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cosmosdb.models.SqlRoleDefinitionGetResults] + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cosmosdb.models.SqlRoleAssignmentGetResults] :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.SqlRoleDefinitionListResult] = kwargs.pop("cls", None) + cls: ClsType[_models.SqlRoleAssignmentListResult] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -7725,7 +7749,7 @@ def list_sql_role_definitions( def prepare_request(next_link=None): if not next_link: - _request = build_list_sql_role_definitions_request( + _request = build_list_sql_role_assignments_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -7753,11 +7777,11 @@ def prepare_request(next_link=None): return _request def extract_data(pipeline_response): - deserialized = self._deserialize("SqlRoleDefinitionListResult", pipeline_response) + deserialized = self._deserialize("SqlRoleAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore - return None, iter(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): _request = prepare_request(next_link) @@ -7778,17 +7802,17 @@ def get_next(next_link=None): @distributed_trace def get_sql_role_assignment( - self, role_assignment_id: str, resource_group_name: str, account_name: str, **kwargs: Any + self, resource_group_name: str, account_name: str, role_assignment_id: str, **kwargs: Any ) -> _models.SqlRoleAssignmentGetResults: """Retrieves the properties of an existing Azure Cosmos DB SQL Role Assignment with the given Id. - :param role_assignment_id: The GUID for the Role Assignment. Required. - :type role_assignment_id: str :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param account_name: Cosmos DB database account name. Required. :type account_name: str + :param role_assignment_id: The GUID for the Role Assignment. Required. + :type role_assignment_id: str :return: SqlRoleAssignmentGetResults or the result of cls(response) :rtype: ~azure.mgmt.cosmosdb.models.SqlRoleAssignmentGetResults :raises ~azure.core.exceptions.HttpResponseError: @@ -7808,9 +7832,9 @@ def get_sql_role_assignment( cls: ClsType[_models.SqlRoleAssignmentGetResults] = kwargs.pop("cls", None) _request = build_get_sql_role_assignment_request( - role_assignment_id=role_assignment_id, resource_group_name=resource_group_name, account_name=account_name, + role_assignment_id=role_assignment_id, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, @@ -7838,9 +7862,9 @@ def get_sql_role_assignment( def _create_update_sql_role_assignment_initial( # pylint: disable=name-too-long self, - role_assignment_id: str, resource_group_name: str, account_name: str, + role_assignment_id: str, create_update_sql_role_assignment_parameters: Union[_models.SqlRoleAssignmentCreateUpdateParameters, IO[bytes]], **kwargs: Any ) -> Iterator[bytes]: @@ -7870,9 +7894,9 @@ def _create_update_sql_role_assignment_initial( # pylint: disable=name-too-long ) _request = build_create_update_sql_role_assignment_request( - role_assignment_id=role_assignment_id, resource_group_name=resource_group_name, account_name=account_name, + role_assignment_id=role_assignment_id, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, @@ -7899,19 +7923,24 @@ def _create_update_sql_role_assignment_initial( # pylint: disable=name-too-long map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @overload def begin_create_update_sql_role_assignment( self, - role_assignment_id: str, resource_group_name: str, account_name: str, + role_assignment_id: str, create_update_sql_role_assignment_parameters: _models.SqlRoleAssignmentCreateUpdateParameters, *, content_type: str = "application/json", @@ -7919,13 +7948,13 @@ def begin_create_update_sql_role_assignment( ) -> LROPoller[_models.SqlRoleAssignmentGetResults]: """Creates or updates an Azure Cosmos DB SQL Role Assignment. - :param role_assignment_id: The GUID for the Role Assignment. Required. - :type role_assignment_id: str :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param account_name: Cosmos DB database account name. Required. :type account_name: str + :param role_assignment_id: The GUID for the Role Assignment. Required. + :type role_assignment_id: str :param create_update_sql_role_assignment_parameters: The properties required to create or update a Role Assignment. Required. :type create_update_sql_role_assignment_parameters: @@ -7942,9 +7971,9 @@ def begin_create_update_sql_role_assignment( @overload def begin_create_update_sql_role_assignment( self, - role_assignment_id: str, resource_group_name: str, account_name: str, + role_assignment_id: str, create_update_sql_role_assignment_parameters: IO[bytes], *, content_type: str = "application/json", @@ -7952,13 +7981,13 @@ def begin_create_update_sql_role_assignment( ) -> LROPoller[_models.SqlRoleAssignmentGetResults]: """Creates or updates an Azure Cosmos DB SQL Role Assignment. - :param role_assignment_id: The GUID for the Role Assignment. Required. - :type role_assignment_id: str :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param account_name: Cosmos DB database account name. Required. :type account_name: str + :param role_assignment_id: The GUID for the Role Assignment. Required. + :type role_assignment_id: str :param create_update_sql_role_assignment_parameters: The properties required to create or update a Role Assignment. Required. :type create_update_sql_role_assignment_parameters: IO[bytes] @@ -7974,21 +8003,21 @@ def begin_create_update_sql_role_assignment( @distributed_trace def begin_create_update_sql_role_assignment( self, - role_assignment_id: str, resource_group_name: str, account_name: str, + role_assignment_id: str, create_update_sql_role_assignment_parameters: Union[_models.SqlRoleAssignmentCreateUpdateParameters, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.SqlRoleAssignmentGetResults]: """Creates or updates an Azure Cosmos DB SQL Role Assignment. - :param role_assignment_id: The GUID for the Role Assignment. Required. - :type role_assignment_id: str :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param account_name: Cosmos DB database account name. Required. :type account_name: str + :param role_assignment_id: The GUID for the Role Assignment. Required. + :type role_assignment_id: str :param create_update_sql_role_assignment_parameters: The properties required to create or update a Role Assignment. Is either a SqlRoleAssignmentCreateUpdateParameters type or a IO[bytes] type. Required. @@ -8010,9 +8039,9 @@ def begin_create_update_sql_role_assignment( cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._create_update_sql_role_assignment_initial( - role_assignment_id=role_assignment_id, resource_group_name=resource_group_name, account_name=account_name, + role_assignment_id=role_assignment_id, create_update_sql_role_assignment_parameters=create_update_sql_role_assignment_parameters, api_version=api_version, content_type=content_type, @@ -8031,7 +8060,9 @@ def get_long_running_output(pipeline_response): return deserialized if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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: @@ -8048,7 +8079,7 @@ def get_long_running_output(pipeline_response): ) def _delete_sql_role_assignment_initial( - self, role_assignment_id: str, resource_group_name: str, account_name: str, **kwargs: Any + self, resource_group_name: str, account_name: str, role_assignment_id: str, **kwargs: Any ) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -8065,9 +8096,9 @@ def _delete_sql_role_assignment_initial( cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) _request = build_delete_sql_role_assignment_request( - role_assignment_id=role_assignment_id, resource_group_name=resource_group_name, account_name=account_name, + role_assignment_id=role_assignment_id, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, @@ -8091,26 +8122,31 @@ def _delete_sql_role_assignment_initial( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @distributed_trace def begin_delete_sql_role_assignment( - self, role_assignment_id: str, resource_group_name: str, account_name: str, **kwargs: Any + self, resource_group_name: str, account_name: str, role_assignment_id: str, **kwargs: Any ) -> LROPoller[None]: """Deletes an existing Azure Cosmos DB SQL Role Assignment. - :param role_assignment_id: The GUID for the Role Assignment. Required. - :type role_assignment_id: str :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param account_name: Cosmos DB database account name. Required. :type account_name: str + :param role_assignment_id: The GUID for the Role Assignment. Required. + :type role_assignment_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: @@ -8125,9 +8161,9 @@ def begin_delete_sql_role_assignment( cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._delete_sql_role_assignment_initial( - role_assignment_id=role_assignment_id, resource_group_name=resource_group_name, account_name=account_name, + role_assignment_id=role_assignment_id, api_version=api_version, cls=lambda x, y, z: x, headers=_headers, @@ -8142,7 +8178,9 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- return cls(pipeline_response, None, {}) # type: ignore if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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: @@ -8157,26 +8195,26 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore @distributed_trace - def list_sql_role_assignments( + def list_sql_role_definitions( self, resource_group_name: str, account_name: str, **kwargs: Any - ) -> ItemPaged["_models.SqlRoleAssignmentGetResults"]: - """Retrieves the list of all Azure Cosmos DB SQL Role Assignments. + ) -> ItemPaged["_models.SqlRoleDefinitionGetResults"]: + """Retrieves the list of all Azure Cosmos DB SQL Role Definitions. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param account_name: Cosmos DB database account name. Required. :type account_name: str - :return: An iterator like instance of either SqlRoleAssignmentGetResults or the result of + :return: An iterator like instance of either SqlRoleDefinitionGetResults or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cosmosdb.models.SqlRoleAssignmentGetResults] + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cosmosdb.models.SqlRoleDefinitionGetResults] :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.SqlRoleAssignmentListResult] = kwargs.pop("cls", None) + cls: ClsType[_models.SqlRoleDefinitionListResult] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -8189,7 +8227,7 @@ def list_sql_role_assignments( def prepare_request(next_link=None): if not next_link: - _request = build_list_sql_role_assignments_request( + _request = build_list_sql_role_definitions_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -8217,11 +8255,11 @@ def prepare_request(next_link=None): return _request def extract_data(pipeline_response): - deserialized = self._deserialize("SqlRoleAssignmentListResult", pipeline_response) + deserialized = self._deserialize("SqlRoleDefinitionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore - return None, iter(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): _request = prepare_request(next_link) @@ -8232,21 +8270,80 @@ def get_next(next_link=None): ) 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def get_sql_role_definition( + self, resource_group_name: str, account_name: str, role_definition_id: str, **kwargs: Any + ) -> _models.SqlRoleDefinitionGetResults: + """Retrieves the properties of an existing Azure Cosmos DB SQL Role Definition with the given Id. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param role_definition_id: The GUID for the Role Definition. Required. + :type role_definition_id: str + :return: SqlRoleDefinitionGetResults or the result of cls(response) + :rtype: ~azure.mgmt.cosmosdb.models.SqlRoleDefinitionGetResults + :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.SqlRoleDefinitionGetResults] = kwargs.pop("cls", None) + + _request = build_get_sql_role_definition_request( + resource_group_name=resource_group_name, + account_name=account_name, + role_definition_id=role_definition_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 - return pipeline_response + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - return ItemPaged(get_next, extract_data) + deserialized = self._deserialize("SqlRoleDefinitionGetResults", pipeline_response.http_response) - def _retrieve_continuous_backup_information_initial( # pylint: disable=name-too-long + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + def _create_update_sql_role_definition_initial( # pylint: disable=name-too-long self, resource_group_name: str, account_name: str, - database_name: str, - container_name: str, - location: Union[_models.ContinuousBackupRestoreLocation, IO[bytes]], + role_definition_id: str, + create_update_sql_role_definition_parameters: Union[_models.SqlRoleDefinitionCreateUpdateParameters, IO[bytes]], **kwargs: Any ) -> Iterator[bytes]: error_map: MutableMapping = { @@ -8267,16 +8364,17 @@ def _retrieve_continuous_backup_information_initial( # pylint: disable=name-too content_type = content_type or "application/json" _json = None _content = None - if isinstance(location, (IOBase, bytes)): - _content = location + if isinstance(create_update_sql_role_definition_parameters, (IOBase, bytes)): + _content = create_update_sql_role_definition_parameters else: - _json = self._serialize.body(location, "ContinuousBackupRestoreLocation") + _json = self._serialize.body( + create_update_sql_role_definition_parameters, "SqlRoleDefinitionCreateUpdateParameters" + ) - _request = build_retrieve_continuous_backup_information_request( + _request = build_create_update_sql_role_definition_request( resource_group_name=resource_group_name, account_name=account_name, - database_name=database_name, - container_name=container_name, + role_definition_id=role_definition_id, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, @@ -8303,108 +8401,109 @@ def _retrieve_continuous_backup_information_initial( # pylint: disable=name-too map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @overload - def begin_retrieve_continuous_backup_information( # pylint: disable=name-too-long + def begin_create_update_sql_role_definition( self, resource_group_name: str, account_name: str, - database_name: str, - container_name: str, - location: _models.ContinuousBackupRestoreLocation, + role_definition_id: str, + create_update_sql_role_definition_parameters: _models.SqlRoleDefinitionCreateUpdateParameters, *, content_type: str = "application/json", **kwargs: Any - ) -> LROPoller[_models.BackupInformation]: - """Retrieves continuous backup information for a container resource. + ) -> LROPoller[_models.SqlRoleDefinitionGetResults]: + """Creates or updates an Azure Cosmos DB SQL Role Definition. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param database_name: Cosmos DB database name. Required. - :type database_name: str - :param container_name: Cosmos DB container name. Required. - :type container_name: str - :param location: The name of the continuous backup restore location. Required. - :type location: ~azure.mgmt.cosmosdb.models.ContinuousBackupRestoreLocation + :param role_definition_id: The GUID for the Role Definition. Required. + :type role_definition_id: str + :param create_update_sql_role_definition_parameters: The properties required to create or + update a Role Definition. Required. + :type create_update_sql_role_definition_parameters: + ~azure.mgmt.cosmosdb.models.SqlRoleDefinitionCreateUpdateParameters :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 BackupInformation or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.BackupInformation] + :return: An instance of LROPoller that returns either SqlRoleDefinitionGetResults or the result + of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.SqlRoleDefinitionGetResults] :raises ~azure.core.exceptions.HttpResponseError: """ @overload - def begin_retrieve_continuous_backup_information( # pylint: disable=name-too-long + def begin_create_update_sql_role_definition( self, resource_group_name: str, account_name: str, - database_name: str, - container_name: str, - location: IO[bytes], + role_definition_id: str, + create_update_sql_role_definition_parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> LROPoller[_models.BackupInformation]: - """Retrieves continuous backup information for a container resource. + ) -> LROPoller[_models.SqlRoleDefinitionGetResults]: + """Creates or updates an Azure Cosmos DB SQL Role Definition. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param database_name: Cosmos DB database name. Required. - :type database_name: str - :param container_name: Cosmos DB container name. Required. - :type container_name: str - :param location: The name of the continuous backup restore location. Required. - :type location: IO[bytes] + :param role_definition_id: The GUID for the Role Definition. Required. + :type role_definition_id: str + :param create_update_sql_role_definition_parameters: The properties required to create or + update a Role Definition. Required. + :type create_update_sql_role_definition_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 BackupInformation or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.BackupInformation] + :return: An instance of LROPoller that returns either SqlRoleDefinitionGetResults or the result + of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.SqlRoleDefinitionGetResults] :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace - def begin_retrieve_continuous_backup_information( # pylint: disable=name-too-long + def begin_create_update_sql_role_definition( self, resource_group_name: str, account_name: str, - database_name: str, - container_name: str, - location: Union[_models.ContinuousBackupRestoreLocation, IO[bytes]], + role_definition_id: str, + create_update_sql_role_definition_parameters: Union[_models.SqlRoleDefinitionCreateUpdateParameters, IO[bytes]], **kwargs: Any - ) -> LROPoller[_models.BackupInformation]: - """Retrieves continuous backup information for a container resource. + ) -> LROPoller[_models.SqlRoleDefinitionGetResults]: + """Creates or updates an Azure Cosmos DB SQL Role Definition. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param database_name: Cosmos DB database name. Required. - :type database_name: str - :param container_name: Cosmos DB container name. Required. - :type container_name: str - :param location: The name of the continuous backup restore location. Is either a - ContinuousBackupRestoreLocation type or a IO[bytes] type. Required. - :type location: ~azure.mgmt.cosmosdb.models.ContinuousBackupRestoreLocation or IO[bytes] - :return: An instance of LROPoller that returns either BackupInformation or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.BackupInformation] + :param role_definition_id: The GUID for the Role Definition. Required. + :type role_definition_id: str + :param create_update_sql_role_definition_parameters: The properties required to create or + update a Role Definition. Is either a SqlRoleDefinitionCreateUpdateParameters type or a + IO[bytes] type. Required. + :type create_update_sql_role_definition_parameters: + ~azure.mgmt.cosmosdb.models.SqlRoleDefinitionCreateUpdateParameters or IO[bytes] + :return: An instance of LROPoller that returns either SqlRoleDefinitionGetResults or the result + of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.SqlRoleDefinitionGetResults] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -8412,17 +8511,16 @@ def begin_retrieve_continuous_backup_information( # pylint: disable=name-too-lo 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.BackupInformation] = kwargs.pop("cls", None) + cls: ClsType[_models.SqlRoleDefinitionGetResults] = 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._retrieve_continuous_backup_information_initial( + raw_result = self._create_update_sql_role_definition_initial( resource_group_name=resource_group_name, account_name=account_name, - database_name=database_name, - container_name=container_name, - location=location, + role_definition_id=role_definition_id, + create_update_sql_role_definition_parameters=create_update_sql_role_definition_parameters, api_version=api_version, content_type=content_type, cls=lambda x, y, z: x, @@ -8434,7 +8532,7 @@ def begin_retrieve_continuous_backup_information( # pylint: disable=name-too-lo kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("BackupInformation", pipeline_response.http_response) + deserialized = self._deserialize("SqlRoleDefinitionGetResults", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized @@ -8448,12 +8546,128 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller[_models.BackupInformation].from_continuation_token( + return LROPoller[_models.SqlRoleDefinitionGetResults].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller[_models.BackupInformation]( + return LROPoller[_models.SqlRoleDefinitionGetResults]( self._client, raw_result, get_long_running_output, polling_method # type: ignore ) + + def _delete_sql_role_definition_initial( + self, resource_group_name: str, account_name: str, role_definition_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_sql_role_definition_request( + resource_group_name=resource_group_name, + account_name=account_name, + role_definition_id=role_definition_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 [200, 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + 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_sql_role_definition( + self, resource_group_name: str, account_name: str, role_definition_id: str, **kwargs: Any + ) -> LROPoller[None]: + """Deletes an existing Azure Cosmos DB SQL Role Definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param role_definition_id: The GUID for the Role Definition. Required. + :type role_definition_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_sql_role_definition_initial( + resource_group_name=resource_group_name, + account_name=account_name, + role_definition_id=role_definition_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 diff --git a/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/operations/_table_resources_operations.py b/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/operations/_table_resources_operations.py index a684500dad0..9fa7d7df4cb 100644 --- a/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/operations/_table_resources_operations.py +++ b/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/operations/_table_resources_operations.py @@ -43,19 +43,19 @@ _SERIALIZER.client_side_validation = False -def build_list_tables_request( +def build_list_table_role_assignments_request( # pylint: disable=name-too-long resource_group_name: str, account_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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/tables", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/tableRoleAssignments", ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), @@ -78,19 +78,19 @@ def build_list_tables_request( return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_get_table_request( - resource_group_name: str, account_name: str, table_name: str, subscription_id: str, **kwargs: Any +def build_get_table_role_assignment_request( + resource_group_name: str, account_name: str, role_assignment_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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/tables/{tableName}", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/tableRoleAssignments/{roleAssignmentId}", ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), @@ -100,7 +100,7 @@ def build_get_table_request( "accountName": _SERIALIZER.url( "account_name", account_name, "str", max_length=50, min_length=3, pattern=r"^[a-z0-9]+(-[a-z0-9]+)*" ), - "tableName": _SERIALIZER.url("table_name", table_name, "str"), + "roleAssignmentId": _SERIALIZER.url("role_assignment_id", role_assignment_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -114,20 +114,20 @@ def build_get_table_request( return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_update_table_request( - resource_group_name: str, account_name: str, table_name: str, subscription_id: str, **kwargs: Any +def build_create_update_table_role_assignment_request( # pylint: disable=name-too-long + resource_group_name: str, account_name: str, role_assignment_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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) 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.DocumentDB/databaseAccounts/{accountName}/tables/{tableName}", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/tableRoleAssignments/{roleAssignmentId}", ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), @@ -137,7 +137,7 @@ def build_create_update_table_request( "accountName": _SERIALIZER.url( "account_name", account_name, "str", max_length=50, min_length=3, pattern=r"^[a-z0-9]+(-[a-z0-9]+)*" ), - "tableName": _SERIALIZER.url("table_name", table_name, "str"), + "roleAssignmentId": _SERIALIZER.url("role_assignment_id", role_assignment_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -153,16 +153,19 @@ def build_create_update_table_request( return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_delete_table_request( - resource_group_name: str, account_name: str, table_name: str, subscription_id: str, **kwargs: Any +def build_delete_table_role_assignment_request( # pylint: disable=name-too-long + resource_group_name: str, account_name: str, role_assignment_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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/tables/{tableName}", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/tableRoleAssignments/{roleAssignmentId}", ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), @@ -172,7 +175,7 @@ def build_delete_table_request( "accountName": _SERIALIZER.url( "account_name", account_name, "str", max_length=50, min_length=3, pattern=r"^[a-z0-9]+(-[a-z0-9]+)*" ), - "tableName": _SERIALIZER.url("table_name", table_name, "str"), + "roleAssignmentId": _SERIALIZER.url("role_assignment_id", role_assignment_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -180,22 +183,25 @@ def build_delete_table_request( # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) -def build_get_table_throughput_request( - resource_group_name: str, account_name: str, table_name: str, subscription_id: str, **kwargs: Any +def build_list_table_role_definitions_request( # pylint: disable=name-too-long + resource_group_name: str, account_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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/tables/{tableName}/throughputSettings/default", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/tableRoleDefinitions", ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), @@ -205,7 +211,6 @@ def build_get_table_throughput_request( "accountName": _SERIALIZER.url( "account_name", account_name, "str", max_length=50, min_length=3, pattern=r"^[a-z0-9]+(-[a-z0-9]+)*" ), - "tableName": _SERIALIZER.url("table_name", table_name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -219,20 +224,19 @@ def build_get_table_throughput_request( return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_update_table_throughput_request( - resource_group_name: str, account_name: str, table_name: str, subscription_id: str, **kwargs: Any +def build_get_table_role_definition_request( + resource_group_name: str, account_name: str, role_definition_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-11-01-preview")) - 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-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/tables/{tableName}/throughputSettings/default", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/tableRoleDefinitions/{roleDefinitionId}", ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), @@ -242,7 +246,7 @@ def build_update_table_throughput_request( "accountName": _SERIALIZER.url( "account_name", account_name, "str", max_length=50, min_length=3, pattern=r"^[a-z0-9]+(-[a-z0-9]+)*" ), - "tableName": _SERIALIZER.url("table_name", table_name, "str"), + "roleDefinitionId": _SERIALIZER.url("role_definition_id", role_definition_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -251,26 +255,25 @@ def build_update_table_throughput_request( _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) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_migrate_table_to_autoscale_request( - resource_group_name: str, account_name: str, table_name: str, subscription_id: str, **kwargs: Any +def build_create_update_table_role_definition_request( # pylint: disable=name-too-long + resource_group_name: str, account_name: str, role_definition_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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) + 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.DocumentDB/databaseAccounts/{accountName}/tables/{tableName}/throughputSettings/default/migrateToAutoscale", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/tableRoleDefinitions/{roleDefinitionId}", ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), @@ -280,7 +283,7 @@ def build_migrate_table_to_autoscale_request( "accountName": _SERIALIZER.url( "account_name", account_name, "str", max_length=50, min_length=3, pattern=r"^[a-z0-9]+(-[a-z0-9]+)*" ), - "tableName": _SERIALIZER.url("table_name", table_name, "str"), + "roleDefinitionId": _SERIALIZER.url("role_definition_id", role_definition_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -289,24 +292,26 @@ def build_migrate_table_to_autoscale_request( _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) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_migrate_table_to_manual_throughput_request( # pylint: disable=name-too-long - resource_group_name: str, account_name: str, table_name: str, subscription_id: str, **kwargs: Any +def build_delete_table_role_definition_request( # pylint: disable=name-too-long + resource_group_name: str, account_name: str, role_definition_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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/tables/{tableName}/throughputSettings/default/migrateToManualThroughput", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/tableRoleDefinitions/{roleDefinitionId}", ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), @@ -316,7 +321,7 @@ def build_migrate_table_to_manual_throughput_request( # pylint: disable=name-to "accountName": _SERIALIZER.url( "account_name", account_name, "str", max_length=50, min_length=3, pattern=r"^[a-z0-9]+(-[a-z0-9]+)*" ), - "tableName": _SERIALIZER.url("table_name", table_name, "str"), + "roleDefinitionId": _SERIALIZER.url("role_definition_id", role_definition_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -327,23 +332,22 @@ def build_migrate_table_to_manual_throughput_request( # pylint: disable=name-to # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) -def build_retrieve_continuous_backup_information_request( # pylint: disable=name-too-long - resource_group_name: str, account_name: str, table_name: str, subscription_id: str, **kwargs: Any +def build_list_tables_request( + resource_group_name: str, account_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-11-01-preview")) - 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-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/tables/{tableName}/retrieveContinuousBackupInformation", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/tables", ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), @@ -353,7 +357,6 @@ def build_retrieve_continuous_backup_information_request( # pylint: disable=nam "accountName": _SERIALIZER.url( "account_name", account_name, "str", max_length=50, min_length=3, pattern=r"^[a-z0-9]+(-[a-z0-9]+)*" ), - "tableName": _SERIALIZER.url("table_name", table_name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -362,26 +365,24 @@ def build_retrieve_continuous_backup_information_request( # pylint: disable=nam _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) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_get_table_role_definition_request( - resource_group_name: str, account_name: str, role_definition_id: str, subscription_id: str, **kwargs: Any +def build_get_table_request( + resource_group_name: str, account_name: str, table_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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/tableRoleDefinitions/{roleDefinitionId}", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/tables/{tableName}", ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), @@ -391,7 +392,7 @@ def build_get_table_role_definition_request( "accountName": _SERIALIZER.url( "account_name", account_name, "str", max_length=50, min_length=3, pattern=r"^[a-z0-9]+(-[a-z0-9]+)*" ), - "roleDefinitionId": _SERIALIZER.url("role_definition_id", role_definition_id, "str"), + "tableName": _SERIALIZER.url("table_name", table_name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -405,20 +406,20 @@ def build_get_table_role_definition_request( return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_update_table_role_definition_request( # pylint: disable=name-too-long - resource_group_name: str, account_name: str, role_definition_id: str, subscription_id: str, **kwargs: Any +def build_create_update_table_request( + resource_group_name: str, account_name: str, table_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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) 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.DocumentDB/databaseAccounts/{accountName}/tableRoleDefinitions/{roleDefinitionId}", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/tables/{tableName}", ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), @@ -428,7 +429,7 @@ def build_create_update_table_role_definition_request( # pylint: disable=name-t "accountName": _SERIALIZER.url( "account_name", account_name, "str", max_length=50, min_length=3, pattern=r"^[a-z0-9]+(-[a-z0-9]+)*" ), - "roleDefinitionId": _SERIALIZER.url("role_definition_id", role_definition_id, "str"), + "tableName": _SERIALIZER.url("table_name", table_name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -444,19 +445,19 @@ def build_create_update_table_role_definition_request( # pylint: disable=name-t return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_delete_table_role_definition_request( # pylint: disable=name-too-long - resource_group_name: str, account_name: str, role_definition_id: str, subscription_id: str, **kwargs: Any +def build_delete_table_request( + resource_group_name: str, account_name: str, table_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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/tableRoleDefinitions/{roleDefinitionId}", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/tables/{tableName}", ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), @@ -466,7 +467,7 @@ def build_delete_table_role_definition_request( # pylint: disable=name-too-long "accountName": _SERIALIZER.url( "account_name", account_name, "str", max_length=50, min_length=3, pattern=r"^[a-z0-9]+(-[a-z0-9]+)*" ), - "roleDefinitionId": _SERIALIZER.url("role_definition_id", role_definition_id, "str"), + "tableName": _SERIALIZER.url("table_name", table_name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -480,19 +481,20 @@ def build_delete_table_role_definition_request( # pylint: disable=name-too-long return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_table_role_definitions_request( # pylint: disable=name-too-long - resource_group_name: str, account_name: str, subscription_id: str, **kwargs: Any +def build_retrieve_continuous_backup_information_request( # pylint: disable=name-too-long + resource_group_name: str, account_name: str, table_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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) + 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.DocumentDB/databaseAccounts/{accountName}/tableRoleDefinitions", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/tables/{tableName}/retrieveContinuousBackupInformation", ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), @@ -502,6 +504,7 @@ def build_list_table_role_definitions_request( # pylint: disable=name-too-long "accountName": _SERIALIZER.url( "account_name", account_name, "str", max_length=50, min_length=3, pattern=r"^[a-z0-9]+(-[a-z0-9]+)*" ), + "tableName": _SERIALIZER.url("table_name", table_name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -510,24 +513,26 @@ def build_list_table_role_definitions_request( # pylint: disable=name-too-long _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="GET", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_get_table_role_assignment_request( - resource_group_name: str, account_name: str, role_assignment_id: str, subscription_id: str, **kwargs: Any +def build_get_table_throughput_request( + resource_group_name: str, account_name: str, table_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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/tableRoleAssignments/{roleAssignmentId}", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/tables/{tableName}/throughputSettings/default", ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), @@ -537,7 +542,7 @@ def build_get_table_role_assignment_request( "accountName": _SERIALIZER.url( "account_name", account_name, "str", max_length=50, min_length=3, pattern=r"^[a-z0-9]+(-[a-z0-9]+)*" ), - "roleAssignmentId": _SERIALIZER.url("role_assignment_id", role_assignment_id, "str"), + "tableName": _SERIALIZER.url("table_name", table_name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -551,20 +556,20 @@ def build_get_table_role_assignment_request( return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_update_table_role_assignment_request( # pylint: disable=name-too-long - resource_group_name: str, account_name: str, role_assignment_id: str, subscription_id: str, **kwargs: Any +def build_update_table_throughput_request( + resource_group_name: str, account_name: str, table_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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) 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.DocumentDB/databaseAccounts/{accountName}/tableRoleAssignments/{roleAssignmentId}", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/tables/{tableName}/throughputSettings/default", ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), @@ -574,7 +579,7 @@ def build_create_update_table_role_assignment_request( # pylint: disable=name-t "accountName": _SERIALIZER.url( "account_name", account_name, "str", max_length=50, min_length=3, pattern=r"^[a-z0-9]+(-[a-z0-9]+)*" ), - "roleAssignmentId": _SERIALIZER.url("role_assignment_id", role_assignment_id, "str"), + "tableName": _SERIALIZER.url("table_name", table_name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -590,19 +595,19 @@ def build_create_update_table_role_assignment_request( # pylint: disable=name-t return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_delete_table_role_assignment_request( # pylint: disable=name-too-long - resource_group_name: str, account_name: str, role_assignment_id: str, subscription_id: str, **kwargs: Any +def build_migrate_table_to_autoscale_request( + resource_group_name: str, account_name: str, table_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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/tableRoleAssignments/{roleAssignmentId}", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/tables/{tableName}/throughputSettings/default/migrateToAutoscale", ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), @@ -612,7 +617,7 @@ def build_delete_table_role_assignment_request( # pylint: disable=name-too-long "accountName": _SERIALIZER.url( "account_name", account_name, "str", max_length=50, min_length=3, pattern=r"^[a-z0-9]+(-[a-z0-9]+)*" ), - "roleAssignmentId": _SERIALIZER.url("role_assignment_id", role_assignment_id, "str"), + "tableName": _SERIALIZER.url("table_name", table_name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -623,22 +628,22 @@ def build_delete_table_role_assignment_request( # pylint: disable=name-too-long # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_table_role_assignments_request( # pylint: disable=name-too-long - resource_group_name: str, account_name: str, subscription_id: str, **kwargs: Any +def build_migrate_table_to_manual_throughput_request( # pylint: disable=name-too-long + resource_group_name: str, account_name: str, table_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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/tableRoleAssignments", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/tables/{tableName}/throughputSettings/default/migrateToManualThroughput", ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), @@ -648,6 +653,7 @@ def build_list_table_role_assignments_request( # pylint: disable=name-too-long "accountName": _SERIALIZER.url( "account_name", account_name, "str", max_length=50, min_length=3, pattern=r"^[a-z0-9]+(-[a-z0-9]+)*" ), + "tableName": _SERIALIZER.url("table_name", table_name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -658,7 +664,7 @@ def build_list_table_role_assignments_request( # pylint: disable=name-too-long # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) class TableResourcesOperations: # pylint: disable=too-many-public-methods @@ -681,25 +687,26 @@ def __init__(self, *args, **kwargs) -> None: self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def list_tables( + def list_table_role_assignments( self, resource_group_name: str, account_name: str, **kwargs: Any - ) -> ItemPaged["_models.TableGetResults"]: - """Lists the Tables under an existing Azure Cosmos DB database account. + ) -> ItemPaged["_models.TableRoleAssignmentResource"]: + """Retrieves the list of all Azure Cosmos DB Table Role Assignments. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param account_name: Cosmos DB database account name. Required. :type account_name: str - :return: An iterator like instance of either TableGetResults or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cosmosdb.models.TableGetResults] + :return: An iterator like instance of either TableRoleAssignmentResource or the result of + cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cosmosdb.models.TableRoleAssignmentResource] :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.TableListResult] = kwargs.pop("cls", None) + cls: ClsType[_models.TableRoleAssignmentListResult] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -712,7 +719,7 @@ def list_tables( def prepare_request(next_link=None): if not next_link: - _request = build_list_tables_request( + _request = build_list_table_role_assignments_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -740,11 +747,11 @@ def prepare_request(next_link=None): return _request def extract_data(pipeline_response): - deserialized = self._deserialize("TableListResult", pipeline_response) + deserialized = self._deserialize("TableRoleAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore - return None, iter(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): _request = prepare_request(next_link) @@ -757,27 +764,32 @@ 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + 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_table( - self, resource_group_name: str, account_name: str, table_name: str, **kwargs: Any - ) -> _models.TableGetResults: - """Gets the Tables under an existing Azure Cosmos DB database account with the provided name. + def get_table_role_assignment( + self, resource_group_name: str, account_name: str, role_assignment_id: str, **kwargs: Any + ) -> _models.TableRoleAssignmentResource: + """Retrieves the properties of an existing Azure Cosmos DB Table Role Assignment with the given + Id. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param table_name: Cosmos DB table name. Required. - :type table_name: str - :return: TableGetResults or the result of cls(response) - :rtype: ~azure.mgmt.cosmosdb.models.TableGetResults + :param role_assignment_id: The GUID for the Role Assignment. Required. + :type role_assignment_id: str + :return: TableRoleAssignmentResource or the result of cls(response) + :rtype: ~azure.mgmt.cosmosdb.models.TableRoleAssignmentResource :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -792,12 +804,12 @@ def get_table( _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.TableGetResults] = kwargs.pop("cls", None) + cls: ClsType[_models.TableRoleAssignmentResource] = kwargs.pop("cls", None) - _request = build_get_table_request( + _request = build_get_table_role_assignment_request( resource_group_name=resource_group_name, account_name=account_name, - table_name=table_name, + role_assignment_id=role_assignment_id, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, @@ -814,21 +826,25 @@ def get_table( if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("TableGetResults", pipeline_response.http_response) + deserialized = self._deserialize("TableRoleAssignmentResource", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - def _create_update_table_initial( + def _create_update_table_role_assignment_initial( # pylint: disable=name-too-long self, resource_group_name: str, account_name: str, - table_name: str, - create_update_table_parameters: Union[_models.TableCreateUpdateParameters, IO[bytes]], + role_assignment_id: str, + create_update_table_role_assignment_parameters: Union[_models.TableRoleAssignmentResource, IO[bytes]], **kwargs: Any ) -> Iterator[bytes]: error_map: MutableMapping = { @@ -849,15 +865,15 @@ def _create_update_table_initial( content_type = content_type or "application/json" _json = None _content = None - if isinstance(create_update_table_parameters, (IOBase, bytes)): - _content = create_update_table_parameters + if isinstance(create_update_table_role_assignment_parameters, (IOBase, bytes)): + _content = create_update_table_role_assignment_parameters else: - _json = self._serialize.body(create_update_table_parameters, "TableCreateUpdateParameters") + _json = self._serialize.body(create_update_table_role_assignment_parameters, "TableRoleAssignmentResource") - _request = build_create_update_table_request( + _request = build_create_update_table_role_assignment_request( resource_group_name=resource_group_name, account_name=account_name, - table_name=table_name, + role_assignment_id=role_assignment_id, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, @@ -882,14 +898,19 @@ def _create_update_table_initial( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + 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["azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("azure-AsyncOperation") + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") ) - response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) @@ -899,94 +920,96 @@ def _create_update_table_initial( return deserialized # type: ignore @overload - def begin_create_update_table( + def begin_create_update_table_role_assignment( # pylint: disable=name-too-long self, resource_group_name: str, account_name: str, - table_name: str, - create_update_table_parameters: _models.TableCreateUpdateParameters, + role_assignment_id: str, + create_update_table_role_assignment_parameters: _models.TableRoleAssignmentResource, *, content_type: str = "application/json", **kwargs: Any - ) -> LROPoller[_models.TableGetResults]: - """Create or update an Azure Cosmos DB Table. + ) -> LROPoller[_models.TableRoleAssignmentResource]: + """Creates or updates an Azure Cosmos DB Table Role Assignment. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param table_name: Cosmos DB table name. Required. - :type table_name: str - :param create_update_table_parameters: The parameters to provide for the current Table. - Required. - :type create_update_table_parameters: ~azure.mgmt.cosmosdb.models.TableCreateUpdateParameters - :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 TableGetResults or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.TableGetResults] + :param role_assignment_id: The GUID for the Role Assignment. Required. + :type role_assignment_id: str + :param create_update_table_role_assignment_parameters: The properties required to create or + update a Role Assignment. Required. + :type create_update_table_role_assignment_parameters: + ~azure.mgmt.cosmosdb.models.TableRoleAssignmentResource + :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 TableRoleAssignmentResource or the result + of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.TableRoleAssignmentResource] :raises ~azure.core.exceptions.HttpResponseError: """ @overload - def begin_create_update_table( + def begin_create_update_table_role_assignment( # pylint: disable=name-too-long self, resource_group_name: str, account_name: str, - table_name: str, - create_update_table_parameters: IO[bytes], + role_assignment_id: str, + create_update_table_role_assignment_parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> LROPoller[_models.TableGetResults]: - """Create or update an Azure Cosmos DB Table. + ) -> LROPoller[_models.TableRoleAssignmentResource]: + """Creates or updates an Azure Cosmos DB Table Role Assignment. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param table_name: Cosmos DB table name. Required. - :type table_name: str - :param create_update_table_parameters: The parameters to provide for the current Table. - Required. - :type create_update_table_parameters: IO[bytes] + :param role_assignment_id: The GUID for the Role Assignment. Required. + :type role_assignment_id: str + :param create_update_table_role_assignment_parameters: The properties required to create or + update a Role Assignment. Required. + :type create_update_table_role_assignment_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 TableGetResults or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.TableGetResults] + :return: An instance of LROPoller that returns either TableRoleAssignmentResource or the result + of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.TableRoleAssignmentResource] :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace - def begin_create_update_table( + def begin_create_update_table_role_assignment( # pylint: disable=name-too-long self, resource_group_name: str, account_name: str, - table_name: str, - create_update_table_parameters: Union[_models.TableCreateUpdateParameters, IO[bytes]], + role_assignment_id: str, + create_update_table_role_assignment_parameters: Union[_models.TableRoleAssignmentResource, IO[bytes]], **kwargs: Any - ) -> LROPoller[_models.TableGetResults]: - """Create or update an Azure Cosmos DB Table. + ) -> LROPoller[_models.TableRoleAssignmentResource]: + """Creates or updates an Azure Cosmos DB Table Role Assignment. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param table_name: Cosmos DB table name. Required. - :type table_name: str - :param create_update_table_parameters: The parameters to provide for the current Table. Is - either a TableCreateUpdateParameters type or a IO[bytes] type. Required. - :type create_update_table_parameters: ~azure.mgmt.cosmosdb.models.TableCreateUpdateParameters - or IO[bytes] - :return: An instance of LROPoller that returns either TableGetResults or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.TableGetResults] + :param role_assignment_id: The GUID for the Role Assignment. Required. + :type role_assignment_id: str + :param create_update_table_role_assignment_parameters: The properties required to create or + update a Role Assignment. Is either a TableRoleAssignmentResource type or a IO[bytes] type. + Required. + :type create_update_table_role_assignment_parameters: + ~azure.mgmt.cosmosdb.models.TableRoleAssignmentResource or IO[bytes] + :return: An instance of LROPoller that returns either TableRoleAssignmentResource or the result + of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.TableRoleAssignmentResource] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -994,16 +1017,16 @@ def begin_create_update_table( 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.TableGetResults] = kwargs.pop("cls", None) + cls: ClsType[_models.TableRoleAssignmentResource] = 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_update_table_initial( + raw_result = self._create_update_table_role_assignment_initial( resource_group_name=resource_group_name, account_name=account_name, - table_name=table_name, - create_update_table_parameters=create_update_table_parameters, + role_assignment_id=role_assignment_id, + create_update_table_role_assignment_parameters=create_update_table_role_assignment_parameters, api_version=api_version, content_type=content_type, cls=lambda x, y, z: x, @@ -1015,30 +1038,32 @@ def begin_create_update_table( kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("TableGetResults", pipeline_response.http_response) + deserialized = self._deserialize("TableRoleAssignmentResource", 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, **kwargs)) + 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.TableGetResults].from_continuation_token( + return LROPoller[_models.TableRoleAssignmentResource].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller[_models.TableGetResults]( + return LROPoller[_models.TableRoleAssignmentResource]( self._client, raw_result, get_long_running_output, polling_method # type: ignore ) - def _delete_table_initial( - self, resource_group_name: str, account_name: str, table_name: str, **kwargs: Any + def _delete_table_role_assignment_initial( + self, resource_group_name: str, account_name: str, role_assignment_id: str, **kwargs: Any ) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -1054,10 +1079,10 @@ def _delete_table_initial( 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_table_request( + _request = build_delete_table_role_assignment_request( resource_group_name=resource_group_name, account_name=account_name, - table_name=table_name, + role_assignment_id=role_assignment_id, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, @@ -1073,20 +1098,24 @@ def _delete_table_initial( response = pipeline_response.http_response - if response.status_code not in [202, 204]: + if response.status_code not in [200, 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + 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["azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("azure-AsyncOperation") + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") ) - response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) @@ -1096,18 +1125,18 @@ def _delete_table_initial( return deserialized # type: ignore @distributed_trace - def begin_delete_table( - self, resource_group_name: str, account_name: str, table_name: str, **kwargs: Any + def begin_delete_table_role_assignment( + self, resource_group_name: str, account_name: str, role_assignment_id: str, **kwargs: Any ) -> LROPoller[None]: - """Deletes an existing Azure Cosmos DB Table. + """Deletes an existing Azure Cosmos DB Table Role Assignment. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param table_name: Cosmos DB table name. Required. - :type table_name: str + :param role_assignment_id: The GUID for the Role Assignment. Required. + :type role_assignment_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: @@ -1121,10 +1150,10 @@ def begin_delete_table( 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_table_initial( + raw_result = self._delete_table_role_assignment_initial( resource_group_name=resource_group_name, account_name=account_name, - table_name=table_name, + role_assignment_id=role_assignment_id, api_version=api_version, cls=lambda x, y, z: x, headers=_headers, @@ -1139,7 +1168,9 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- return cls(pipeline_response, None, {}) # type: ignore if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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: @@ -1154,21 +1185,109 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore @distributed_trace - def get_table_throughput( - self, resource_group_name: str, account_name: str, table_name: str, **kwargs: Any - ) -> _models.ThroughputSettingsGetResults: - """Gets the RUs per second of the Table under an existing Azure Cosmos DB database account with - the provided name. + def list_table_role_definitions( + self, resource_group_name: str, account_name: str, **kwargs: Any + ) -> ItemPaged["_models.TableRoleDefinitionResource"]: + """Retrieves the list of all Azure Cosmos DB Table Role Definitions. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param table_name: Cosmos DB table name. Required. - :type table_name: str - :return: ThroughputSettingsGetResults or the result of cls(response) - :rtype: ~azure.mgmt.cosmosdb.models.ThroughputSettingsGetResults + :return: An iterator like instance of either TableRoleDefinitionResource or the result of + cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cosmosdb.models.TableRoleDefinitionResource] + :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.TableRoleDefinitionListResult] = 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_table_role_definitions_request( + resource_group_name=resource_group_name, + account_name=account_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("TableRoleDefinitionListResult", 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_table_role_definition( + self, resource_group_name: str, account_name: str, role_definition_id: str, **kwargs: Any + ) -> _models.TableRoleDefinitionResource: + """Retrieves the properties of an existing Azure Cosmos DB Table Role Definition with the given + Id. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param role_definition_id: The GUID for the Role Definition. Required. + :type role_definition_id: str + :return: TableRoleDefinitionResource or the result of cls(response) + :rtype: ~azure.mgmt.cosmosdb.models.TableRoleDefinitionResource :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -1183,12 +1302,12 @@ def get_table_throughput( _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.ThroughputSettingsGetResults] = kwargs.pop("cls", None) + cls: ClsType[_models.TableRoleDefinitionResource] = kwargs.pop("cls", None) - _request = build_get_table_throughput_request( + _request = build_get_table_role_definition_request( resource_group_name=resource_group_name, account_name=account_name, - table_name=table_name, + role_definition_id=role_definition_id, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, @@ -1205,21 +1324,25 @@ def get_table_throughput( if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("ThroughputSettingsGetResults", pipeline_response.http_response) + deserialized = self._deserialize("TableRoleDefinitionResource", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - def _update_table_throughput_initial( + def _create_update_table_role_definition_initial( # pylint: disable=name-too-long self, resource_group_name: str, account_name: str, - table_name: str, - update_throughput_parameters: Union[_models.ThroughputSettingsUpdateParameters, IO[bytes]], + role_definition_id: str, + create_update_table_role_definition_parameters: Union[_models.TableRoleDefinitionResource, IO[bytes]], **kwargs: Any ) -> Iterator[bytes]: error_map: MutableMapping = { @@ -1240,15 +1363,15 @@ def _update_table_throughput_initial( content_type = content_type or "application/json" _json = None _content = None - if isinstance(update_throughput_parameters, (IOBase, bytes)): - _content = update_throughput_parameters + if isinstance(create_update_table_role_definition_parameters, (IOBase, bytes)): + _content = create_update_table_role_definition_parameters else: - _json = self._serialize.body(update_throughput_parameters, "ThroughputSettingsUpdateParameters") + _json = self._serialize.body(create_update_table_role_definition_parameters, "TableRoleDefinitionResource") - _request = build_update_table_throughput_request( + _request = build_create_update_table_role_definition_request( resource_group_name=resource_group_name, account_name=account_name, - table_name=table_name, + role_definition_id=role_definition_id, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, @@ -1273,14 +1396,18 @@ def _update_table_throughput_initial( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - response_headers = {} + 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["azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("azure-AsyncOperation") + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") ) - response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) @@ -1290,96 +1417,96 @@ def _update_table_throughput_initial( return deserialized # type: ignore @overload - def begin_update_table_throughput( + def begin_create_update_table_role_definition( # pylint: disable=name-too-long self, resource_group_name: str, account_name: str, - table_name: str, - update_throughput_parameters: _models.ThroughputSettingsUpdateParameters, + role_definition_id: str, + create_update_table_role_definition_parameters: _models.TableRoleDefinitionResource, *, content_type: str = "application/json", **kwargs: Any - ) -> LROPoller[_models.ThroughputSettingsGetResults]: - """Update RUs per second of an Azure Cosmos DB Table. + ) -> LROPoller[_models.TableRoleDefinitionResource]: + """Creates or updates an Azure Cosmos DB Table Role Definition. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param table_name: Cosmos DB table name. Required. - :type table_name: str - :param update_throughput_parameters: The parameters to provide for the RUs per second of the - current Table. Required. - :type update_throughput_parameters: - ~azure.mgmt.cosmosdb.models.ThroughputSettingsUpdateParameters + :param role_definition_id: The GUID for the Role Definition. Required. + :type role_definition_id: str + :param create_update_table_role_definition_parameters: The properties required to create or + update a Role Definition. Required. + :type create_update_table_role_definition_parameters: + ~azure.mgmt.cosmosdb.models.TableRoleDefinitionResource :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 ThroughputSettingsGetResults or the - result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.ThroughputSettingsGetResults] + :return: An instance of LROPoller that returns either TableRoleDefinitionResource or the result + of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.TableRoleDefinitionResource] :raises ~azure.core.exceptions.HttpResponseError: """ @overload - def begin_update_table_throughput( + def begin_create_update_table_role_definition( # pylint: disable=name-too-long self, resource_group_name: str, account_name: str, - table_name: str, - update_throughput_parameters: IO[bytes], + role_definition_id: str, + create_update_table_role_definition_parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> LROPoller[_models.ThroughputSettingsGetResults]: - """Update RUs per second of an Azure Cosmos DB Table. + ) -> LROPoller[_models.TableRoleDefinitionResource]: + """Creates or updates an Azure Cosmos DB Table Role Definition. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param table_name: Cosmos DB table name. Required. - :type table_name: str - :param update_throughput_parameters: The parameters to provide for the RUs per second of the - current Table. Required. - :type update_throughput_parameters: IO[bytes] + :param role_definition_id: The GUID for the Role Definition. Required. + :type role_definition_id: str + :param create_update_table_role_definition_parameters: The properties required to create or + update a Role Definition. Required. + :type create_update_table_role_definition_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 ThroughputSettingsGetResults or the - result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.ThroughputSettingsGetResults] + :return: An instance of LROPoller that returns either TableRoleDefinitionResource or the result + of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.TableRoleDefinitionResource] :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace - def begin_update_table_throughput( + def begin_create_update_table_role_definition( # pylint: disable=name-too-long self, resource_group_name: str, account_name: str, - table_name: str, - update_throughput_parameters: Union[_models.ThroughputSettingsUpdateParameters, IO[bytes]], + role_definition_id: str, + create_update_table_role_definition_parameters: Union[_models.TableRoleDefinitionResource, IO[bytes]], **kwargs: Any - ) -> LROPoller[_models.ThroughputSettingsGetResults]: - """Update RUs per second of an Azure Cosmos DB Table. + ) -> LROPoller[_models.TableRoleDefinitionResource]: + """Creates or updates an Azure Cosmos DB Table Role Definition. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param table_name: Cosmos DB table name. Required. - :type table_name: str - :param update_throughput_parameters: The parameters to provide for the RUs per second of the - current Table. Is either a ThroughputSettingsUpdateParameters type or a IO[bytes] type. + :param role_definition_id: The GUID for the Role Definition. Required. + :type role_definition_id: str + :param create_update_table_role_definition_parameters: The properties required to create or + update a Role Definition. Is either a TableRoleDefinitionResource type or a IO[bytes] type. Required. - :type update_throughput_parameters: - ~azure.mgmt.cosmosdb.models.ThroughputSettingsUpdateParameters or IO[bytes] - :return: An instance of LROPoller that returns either ThroughputSettingsGetResults or the - result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.ThroughputSettingsGetResults] + :type create_update_table_role_definition_parameters: + ~azure.mgmt.cosmosdb.models.TableRoleDefinitionResource or IO[bytes] + :return: An instance of LROPoller that returns either TableRoleDefinitionResource or the result + of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.TableRoleDefinitionResource] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -1387,16 +1514,16 @@ def begin_update_table_throughput( 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.ThroughputSettingsGetResults] = kwargs.pop("cls", None) + cls: ClsType[_models.TableRoleDefinitionResource] = 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_table_throughput_initial( + raw_result = self._create_update_table_role_definition_initial( resource_group_name=resource_group_name, account_name=account_name, - table_name=table_name, - update_throughput_parameters=update_throughput_parameters, + role_definition_id=role_definition_id, + create_update_table_role_definition_parameters=create_update_table_role_definition_parameters, api_version=api_version, content_type=content_type, cls=lambda x, y, z: x, @@ -1408,30 +1535,32 @@ def begin_update_table_throughput( kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ThroughputSettingsGetResults", pipeline_response.http_response) + deserialized = self._deserialize("TableRoleDefinitionResource", 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, **kwargs)) + 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.ThroughputSettingsGetResults].from_continuation_token( + return LROPoller[_models.TableRoleDefinitionResource].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller[_models.ThroughputSettingsGetResults]( + return LROPoller[_models.TableRoleDefinitionResource]( self._client, raw_result, get_long_running_output, polling_method # type: ignore ) - def _migrate_table_to_autoscale_initial( - self, resource_group_name: str, account_name: str, table_name: str, **kwargs: Any + def _delete_table_role_definition_initial( + self, resource_group_name: str, account_name: str, role_definition_id: str, **kwargs: Any ) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -1447,10 +1576,10 @@ def _migrate_table_to_autoscale_initial( 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_migrate_table_to_autoscale_request( + _request = build_delete_table_role_definition_request( resource_group_name=resource_group_name, account_name=account_name, - table_name=table_name, + role_definition_id=role_definition_id, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, @@ -1466,20 +1595,24 @@ def _migrate_table_to_autoscale_initial( response = pipeline_response.http_response - if response.status_code not in [200, 202]: + if response.status_code not in [200, 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + 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["azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("azure-AsyncOperation") + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") ) - response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) @@ -1489,36 +1622,35 @@ def _migrate_table_to_autoscale_initial( return deserialized # type: ignore @distributed_trace - def begin_migrate_table_to_autoscale( - self, resource_group_name: str, account_name: str, table_name: str, **kwargs: Any - ) -> LROPoller[_models.ThroughputSettingsGetResults]: - """Migrate an Azure Cosmos DB Table from manual throughput to autoscale. + def begin_delete_table_role_definition( + self, resource_group_name: str, account_name: str, role_definition_id: str, **kwargs: Any + ) -> LROPoller[None]: + """Deletes an existing Azure Cosmos DB Table Role Definition. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param table_name: Cosmos DB table name. Required. - :type table_name: str - :return: An instance of LROPoller that returns either ThroughputSettingsGetResults or the - result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.ThroughputSettingsGetResults] + :param role_definition_id: The GUID for the Role Definition. Required. + :type role_definition_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[_models.ThroughputSettingsGetResults] = kwargs.pop("cls", 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._migrate_table_to_autoscale_initial( + raw_result = self._delete_table_role_definition_initial( resource_group_name=resource_group_name, account_name=account_name, - table_name=table_name, + role_definition_id=role_definition_id, api_version=api_version, cls=lambda x, y, z: x, headers=_headers, @@ -1528,32 +1660,48 @@ def begin_migrate_table_to_autoscale( raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ThroughputSettingsGetResults", pipeline_response.http_response) + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return cls(pipeline_response, None, {}) # type: ignore if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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.ThroughputSettingsGetResults].from_continuation_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[_models.ThroughputSettingsGetResults]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + def list_tables( + self, resource_group_name: str, account_name: str, **kwargs: Any + ) -> ItemPaged["_models.TableGetResults"]: + """Lists the Tables under an existing Azure Cosmos DB database account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :return: An iterator like instance of either TableGetResults or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cosmosdb.models.TableGetResults] + :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.TableListResult] = kwargs.pop("cls", None) - def _migrate_table_to_manual_throughput_initial( # pylint: disable=name-too-long - self, resource_group_name: str, account_name: str, table_name: str, **kwargs: Any - ) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -1562,58 +1710,69 @@ def _migrate_table_to_manual_throughput_initial( # pylint: disable=name-too-lon } 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) + def prepare_request(next_link=None): + if not next_link: - _request = build_migrate_table_to_manual_throughput_request( - resource_group_name=resource_group_name, - account_name=account_name, - table_name=table_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) + _request = build_list_tables_request( + resource_group_name=resource_group_name, + account_name=account_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 - ) + 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 - response = pipeline_response.http_response + def extract_data(pipeline_response): + deserialized = self._deserialize("TableListResult", 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) - 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + def get_next(next_link=None): + _request = prepare_request(next_link) - response_headers = {} - if response.status_code == 202: - response_headers["azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("azure-AsyncOperation") + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs ) - response_headers["location"] = self._deserialize("str", response.headers.get("location")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + response = pipeline_response.http_response - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore + 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 deserialized # type: ignore + return pipeline_response + + return ItemPaged(get_next, extract_data) @distributed_trace - def begin_migrate_table_to_manual_throughput( + def get_table( self, resource_group_name: str, account_name: str, table_name: str, **kwargs: Any - ) -> LROPoller[_models.ThroughputSettingsGetResults]: - """Migrate an Azure Cosmos DB Table from autoscale to manual throughput. + ) -> _models.TableGetResults: + """Gets the Tables under an existing Azure Cosmos DB database account with the provided name. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -1622,62 +1781,63 @@ def begin_migrate_table_to_manual_throughput( :type account_name: str :param table_name: Cosmos DB table name. Required. :type table_name: str - :return: An instance of LROPoller that returns either ThroughputSettingsGetResults or the - result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.ThroughputSettingsGetResults] + :return: TableGetResults or the result of cls(response) + :rtype: ~azure.mgmt.cosmosdb.models.TableGetResults :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.ThroughputSettingsGetResults] = 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_table_to_manual_throughput_initial( - resource_group_name=resource_group_name, - account_name=account_name, - table_name=table_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) + cls: ClsType[_models.TableGetResults] = kwargs.pop("cls", None) - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ThroughputSettingsGetResults", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + _request = build_get_table_request( + resource_group_name=resource_group_name, + account_name=account_name, + table_name=table_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) - if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[_models.ThroughputSettingsGetResults].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.ThroughputSettingsGetResults]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs ) - def _retrieve_continuous_backup_information_initial( # pylint: disable=name-too-long + 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("TableGetResults", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + def _create_update_table_initial( self, resource_group_name: str, account_name: str, table_name: str, - location: Union[_models.ContinuousBackupRestoreLocation, IO[bytes]], + create_update_table_parameters: Union[_models.TableCreateUpdateParameters, IO[bytes]], **kwargs: Any ) -> Iterator[bytes]: error_map: MutableMapping = { @@ -1698,12 +1858,12 @@ def _retrieve_continuous_backup_information_initial( # pylint: disable=name-too content_type = content_type or "application/json" _json = None _content = None - if isinstance(location, (IOBase, bytes)): - _content = location + if isinstance(create_update_table_parameters, (IOBase, bytes)): + _content = create_update_table_parameters else: - _json = self._serialize.body(location, "ContinuousBackupRestoreLocation") + _json = self._serialize.body(create_update_table_parameters, "TableCreateUpdateParameters") - _request = build_retrieve_continuous_backup_information_request( + _request = build_create_update_table_request( resource_group_name=resource_group_name, account_name=account_name, table_name=table_name, @@ -1731,27 +1891,39 @@ def _retrieve_continuous_backup_information_initial( # pylint: disable=name-too except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + 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["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.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @overload - def begin_retrieve_continuous_backup_information( # pylint: disable=name-too-long + def begin_create_update_table( self, resource_group_name: str, account_name: str, table_name: str, - location: _models.ContinuousBackupRestoreLocation, + create_update_table_parameters: _models.TableCreateUpdateParameters, *, content_type: str = "application/json", **kwargs: Any - ) -> LROPoller[_models.BackupInformation]: - """Retrieves continuous backup information for a table. + ) -> LROPoller[_models.TableGetResults]: + """Create or update an Azure Cosmos DB Table. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -1760,29 +1932,30 @@ def begin_retrieve_continuous_backup_information( # pylint: disable=name-too-lo :type account_name: str :param table_name: Cosmos DB table name. Required. :type table_name: str - :param location: The name of the continuous backup restore location. Required. - :type location: ~azure.mgmt.cosmosdb.models.ContinuousBackupRestoreLocation + :param create_update_table_parameters: The parameters to provide for the current Table. + Required. + :type create_update_table_parameters: ~azure.mgmt.cosmosdb.models.TableCreateUpdateParameters :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 BackupInformation or the result of + :return: An instance of LROPoller that returns either TableGetResults or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.BackupInformation] + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.TableGetResults] :raises ~azure.core.exceptions.HttpResponseError: """ @overload - def begin_retrieve_continuous_backup_information( # pylint: disable=name-too-long + def begin_create_update_table( self, resource_group_name: str, account_name: str, table_name: str, - location: IO[bytes], + create_update_table_parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> LROPoller[_models.BackupInformation]: - """Retrieves continuous backup information for a table. + ) -> LROPoller[_models.TableGetResults]: + """Create or update an Azure Cosmos DB Table. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -1791,27 +1964,28 @@ def begin_retrieve_continuous_backup_information( # pylint: disable=name-too-lo :type account_name: str :param table_name: Cosmos DB table name. Required. :type table_name: str - :param location: The name of the continuous backup restore location. Required. - :type location: IO[bytes] + :param create_update_table_parameters: The parameters to provide for the current Table. + Required. + :type create_update_table_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 BackupInformation or the result of + :return: An instance of LROPoller that returns either TableGetResults or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.BackupInformation] + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.TableGetResults] :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace - def begin_retrieve_continuous_backup_information( # pylint: disable=name-too-long + def begin_create_update_table( self, resource_group_name: str, account_name: str, table_name: str, - location: Union[_models.ContinuousBackupRestoreLocation, IO[bytes]], + create_update_table_parameters: Union[_models.TableCreateUpdateParameters, IO[bytes]], **kwargs: Any - ) -> LROPoller[_models.BackupInformation]: - """Retrieves continuous backup information for a table. + ) -> LROPoller[_models.TableGetResults]: + """Create or update an Azure Cosmos DB Table. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -1820,12 +1994,13 @@ def begin_retrieve_continuous_backup_information( # pylint: disable=name-too-lo :type account_name: str :param table_name: Cosmos DB table name. Required. :type table_name: str - :param location: The name of the continuous backup restore location. Is either a - ContinuousBackupRestoreLocation type or a IO[bytes] type. Required. - :type location: ~azure.mgmt.cosmosdb.models.ContinuousBackupRestoreLocation or IO[bytes] - :return: An instance of LROPoller that returns either BackupInformation or the result of + :param create_update_table_parameters: The parameters to provide for the current Table. Is + either a TableCreateUpdateParameters type or a IO[bytes] type. Required. + :type create_update_table_parameters: ~azure.mgmt.cosmosdb.models.TableCreateUpdateParameters + or IO[bytes] + :return: An instance of LROPoller that returns either TableGetResults or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.BackupInformation] + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.TableGetResults] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -1833,16 +2008,16 @@ def begin_retrieve_continuous_backup_information( # pylint: disable=name-too-lo 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.BackupInformation] = kwargs.pop("cls", None) + cls: ClsType[_models.TableGetResults] = 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._retrieve_continuous_backup_information_initial( + raw_result = self._create_update_table_initial( resource_group_name=resource_group_name, account_name=account_name, table_name=table_name, - location=location, + create_update_table_parameters=create_update_table_parameters, api_version=api_version, content_type=content_type, cls=lambda x, y, z: x, @@ -1854,7 +2029,7 @@ def begin_retrieve_continuous_backup_information( # pylint: disable=name-too-lo kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("BackupInformation", pipeline_response.http_response) + deserialized = self._deserialize("TableGetResults", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized @@ -1868,34 +2043,19 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller[_models.BackupInformation].from_continuation_token( + return LROPoller[_models.TableGetResults].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller[_models.BackupInformation]( + return LROPoller[_models.TableGetResults]( self._client, raw_result, get_long_running_output, polling_method # type: ignore ) - @distributed_trace - def get_table_role_definition( - self, resource_group_name: str, account_name: str, role_definition_id: str, **kwargs: Any - ) -> _models.TableRoleDefinitionResource: - """Retrieves the properties of an existing Azure Cosmos DB Table Role Definition with the given - Id. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param account_name: Cosmos DB database account name. Required. - :type account_name: str - :param role_definition_id: The GUID for the Role Definition. Required. - :type role_definition_id: str - :return: TableRoleDefinitionResource or the result of cls(response) - :rtype: ~azure.mgmt.cosmosdb.models.TableRoleDefinitionResource - :raises ~azure.core.exceptions.HttpResponseError: - """ + def _delete_table_initial( + self, resource_group_name: str, account_name: str, table_name: str, **kwargs: Any + ) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -1908,12 +2068,12 @@ def get_table_role_definition( _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.TableRoleDefinitionResource] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - _request = build_get_table_role_definition_request( + _request = build_delete_table_request( resource_group_name=resource_group_name, account_name=account_name, - role_definition_id=role_definition_id, + table_name=table_name, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, @@ -1921,14 +2081,19 @@ def get_table_role_definition( ) _request.url = self._client.format_url(_request.url) - _stream = False + _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]: + 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, @@ -1936,48 +2101,115 @@ def get_table_role_definition( ) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("TableRoleDefinitionResource", pipeline_response.http_response) + 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")) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore - def _create_update_table_role_definition_initial( # pylint: disable=name-too-long - self, - resource_group_name: str, - account_name: str, - role_definition_id: str, - create_update_table_role_definition_parameters: Union[_models.TableRoleDefinitionResource, 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 {}) + @distributed_trace + def begin_delete_table( + self, resource_group_name: str, account_name: str, table_name: str, **kwargs: Any + ) -> LROPoller[None]: + """Deletes an existing Azure Cosmos DB Table. - 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) + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param table_name: Cosmos DB table name. Required. + :type table_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_table_initial( + resource_group_name=resource_group_name, + account_name=account_name, + table_name=table_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 _retrieve_continuous_backup_information_initial( # pylint: disable=name-too-long + self, + resource_group_name: str, + account_name: str, + table_name: str, + location: Union[_models.ContinuousBackupRestoreLocation, 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(create_update_table_role_definition_parameters, (IOBase, bytes)): - _content = create_update_table_role_definition_parameters + if isinstance(location, (IOBase, bytes)): + _content = location else: - _json = self._serialize.body(create_update_table_role_definition_parameters, "TableRoleDefinitionResource") + _json = self._serialize.body(location, "ContinuousBackupRestoreLocation") - _request = build_create_update_table_role_definition_request( + _request = build_retrieve_continuous_backup_information_request( resource_group_name=resource_group_name, account_name=account_name, - role_definition_id=role_definition_id, + table_name=table_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, @@ -2002,18 +2234,12 @@ def _create_update_table_role_definition_initial( # pylint: disable=name-too-lo 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) + raise HttpResponseError(response=response, 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["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) @@ -2023,96 +2249,91 @@ def _create_update_table_role_definition_initial( # pylint: disable=name-too-lo return deserialized # type: ignore @overload - def begin_create_update_table_role_definition( # pylint: disable=name-too-long + def begin_retrieve_continuous_backup_information( # pylint: disable=name-too-long self, resource_group_name: str, account_name: str, - role_definition_id: str, - create_update_table_role_definition_parameters: _models.TableRoleDefinitionResource, + table_name: str, + location: _models.ContinuousBackupRestoreLocation, *, content_type: str = "application/json", **kwargs: Any - ) -> LROPoller[_models.TableRoleDefinitionResource]: - """Creates or updates an Azure Cosmos DB Table Role Definition. + ) -> LROPoller[_models.BackupInformation]: + """Retrieves continuous backup information for a table. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param role_definition_id: The GUID for the Role Definition. Required. - :type role_definition_id: str - :param create_update_table_role_definition_parameters: The properties required to create or - update a Role Definition. Required. - :type create_update_table_role_definition_parameters: - ~azure.mgmt.cosmosdb.models.TableRoleDefinitionResource + :param table_name: Cosmos DB table name. Required. + :type table_name: str + :param location: The name of the continuous backup restore location. Required. + :type location: ~azure.mgmt.cosmosdb.models.ContinuousBackupRestoreLocation :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 TableRoleDefinitionResource or the result - of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.TableRoleDefinitionResource] + :return: An instance of LROPoller that returns either BackupInformation or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.BackupInformation] :raises ~azure.core.exceptions.HttpResponseError: """ @overload - def begin_create_update_table_role_definition( # pylint: disable=name-too-long + def begin_retrieve_continuous_backup_information( # pylint: disable=name-too-long self, resource_group_name: str, account_name: str, - role_definition_id: str, - create_update_table_role_definition_parameters: IO[bytes], + table_name: str, + location: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> LROPoller[_models.TableRoleDefinitionResource]: - """Creates or updates an Azure Cosmos DB Table Role Definition. + ) -> LROPoller[_models.BackupInformation]: + """Retrieves continuous backup information for a table. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param role_definition_id: The GUID for the Role Definition. Required. - :type role_definition_id: str - :param create_update_table_role_definition_parameters: The properties required to create or - update a Role Definition. Required. - :type create_update_table_role_definition_parameters: IO[bytes] + :param table_name: Cosmos DB table name. Required. + :type table_name: str + :param location: The name of the continuous backup restore location. Required. + :type location: 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 TableRoleDefinitionResource or the result - of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.TableRoleDefinitionResource] + :return: An instance of LROPoller that returns either BackupInformation or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.BackupInformation] :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace - def begin_create_update_table_role_definition( # pylint: disable=name-too-long + def begin_retrieve_continuous_backup_information( # pylint: disable=name-too-long self, resource_group_name: str, account_name: str, - role_definition_id: str, - create_update_table_role_definition_parameters: Union[_models.TableRoleDefinitionResource, IO[bytes]], + table_name: str, + location: Union[_models.ContinuousBackupRestoreLocation, IO[bytes]], **kwargs: Any - ) -> LROPoller[_models.TableRoleDefinitionResource]: - """Creates or updates an Azure Cosmos DB Table Role Definition. + ) -> LROPoller[_models.BackupInformation]: + """Retrieves continuous backup information for a table. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param role_definition_id: The GUID for the Role Definition. Required. - :type role_definition_id: str - :param create_update_table_role_definition_parameters: The properties required to create or - update a Role Definition. Is either a TableRoleDefinitionResource type or a IO[bytes] type. - Required. - :type create_update_table_role_definition_parameters: - ~azure.mgmt.cosmosdb.models.TableRoleDefinitionResource or IO[bytes] - :return: An instance of LROPoller that returns either TableRoleDefinitionResource or the result - of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.TableRoleDefinitionResource] + :param table_name: Cosmos DB table name. Required. + :type table_name: str + :param location: The name of the continuous backup restore location. Is either a + ContinuousBackupRestoreLocation type or a IO[bytes] type. Required. + :type location: ~azure.mgmt.cosmosdb.models.ContinuousBackupRestoreLocation or IO[bytes] + :return: An instance of LROPoller that returns either BackupInformation or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.BackupInformation] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -2120,16 +2341,16 @@ def begin_create_update_table_role_definition( # pylint: disable=name-too-long 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.TableRoleDefinitionResource] = kwargs.pop("cls", None) + cls: ClsType[_models.BackupInformation] = 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_update_table_role_definition_initial( + raw_result = self._retrieve_continuous_backup_information_initial( resource_group_name=resource_group_name, account_name=account_name, - role_definition_id=role_definition_id, - create_update_table_role_definition_parameters=create_update_table_role_definition_parameters, + table_name=table_name, + location=location, api_version=api_version, content_type=content_type, cls=lambda x, y, z: x, @@ -2141,31 +2362,48 @@ def begin_create_update_table_role_definition( # pylint: disable=name-too-long kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("TableRoleDefinitionResource", pipeline_response.http_response) + deserialized = self._deserialize("BackupInformation", 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, **kwargs)) + 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.TableRoleDefinitionResource].from_continuation_token( + return LROPoller[_models.BackupInformation].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller[_models.TableRoleDefinitionResource]( + return LROPoller[_models.BackupInformation]( self._client, raw_result, get_long_running_output, polling_method # type: ignore ) - def _delete_table_role_definition_initial( - self, resource_group_name: str, account_name: str, role_definition_id: str, **kwargs: Any - ) -> Iterator[bytes]: + @distributed_trace + def get_table_throughput( + self, resource_group_name: str, account_name: str, table_name: str, **kwargs: Any + ) -> _models.ThroughputSettingsGetResults: + """Gets the RUs per second of the Table under an existing Azure Cosmos DB database account with + the provided name. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param table_name: Cosmos DB table name. Required. + :type table_name: str + :return: ThroughputSettingsGetResults or the result of cls(response) + :rtype: ~azure.mgmt.cosmosdb.models.ThroughputSettingsGetResults + :raises ~azure.core.exceptions.HttpResponseError: + """ error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -2178,12 +2416,12 @@ def _delete_table_role_definition_initial( _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) + cls: ClsType[_models.ThroughputSettingsGetResults] = kwargs.pop("cls", None) - _request = build_delete_table_role_definition_request( + _request = build_get_table_throughput_request( resource_group_name=resource_group_name, account_name=account_name, - role_definition_id=role_definition_id, + table_name=table_name, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, @@ -2191,19 +2429,14 @@ def _delete_table_role_definition_initial( ) _request.url = self._client.format_url(_request.url) - _decompress = kwargs.pop("decompress", True) - _stream = True + _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, 202, 204]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass + 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, @@ -2211,246 +2444,28 @@ def _delete_table_role_definition_initial( ) 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")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + deserialized = self._deserialize("ThroughputSettingsGetResults", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - @distributed_trace - def begin_delete_table_role_definition( - self, resource_group_name: str, account_name: str, role_definition_id: str, **kwargs: Any - ) -> LROPoller[None]: - """Deletes an existing Azure Cosmos DB Table Role Definition. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param account_name: Cosmos DB database account name. Required. - :type account_name: str - :param role_definition_id: The GUID for the Role Definition. Required. - :type role_definition_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_table_role_definition_initial( - resource_group_name=resource_group_name, - account_name=account_name, - role_definition_id=role_definition_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, **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_table_role_definitions( - self, resource_group_name: str, account_name: str, **kwargs: Any - ) -> ItemPaged["_models.TableRoleDefinitionResource"]: - """Retrieves the list of all Azure Cosmos DB Table Role Definitions. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param account_name: Cosmos DB database account name. Required. - :type account_name: str - :return: An iterator like instance of either TableRoleDefinitionResource or the result of - cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cosmosdb.models.TableRoleDefinitionResource] - :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.TableRoleDefinitionListResult] = 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_table_role_definitions_request( - resource_group_name=resource_group_name, - account_name=account_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("TableRoleDefinitionListResult", 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) - - @distributed_trace - def get_table_role_assignment( - self, resource_group_name: str, account_name: str, role_assignment_id: str, **kwargs: Any - ) -> _models.TableRoleAssignmentResource: - """Retrieves the properties of an existing Azure Cosmos DB Table Role Assignment with the given - Id. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param account_name: Cosmos DB database account name. Required. - :type account_name: str - :param role_assignment_id: The GUID for the Role Assignment. Required. - :type role_assignment_id: str - :return: TableRoleAssignmentResource or the result of cls(response) - :rtype: ~azure.mgmt.cosmosdb.models.TableRoleAssignmentResource - :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.TableRoleAssignmentResource] = kwargs.pop("cls", None) - - _request = build_get_table_role_assignment_request( - resource_group_name=resource_group_name, - account_name=account_name, - role_assignment_id=role_assignment_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("TableRoleAssignmentResource", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - def _create_update_table_role_assignment_initial( # pylint: disable=name-too-long - self, - resource_group_name: str, - account_name: str, - role_assignment_id: str, - create_update_table_role_assignment_parameters: Union[_models.TableRoleAssignmentResource, 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 {}) + def _update_table_throughput_initial( + self, + resource_group_name: str, + account_name: str, + table_name: str, + update_throughput_parameters: Union[_models.ThroughputSettingsUpdateParameters, 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 {}) @@ -2462,15 +2477,15 @@ def _create_update_table_role_assignment_initial( # pylint: disable=name-too-lo content_type = content_type or "application/json" _json = None _content = None - if isinstance(create_update_table_role_assignment_parameters, (IOBase, bytes)): - _content = create_update_table_role_assignment_parameters + if isinstance(update_throughput_parameters, (IOBase, bytes)): + _content = update_throughput_parameters else: - _json = self._serialize.body(create_update_table_role_assignment_parameters, "TableRoleAssignmentResource") + _json = self._serialize.body(update_throughput_parameters, "ThroughputSettingsUpdateParameters") - _request = build_create_update_table_role_assignment_request( + _request = build_update_table_throughput_request( resource_group_name=resource_group_name, account_name=account_name, - role_assignment_id=role_assignment_id, + table_name=table_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, @@ -2503,10 +2518,11 @@ def _create_update_table_role_assignment_initial( # pylint: disable=name-too-lo response_headers = {} if response.status_code == 202: - response_headers["azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("azure-AsyncOperation") + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") ) - response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) @@ -2516,96 +2532,96 @@ def _create_update_table_role_assignment_initial( # pylint: disable=name-too-lo return deserialized # type: ignore @overload - def begin_create_update_table_role_assignment( # pylint: disable=name-too-long + def begin_update_table_throughput( self, resource_group_name: str, account_name: str, - role_assignment_id: str, - create_update_table_role_assignment_parameters: _models.TableRoleAssignmentResource, + table_name: str, + update_throughput_parameters: _models.ThroughputSettingsUpdateParameters, *, content_type: str = "application/json", **kwargs: Any - ) -> LROPoller[_models.TableRoleAssignmentResource]: - """Creates or updates an Azure Cosmos DB Table Role Assignment. + ) -> LROPoller[_models.ThroughputSettingsGetResults]: + """Update RUs per second of an Azure Cosmos DB Table. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param role_assignment_id: The GUID for the Role Assignment. Required. - :type role_assignment_id: str - :param create_update_table_role_assignment_parameters: The properties required to create or - update a Role Assignment. Required. - :type create_update_table_role_assignment_parameters: - ~azure.mgmt.cosmosdb.models.TableRoleAssignmentResource + :param table_name: Cosmos DB table name. Required. + :type table_name: str + :param update_throughput_parameters: The parameters to provide for the RUs per second of the + current Table. Required. + :type update_throughput_parameters: + ~azure.mgmt.cosmosdb.models.ThroughputSettingsUpdateParameters :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 TableRoleAssignmentResource or the result - of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.TableRoleAssignmentResource] + :return: An instance of LROPoller that returns either ThroughputSettingsGetResults or the + result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.ThroughputSettingsGetResults] :raises ~azure.core.exceptions.HttpResponseError: """ @overload - def begin_create_update_table_role_assignment( # pylint: disable=name-too-long + def begin_update_table_throughput( self, resource_group_name: str, account_name: str, - role_assignment_id: str, - create_update_table_role_assignment_parameters: IO[bytes], + table_name: str, + update_throughput_parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> LROPoller[_models.TableRoleAssignmentResource]: - """Creates or updates an Azure Cosmos DB Table Role Assignment. + ) -> LROPoller[_models.ThroughputSettingsGetResults]: + """Update RUs per second of an Azure Cosmos DB Table. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param role_assignment_id: The GUID for the Role Assignment. Required. - :type role_assignment_id: str - :param create_update_table_role_assignment_parameters: The properties required to create or - update a Role Assignment. Required. - :type create_update_table_role_assignment_parameters: IO[bytes] + :param table_name: Cosmos DB table name. Required. + :type table_name: str + :param update_throughput_parameters: The parameters to provide for the RUs per second of the + current Table. Required. + :type update_throughput_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 TableRoleAssignmentResource or the result - of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.TableRoleAssignmentResource] + :return: An instance of LROPoller that returns either ThroughputSettingsGetResults or the + result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.ThroughputSettingsGetResults] :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace - def begin_create_update_table_role_assignment( # pylint: disable=name-too-long + def begin_update_table_throughput( self, resource_group_name: str, account_name: str, - role_assignment_id: str, - create_update_table_role_assignment_parameters: Union[_models.TableRoleAssignmentResource, IO[bytes]], + table_name: str, + update_throughput_parameters: Union[_models.ThroughputSettingsUpdateParameters, IO[bytes]], **kwargs: Any - ) -> LROPoller[_models.TableRoleAssignmentResource]: - """Creates or updates an Azure Cosmos DB Table Role Assignment. + ) -> LROPoller[_models.ThroughputSettingsGetResults]: + """Update RUs per second of an Azure Cosmos DB Table. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param role_assignment_id: The GUID for the Role Assignment. Required. - :type role_assignment_id: str - :param create_update_table_role_assignment_parameters: The properties required to create or - update a Role Assignment. Is either a TableRoleAssignmentResource type or a IO[bytes] type. + :param table_name: Cosmos DB table name. Required. + :type table_name: str + :param update_throughput_parameters: The parameters to provide for the RUs per second of the + current Table. Is either a ThroughputSettingsUpdateParameters type or a IO[bytes] type. Required. - :type create_update_table_role_assignment_parameters: - ~azure.mgmt.cosmosdb.models.TableRoleAssignmentResource or IO[bytes] - :return: An instance of LROPoller that returns either TableRoleAssignmentResource or the result - of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.TableRoleAssignmentResource] + :type update_throughput_parameters: + ~azure.mgmt.cosmosdb.models.ThroughputSettingsUpdateParameters or IO[bytes] + :return: An instance of LROPoller that returns either ThroughputSettingsGetResults or the + result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.ThroughputSettingsGetResults] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -2613,16 +2629,16 @@ def begin_create_update_table_role_assignment( # pylint: disable=name-too-long 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.TableRoleAssignmentResource] = kwargs.pop("cls", None) + cls: ClsType[_models.ThroughputSettingsGetResults] = 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_update_table_role_assignment_initial( + raw_result = self._update_table_throughput_initial( resource_group_name=resource_group_name, account_name=account_name, - role_assignment_id=role_assignment_id, - create_update_table_role_assignment_parameters=create_update_table_role_assignment_parameters, + table_name=table_name, + update_throughput_parameters=update_throughput_parameters, api_version=api_version, content_type=content_type, cls=lambda x, y, z: x, @@ -2634,30 +2650,32 @@ def begin_create_update_table_role_assignment( # pylint: disable=name-too-long kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("TableRoleAssignmentResource", pipeline_response.http_response) + deserialized = self._deserialize("ThroughputSettingsGetResults", 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, **kwargs)) + 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.TableRoleAssignmentResource].from_continuation_token( + return LROPoller[_models.ThroughputSettingsGetResults].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller[_models.TableRoleAssignmentResource]( + return LROPoller[_models.ThroughputSettingsGetResults]( self._client, raw_result, get_long_running_output, polling_method # type: ignore ) - def _delete_table_role_assignment_initial( - self, resource_group_name: str, account_name: str, role_assignment_id: str, **kwargs: Any + def _migrate_table_to_autoscale_initial( + self, resource_group_name: str, account_name: str, table_name: str, **kwargs: Any ) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -2673,10 +2691,10 @@ def _delete_table_role_assignment_initial( 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_table_role_assignment_request( + _request = build_migrate_table_to_autoscale_request( resource_group_name=resource_group_name, account_name=account_name, - role_assignment_id=role_assignment_id, + table_name=table_name, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, @@ -2692,24 +2710,21 @@ def _delete_table_role_assignment_initial( response = pipeline_response.http_response - if response.status_code not in [200, 202, 204]: + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) response_headers = {} if response.status_code == 202: - response_headers["azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("azure-AsyncOperation") + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") ) - response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) @@ -2719,35 +2734,36 @@ def _delete_table_role_assignment_initial( return deserialized # type: ignore @distributed_trace - def begin_delete_table_role_assignment( - self, resource_group_name: str, account_name: str, role_assignment_id: str, **kwargs: Any - ) -> LROPoller[None]: - """Deletes an existing Azure Cosmos DB Table Role Assignment. + def begin_migrate_table_to_autoscale( + self, resource_group_name: str, account_name: str, table_name: str, **kwargs: Any + ) -> LROPoller[_models.ThroughputSettingsGetResults]: + """Migrate an Azure Cosmos DB Table from manual throughput to autoscale. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param role_assignment_id: The GUID for the Role Assignment. Required. - :type role_assignment_id: str - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] + :param table_name: Cosmos DB table name. Required. + :type table_name: str + :return: An instance of LROPoller that returns either ThroughputSettingsGetResults or the + result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.ThroughputSettingsGetResults] :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) + cls: ClsType[_models.ThroughputSettingsGetResults] = 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_table_role_assignment_initial( + raw_result = self._migrate_table_to_autoscale_initial( resource_group_name=resource_group_name, account_name=account_name, - role_assignment_id=role_assignment_id, + table_name=table_name, api_version=api_version, cls=lambda x, y, z: x, headers=_headers, @@ -2757,47 +2773,34 @@ def begin_delete_table_role_assignment( raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("ThroughputSettingsGetResults", pipeline_response.http_response) if cls: - return cls(pipeline_response, None, {}) # type: ignore + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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( + return LROPoller[_models.ThroughputSettingsGetResults].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_table_role_assignments( - self, resource_group_name: str, account_name: str, **kwargs: Any - ) -> ItemPaged["_models.TableRoleAssignmentResource"]: - """Retrieves the list of all Azure Cosmos DB Table Role Assignments. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param account_name: Cosmos DB database account name. Required. - :type account_name: str - :return: An iterator like instance of either TableRoleAssignmentResource or the result of - cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cosmosdb.models.TableRoleAssignmentResource] - :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.TableRoleAssignmentListResult] = kwargs.pop("cls", None) + return LROPoller[_models.ThroughputSettingsGetResults]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + def _migrate_table_to_manual_throughput_initial( # pylint: disable=name-too-long + self, resource_group_name: str, account_name: str, table_name: str, **kwargs: Any + ) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -2806,60 +2809,115 @@ def list_table_role_assignments( } error_map.update(kwargs.pop("error_map", {}) or {}) - def prepare_request(next_link=None): - if not next_link: + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _request = build_list_table_role_assignments_request( - resource_group_name=resource_group_name, - account_name=account_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - 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 + _request = build_migrate_table_to_manual_throughput_request( + resource_group_name=resource_group_name, + account_name=account_name, + table_name=table_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) - def extract_data(pipeline_response): - deserialized = self._deserialize("TableRoleAssignmentListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return None, iter(list_of_elem) + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) - def get_next(next_link=None): - _request = prepare_request(next_link) + response = pipeline_response.http_response - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") ) - response = pipeline_response.http_response + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - 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 = response.stream_download(self._client._pipeline, decompress=_decompress) - return pipeline_response + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore - return ItemPaged(get_next, extract_data) + return deserialized # type: ignore + + @distributed_trace + def begin_migrate_table_to_manual_throughput( + self, resource_group_name: str, account_name: str, table_name: str, **kwargs: Any + ) -> LROPoller[_models.ThroughputSettingsGetResults]: + """Migrate an Azure Cosmos DB Table from autoscale to manual throughput. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param table_name: Cosmos DB table name. Required. + :type table_name: str + :return: An instance of LROPoller that returns either ThroughputSettingsGetResults or the + result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.ThroughputSettingsGetResults] + :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.ThroughputSettingsGetResults] = 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_table_to_manual_throughput_initial( + resource_group_name=resource_group_name, + account_name=account_name, + table_name=table_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("ThroughputSettingsGetResults", 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": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.ThroughputSettingsGetResults].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.ThroughputSettingsGetResults]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) diff --git a/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/operations/_throughput_pool_account_operations.py b/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/operations/_throughput_pool_account_operations.py index e87d6e5ad52..f93f9eae5b9 100644 --- a/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/operations/_throughput_pool_account_operations.py +++ b/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/operations/_throughput_pool_account_operations.py @@ -51,7 +51,7 @@ def build_get_request( _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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -103,7 +103,7 @@ def build_create_request( _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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -158,7 +158,7 @@ def build_delete_request( _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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -349,10 +349,17 @@ def _create_initial( ) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + response_headers = {} + if response.status_code == 201: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @@ -553,10 +560,10 @@ def _delete_initial( response_headers = {} if response.status_code == 202: - response_headers["azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("azure-AsyncOperation") + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") ) - response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) @@ -610,7 +617,9 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- return cls(pipeline_response, None, {}) # type: ignore if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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: diff --git a/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/operations/_throughput_pool_accounts_operations.py b/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/operations/_throughput_pool_accounts_operations.py index f4e0b5609f6..21cb9f48738 100644 --- a/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/operations/_throughput_pool_accounts_operations.py +++ b/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/operations/_throughput_pool_accounts_operations.py @@ -44,7 +44,7 @@ def build_list_request( _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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL diff --git a/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/operations/_throughput_pool_operations.py b/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/operations/_throughput_pool_operations.py index 42a9aab3eee..360543470b6 100644 --- a/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/operations/_throughput_pool_operations.py +++ b/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/operations/_throughput_pool_operations.py @@ -47,7 +47,7 @@ def build_get_request( _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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -87,7 +87,7 @@ def build_create_or_update_request( _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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -130,7 +130,7 @@ def build_update_request( _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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -173,7 +173,7 @@ def build_delete_request( _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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -348,10 +348,17 @@ def _create_or_update_initial( ) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + response_headers = {} + if response.status_code == 201: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @@ -555,10 +562,11 @@ def _update_initial( response_headers = {} if response.status_code == 202: - response_headers["azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("azure-AsyncOperation") + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") ) - response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) @@ -743,10 +751,10 @@ def _delete_initial(self, resource_group_name: str, throughput_pool_name: str, * response_headers = {} if response.status_code == 202: - response_headers["azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("azure-AsyncOperation") + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") ) - response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) @@ -794,7 +802,9 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- return cls(pipeline_response, None, {}) # type: ignore if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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: diff --git a/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/operations/_throughput_pools_operations.py b/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/operations/_throughput_pools_operations.py index e131906664d..16a22453f42 100644 --- a/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/operations/_throughput_pools_operations.py +++ b/src/cosmosdb-preview/azext_cosmosdb_preview/vendored_sdks/azure_mgmt_cosmosdb/operations/_throughput_pools_operations.py @@ -42,7 +42,7 @@ def build_list_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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -66,7 +66,7 @@ def build_list_by_resource_group_request(resource_group_name: str, subscription_ _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-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL